From 478152413918af13a0f0f93ea4403dbec386cc85 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Wed, 24 Jan 2018 19:10:43 +0100 Subject: [PATCH] Finalized client-side storage --- src/Artemis.Core/Artemis.Core.csproj | 107 ++++----- src/Artemis.Core/Services/RgbService.cs | 15 +- src/Artemis.Core/packages.config | 17 +- src/Artemis.Storage/Artemis.Storage.csproj | 6 +- src/Artemis.Storage/Entities/FolderEntity.cs | 19 ++ .../Entities/KeypointEntity.cs | 15 ++ src/Artemis.Storage/Entities/Layer.cs | 18 -- src/Artemis.Storage/Entities/LayerEntity.cs | 21 ++ .../Entities/LayerSettingEntity.cs | 18 ++ src/Artemis.Storage/Entities/LedEntity.cs | 18 ++ src/Artemis.Storage/Entities/Profile.cs | 14 -- src/Artemis.Storage/Entities/ProfileEntity.cs | 16 ++ .../Entities/{Setting.cs => SettingEntity.cs} | 2 +- .../20171208203331_InitialCreate.Designer.cs | 67 ------ .../20171208203331_InitialCreate.cs | 59 ----- .../20180124134310_InitialCreate.Designer.cs | 190 ++++++++++++++++ .../20180124134310_InitialCreate.cs | 205 ++++++++++++++++++ .../Migrations/StorageContextModelSnapshot.cs | 193 ++++++++++++++--- src/Artemis.Storage/Storage.db | Bin 36864 -> 73728 bytes src/Artemis.Storage/StorageContext.cs | 16 +- src/Artemis.UI/Adorners/BoundingBoxAdorner.cs | 44 ++++ src/Artemis.UI/Artemis.UI.csproj | 107 ++++----- .../Controls/Visualizers/LedVisualizer.cs | 11 + .../Visualizers/RGBDeviceVisualizer.cs | 12 +- .../Visualizers/RGBSurfaceVisualizer.cs | 76 ++++++- .../Styles/Visualizers/LedVisualizer.xaml | 2 +- .../Visualizers/RGBSurfaceVisualizer.xaml | 6 +- src/Artemis.UI/packages.config | 17 ++ src/Artemis.sln | 104 --------- 29 files changed, 961 insertions(+), 434 deletions(-) create mode 100644 src/Artemis.Storage/Entities/FolderEntity.cs create mode 100644 src/Artemis.Storage/Entities/KeypointEntity.cs delete mode 100644 src/Artemis.Storage/Entities/Layer.cs create mode 100644 src/Artemis.Storage/Entities/LayerEntity.cs create mode 100644 src/Artemis.Storage/Entities/LayerSettingEntity.cs create mode 100644 src/Artemis.Storage/Entities/LedEntity.cs delete mode 100644 src/Artemis.Storage/Entities/Profile.cs create mode 100644 src/Artemis.Storage/Entities/ProfileEntity.cs rename src/Artemis.Storage/Entities/{Setting.cs => SettingEntity.cs} (85%) delete mode 100644 src/Artemis.Storage/Migrations/20171208203331_InitialCreate.Designer.cs delete mode 100644 src/Artemis.Storage/Migrations/20171208203331_InitialCreate.cs create mode 100644 src/Artemis.Storage/Migrations/20180124134310_InitialCreate.Designer.cs create mode 100644 src/Artemis.Storage/Migrations/20180124134310_InitialCreate.cs create mode 100644 src/Artemis.UI/Adorners/BoundingBoxAdorner.cs diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index 2a8ac8d4e..cf2c1cb7d 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -68,6 +68,42 @@ ..\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll + + ..\packages\RGB.NET.Brushes.0.0.1.26\lib\net45\RGB.NET.Brushes.dll + + + ..\packages\RGB.NET.Core.0.0.1.26\lib\net45\RGB.NET.Core.dll + + + ..\packages\RGB.NET.Decorators.0.0.1.26\lib\net45\RGB.NET.Decorators.dll + + + ..\packages\RGB.NET.Devices.Asus.0.0.1.26\lib\net45\RGB.NET.Devices.Asus.dll + + + ..\packages\RGB.NET.Devices.CoolerMaster.0.0.1.26\lib\net45\RGB.NET.Devices.CoolerMaster.dll + + + ..\packages\RGB.NET.Devices.Corsair.0.0.1.26\lib\net45\RGB.NET.Devices.Corsair.dll + + + ..\packages\RGB.NET.Devices.Logitech.0.0.1.26\lib\net45\RGB.NET.Devices.Logitech.dll + + + ..\packages\RGB.NET.Devices.Msi.0.0.1.26\lib\net45\RGB.NET.Devices.Msi.dll + + + ..\packages\RGB.NET.Devices.Novation.0.0.1.26\lib\net45\RGB.NET.Devices.Novation.dll + + + ..\packages\RGB.NET.Devices.Razer.0.0.1.26\lib\net45\RGB.NET.Devices.Razer.dll + + + ..\packages\RGB.NET.Groups.0.0.1.26\lib\net45\RGB.NET.Groups.dll + + + ..\packages\RGB.NET.Input.0.0.1.26\lib\net45\RGB.NET.Input.dll + ..\packages\Sanford.Multimedia.Midi.6.4.2\lib\net20\Sanford.Multimedia.Midi.dll @@ -138,7 +174,7 @@ - ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + ..\packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll @@ -178,58 +214,6 @@ - - {347c5f0f-f490-4dec-9c1c-6e84750d838d} - RGB.NET.Brushes - - - {5a4f9a75-75fe-47cd-90e5-914d5b20d232} - RGB.NET.Core - - - {7012c431-244a-453f-b7fd-59e030cdbc44} - RGB.NET.Decorators - - - {4f2f3fbd-a1e4-4968-a2ad-0514959e5e59} - RGB.NET.Devices.Asus - - - {85609427-d433-44e2-a249-ce890b66d845} - RGB.NET.Devices.CoolerMaster - - - {dda8c4c2-8abf-4fa0-9af9-c47ad0bfe47d} - RGB.NET.Devices.Corsair - - - {e7b2f174-fcc6-4fc7-9970-3138b5f4c921} - RGB.NET.Devices.Logitech - - - {4efd77c7-fdb4-4c6b-970c-0ef66d24be09} - RGB.NET.Devices.Msi - - - {db2911f6-404c-4bc8-b35f-232a7450755f} - RGB.NET.Devices.Novation - - - {24ff4acb-d679-4b2d-86d4-50ab6c02d816} - RGB.NET.Devices.Razer - - - {2a39f859-aad0-4c16-94f8-78057820b376} - RGB.NET.Groups - - - {f905c418-76bb-4ba6-88ab-0793bc2681d3} - RGB.NET.Input.Corsair - - - {e60c3c6f-903f-4d80-99d0-7a1e50af5a9d} - RGB.NET.Input - {cd23bc5e-57f0-46ce-a007-24d031146219} Artemis.Plugins @@ -239,4 +223,21 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs index c762510ae..3885a68f6 100644 --- a/src/Artemis.Core/Services/RgbService.cs +++ b/src/Artemis.Core/Services/RgbService.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading.Tasks; using Artemis.Core.Events; using Artemis.Core.Services.Interfaces; @@ -42,15 +43,19 @@ namespace Artemis.Core.Services Surface.LoadDevices(LogitechDeviceProvider.Instance); Surface.LoadDevices(CoolerMasterDeviceProvider.Instance); // Surface.LoadDevices(NovationDeviceProvider.Instance); - + // TODO SpoinkyNL 8-1-18: Load alignment Surface.AlignDevies(); // Do some testing, why does this work, how does it know I want to target the surface? Check source! - var ledGroup = new RectangleLedGroup(Surface.SurfaceRectangle) - { - Brush = new SolidColorBrush(new Color(255, 0, 0)) { BrushCalculationMode = BrushCalculationMode.Absolute } - }; + var mouse1 = Surface.Leds.First(l => l.Id == LedId.Mouse1); + mouse1.Color = new Color(255, 0, 0); + var mouse2 = Surface.Leds.First(l => l.Id == LedId.Mouse2); + mouse2.Color = new Color(255, 255, 0); + var mouse3 = Surface.Leds.First(l => l.Id == LedId.Mouse3); + mouse3.Color = new Color(255, 255, 255); + var mouse4 = Surface.Leds.First(l => l.Id == LedId.Mouse4); + mouse4.Color = new Color(255, 0, 255); Surface.UpdateMode = UpdateMode.Continuous; }); diff --git a/src/Artemis.Core/packages.config b/src/Artemis.Core/packages.config index 7257243c9..693215aa2 100644 --- a/src/Artemis.Core/packages.config +++ b/src/Artemis.Core/packages.config @@ -13,6 +13,21 @@ + + + + + + + + + + + + + + + @@ -52,7 +67,7 @@ - + diff --git a/src/Artemis.Storage/Artemis.Storage.csproj b/src/Artemis.Storage/Artemis.Storage.csproj index d595d73b6..40afd4843 100644 --- a/src/Artemis.Storage/Artemis.Storage.csproj +++ b/src/Artemis.Storage/Artemis.Storage.csproj @@ -2,13 +2,17 @@ net461 - + + + + + diff --git a/src/Artemis.Storage/Entities/FolderEntity.cs b/src/Artemis.Storage/Entities/FolderEntity.cs new file mode 100644 index 000000000..76cf0d292 --- /dev/null +++ b/src/Artemis.Storage/Entities/FolderEntity.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Artemis.Storage.Entities +{ + [Table("Folders")] + internal class FolderEntity + { + [Key] + public int Id { get; set; } + + public int Order { get; set; } + public string Name { get; set; } + + public virtual ICollection Folders { get; set; } + public virtual ICollection Layers { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/KeypointEntity.cs b/src/Artemis.Storage/Entities/KeypointEntity.cs new file mode 100644 index 000000000..dde39792d --- /dev/null +++ b/src/Artemis.Storage/Entities/KeypointEntity.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Artemis.Storage.Entities +{ + [Table("Keypoints")] + internal class KeypointEntity + { + [Key] + public int Id { get; set; } + + public int Time { get; set; } + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Layer.cs b/src/Artemis.Storage/Entities/Layer.cs deleted file mode 100644 index 449461a71..000000000 --- a/src/Artemis.Storage/Entities/Layer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; - -namespace Artemis.Storage.Entities -{ - internal class Layer - { - public int ProfileId { get; set; } - public string Name { get; set; } - public LayerType LayerType { get; set; } - - public virtual Profile Profile { get; set; } - public virtual ICollection Layers { get; set; } - } - - internal enum LayerType - { - } -} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/LayerEntity.cs b/src/Artemis.Storage/Entities/LayerEntity.cs new file mode 100644 index 000000000..d74ae823a --- /dev/null +++ b/src/Artemis.Storage/Entities/LayerEntity.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Artemis.Storage.Entities +{ + [Table("Layers")] + internal class LayerEntity + { + [Key] + public int Id { get; set; } + + public string Type { get; set; } + + public virtual ICollection Leds { get; set; } + public virtual ICollection Settings { get; set; } + + public int Order { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/LayerSettingEntity.cs b/src/Artemis.Storage/Entities/LayerSettingEntity.cs new file mode 100644 index 000000000..a9f50cb10 --- /dev/null +++ b/src/Artemis.Storage/Entities/LayerSettingEntity.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Artemis.Storage.Entities +{ + [Table("LayerSettings")] + internal class LayerSettingEntity + { + [Key] + public int Id { get; set; } + + public string Name { get; set; } + public string Value { get; set; } + + public ICollection Keypoints { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/LedEntity.cs b/src/Artemis.Storage/Entities/LedEntity.cs new file mode 100644 index 000000000..22d0a934d --- /dev/null +++ b/src/Artemis.Storage/Entities/LedEntity.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Artemis.Storage.Entities +{ + [Table("Leds")] + internal class LedEntity + { + [Key] + public int Id { get; set; } + + public string LedName { get; set; } + public string LimitedToDevice { get; set; } + + public int LayerId { get; set; } + public virtual LayerEntity Layer { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile.cs b/src/Artemis.Storage/Entities/Profile.cs deleted file mode 100644 index b9bdf8252..000000000 --- a/src/Artemis.Storage/Entities/Profile.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace Artemis.Storage.Entities -{ - internal class Profile - { - [Key] - public int Id { get; set; } - - public string Name { get; set; } - public virtual ICollection Layers { get; set; } - } -} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/ProfileEntity.cs b/src/Artemis.Storage/Entities/ProfileEntity.cs new file mode 100644 index 000000000..8ae73e9b5 --- /dev/null +++ b/src/Artemis.Storage/Entities/ProfileEntity.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace Artemis.Storage.Entities +{ + internal class ProfileEntity + { + [Key] + public int Id { get; set; } + + public string Name { get; set; } + public string Module { get; set; } + + public int RootFolderId { get; set; } + public virtual FolderEntity RootFolder { get; set; } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Setting.cs b/src/Artemis.Storage/Entities/SettingEntity.cs similarity index 85% rename from src/Artemis.Storage/Entities/Setting.cs rename to src/Artemis.Storage/Entities/SettingEntity.cs index 4463e1971..19690251b 100644 --- a/src/Artemis.Storage/Entities/Setting.cs +++ b/src/Artemis.Storage/Entities/SettingEntity.cs @@ -2,7 +2,7 @@ namespace Artemis.Storage.Entities { - internal class Setting + internal class SettingEntity { [Key] public string Name { get; set; } diff --git a/src/Artemis.Storage/Migrations/20171208203331_InitialCreate.Designer.cs b/src/Artemis.Storage/Migrations/20171208203331_InitialCreate.Designer.cs deleted file mode 100644 index 96b5c0139..000000000 --- a/src/Artemis.Storage/Migrations/20171208203331_InitialCreate.Designer.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -using Artemis.Storage; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage; -using System; - -namespace Artemis.Storage.Migrations -{ - [DbContext(typeof(StorageContext))] - [Migration("20171208203331_InitialCreate")] - partial class InitialCreate - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.0.1-rtm-125"); - - modelBuilder.Entity("Artemis.Storage.Entities.Layer", b => - { - b.Property("ProfileId"); - - b.Property("Name"); - - b.HasKey("ProfileId", "Name"); - - b.ToTable("Layer"); - }); - - modelBuilder.Entity("Artemis.Storage.Entities.Profile", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Name"); - - b.HasKey("Id"); - - b.ToTable("Profiles"); - }); - - modelBuilder.Entity("Artemis.Storage.Entities.Setting", b => - { - b.Property("Name") - .ValueGeneratedOnAdd(); - - b.Property("Value"); - - b.HasKey("Name"); - - b.ToTable("Settings"); - }); - - modelBuilder.Entity("Artemis.Storage.Entities.Layer", b => - { - b.HasOne("Artemis.Storage.Entities.Profile", "Profile") - .WithMany("Layers") - .HasForeignKey("ProfileId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Artemis.Storage/Migrations/20171208203331_InitialCreate.cs b/src/Artemis.Storage/Migrations/20171208203331_InitialCreate.cs deleted file mode 100644 index 84894e771..000000000 --- a/src/Artemis.Storage/Migrations/20171208203331_InitialCreate.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Artemis.Storage.Migrations -{ - public partial class InitialCreate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - "Profiles", - table => new - { - Id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(nullable: true) - }, - constraints: table => { table.PrimaryKey("PK_Profiles", x => x.Id); }); - - migrationBuilder.CreateTable( - "Settings", - table => new - { - Name = table.Column(nullable: false), - Value = table.Column(nullable: true) - }, - constraints: table => { table.PrimaryKey("PK_Settings", x => x.Name); }); - - migrationBuilder.CreateTable( - "Layer", - table => new - { - ProfileId = table.Column(nullable: false), - Name = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Layer", x => new {x.ProfileId, x.Name}); - table.ForeignKey( - "FK_Layer_Profiles_ProfileId", - x => x.ProfileId, - "Profiles", - "Id", - onDelete: ReferentialAction.Cascade); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - "Layer"); - - migrationBuilder.DropTable( - "Settings"); - - migrationBuilder.DropTable( - "Profiles"); - } - } -} \ No newline at end of file diff --git a/src/Artemis.Storage/Migrations/20180124134310_InitialCreate.Designer.cs b/src/Artemis.Storage/Migrations/20180124134310_InitialCreate.Designer.cs new file mode 100644 index 000000000..ac48f3eb0 --- /dev/null +++ b/src/Artemis.Storage/Migrations/20180124134310_InitialCreate.Designer.cs @@ -0,0 +1,190 @@ +// +using Artemis.Storage; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using System; + +namespace Artemis.Storage.Migrations +{ + [DbContext(typeof(StorageContext))] + [Migration("20180124134310_InitialCreate")] + partial class InitialCreate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.0.1-rtm-125"); + + modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("FolderEntityId"); + + b.Property("Name"); + + b.Property("Order"); + + b.HasKey("Id"); + + b.HasIndex("FolderEntityId"); + + b.ToTable("Folders"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("LayerSettingEntityId"); + + b.Property("Time"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.HasIndex("LayerSettingEntityId"); + + b.ToTable("Keypoints"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("FolderEntityId"); + + b.Property("Name"); + + b.Property("Order"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("FolderEntityId"); + + b.ToTable("Layers"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("LayerEntityId"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.HasIndex("LayerEntityId"); + + b.ToTable("LayerSettings"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("LayerId"); + + b.Property("LedName"); + + b.Property("LimitedToDevice"); + + b.HasKey("Id"); + + b.HasIndex("LayerId"); + + b.ToTable("Leds"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Module"); + + b.Property("Name"); + + b.Property("RootFolderId"); + + b.HasKey("Id"); + + b.HasIndex("RootFolderId"); + + b.ToTable("Profiles"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.SettingEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd(); + + b.Property("Value"); + + b.HasKey("Name"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b => + { + b.HasOne("Artemis.Storage.Entities.FolderEntity") + .WithMany("Folders") + .HasForeignKey("FolderEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b => + { + b.HasOne("Artemis.Storage.Entities.LayerSettingEntity") + .WithMany("Keypoints") + .HasForeignKey("LayerSettingEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b => + { + b.HasOne("Artemis.Storage.Entities.FolderEntity") + .WithMany("Layers") + .HasForeignKey("FolderEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b => + { + b.HasOne("Artemis.Storage.Entities.LayerEntity") + .WithMany("Settings") + .HasForeignKey("LayerEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b => + { + b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer") + .WithMany("Leds") + .HasForeignKey("LayerId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => + { + b.HasOne("Artemis.Storage.Entities.FolderEntity", "RootFolder") + .WithMany() + .HasForeignKey("RootFolderId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Artemis.Storage/Migrations/20180124134310_InitialCreate.cs b/src/Artemis.Storage/Migrations/20180124134310_InitialCreate.cs new file mode 100644 index 000000000..8f709fb9f --- /dev/null +++ b/src/Artemis.Storage/Migrations/20180124134310_InitialCreate.cs @@ -0,0 +1,205 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; + +namespace Artemis.Storage.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Folders", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FolderEntityId = table.Column(nullable: true), + Name = table.Column(nullable: true), + Order = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Folders", x => x.Id); + table.ForeignKey( + name: "FK_Folders_Folders_FolderEntityId", + column: x => x.FolderEntityId, + principalTable: "Folders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Settings", + columns: table => new + { + Name = table.Column(nullable: false), + Value = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Settings", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "Layers", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FolderEntityId = table.Column(nullable: true), + Name = table.Column(nullable: true), + Order = table.Column(nullable: false), + Type = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Layers", x => x.Id); + table.ForeignKey( + name: "FK_Layers_Folders_FolderEntityId", + column: x => x.FolderEntityId, + principalTable: "Folders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Profiles", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Module = table.Column(nullable: true), + Name = table.Column(nullable: true), + RootFolderId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Profiles", x => x.Id); + table.ForeignKey( + name: "FK_Profiles_Folders_RootFolderId", + column: x => x.RootFolderId, + principalTable: "Folders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "LayerSettings", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + LayerEntityId = table.Column(nullable: true), + Name = table.Column(nullable: true), + Value = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LayerSettings", x => x.Id); + table.ForeignKey( + name: "FK_LayerSettings_Layers_LayerEntityId", + column: x => x.LayerEntityId, + principalTable: "Layers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Leds", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + LayerId = table.Column(nullable: false), + LedName = table.Column(nullable: true), + LimitedToDevice = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Leds", x => x.Id); + table.ForeignKey( + name: "FK_Leds_Layers_LayerId", + column: x => x.LayerId, + principalTable: "Layers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Keypoints", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + LayerSettingEntityId = table.Column(nullable: true), + Time = table.Column(nullable: false), + Value = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Keypoints", x => x.Id); + table.ForeignKey( + name: "FK_Keypoints_LayerSettings_LayerSettingEntityId", + column: x => x.LayerSettingEntityId, + principalTable: "LayerSettings", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Folders_FolderEntityId", + table: "Folders", + column: "FolderEntityId"); + + migrationBuilder.CreateIndex( + name: "IX_Keypoints_LayerSettingEntityId", + table: "Keypoints", + column: "LayerSettingEntityId"); + + migrationBuilder.CreateIndex( + name: "IX_Layers_FolderEntityId", + table: "Layers", + column: "FolderEntityId"); + + migrationBuilder.CreateIndex( + name: "IX_LayerSettings_LayerEntityId", + table: "LayerSettings", + column: "LayerEntityId"); + + migrationBuilder.CreateIndex( + name: "IX_Leds_LayerId", + table: "Leds", + column: "LayerId"); + + migrationBuilder.CreateIndex( + name: "IX_Profiles_RootFolderId", + table: "Profiles", + column: "RootFolderId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Keypoints"); + + migrationBuilder.DropTable( + name: "Leds"); + + migrationBuilder.DropTable( + name: "Profiles"); + + migrationBuilder.DropTable( + name: "Settings"); + + migrationBuilder.DropTable( + name: "LayerSettings"); + + migrationBuilder.DropTable( + name: "Layers"); + + migrationBuilder.DropTable( + name: "Folders"); + } + } +} diff --git a/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs b/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs index 3cd74ed41..5cba3bdc1 100644 --- a/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs +++ b/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs @@ -1,12 +1,16 @@ // - +using Artemis.Storage; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using System; namespace Artemis.Storage.Migrations { [DbContext(typeof(StorageContext))] - internal class StorageContextModelSnapshot : ModelSnapshot + partial class StorageContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { @@ -14,49 +18,172 @@ namespace Artemis.Storage.Migrations modelBuilder .HasAnnotation("ProductVersion", "2.0.1-rtm-125"); - modelBuilder.Entity("Artemis.Storage.Entities.Layer", b => - { - b.Property("ProfileId"); + modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); - b.Property("Name"); + b.Property("FolderEntityId"); - b.HasKey("ProfileId", "Name"); + b.Property("Name"); - b.ToTable("Layer"); - }); + b.Property("Order"); - modelBuilder.Entity("Artemis.Storage.Entities.Profile", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + b.HasKey("Id"); - b.Property("Name"); + b.HasIndex("FolderEntityId"); - b.HasKey("Id"); + b.ToTable("Folders"); + }); - b.ToTable("Profiles"); - }); + modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); - modelBuilder.Entity("Artemis.Storage.Entities.Setting", b => - { - b.Property("Name") - .ValueGeneratedOnAdd(); + b.Property("LayerSettingEntityId"); - b.Property("Value"); + b.Property("Time"); - b.HasKey("Name"); + b.Property("Value"); - b.ToTable("Settings"); - }); + b.HasKey("Id"); - modelBuilder.Entity("Artemis.Storage.Entities.Layer", b => - { - b.HasOne("Artemis.Storage.Entities.Profile", "Profile") - .WithMany("Layers") - .HasForeignKey("ProfileId") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasIndex("LayerSettingEntityId"); + + b.ToTable("Keypoints"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("FolderEntityId"); + + b.Property("Name"); + + b.Property("Order"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.HasIndex("FolderEntityId"); + + b.ToTable("Layers"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("LayerEntityId"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.HasIndex("LayerEntityId"); + + b.ToTable("LayerSettings"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("LayerId"); + + b.Property("LedName"); + + b.Property("LimitedToDevice"); + + b.HasKey("Id"); + + b.HasIndex("LayerId"); + + b.ToTable("Leds"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Module"); + + b.Property("Name"); + + b.Property("RootFolderId"); + + b.HasKey("Id"); + + b.HasIndex("RootFolderId"); + + b.ToTable("Profiles"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.SettingEntity", b => + { + b.Property("Name") + .ValueGeneratedOnAdd(); + + b.Property("Value"); + + b.HasKey("Name"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b => + { + b.HasOne("Artemis.Storage.Entities.FolderEntity") + .WithMany("Folders") + .HasForeignKey("FolderEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b => + { + b.HasOne("Artemis.Storage.Entities.LayerSettingEntity") + .WithMany("Keypoints") + .HasForeignKey("LayerSettingEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b => + { + b.HasOne("Artemis.Storage.Entities.FolderEntity") + .WithMany("Layers") + .HasForeignKey("FolderEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b => + { + b.HasOne("Artemis.Storage.Entities.LayerEntity") + .WithMany("Settings") + .HasForeignKey("LayerEntityId"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b => + { + b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer") + .WithMany("Leds") + .HasForeignKey("LayerId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => + { + b.HasOne("Artemis.Storage.Entities.FolderEntity", "RootFolder") + .WithMany() + .HasForeignKey("RootFolderId") + .OnDelete(DeleteBehavior.Cascade); + }); #pragma warning restore 612, 618 } } -} \ No newline at end of file +} diff --git a/src/Artemis.Storage/Storage.db b/src/Artemis.Storage/Storage.db index 923747c3fc4eb73327823da9e974ebeace5078fb..77b0d6faa1abc728501f66d45b0c13860859b4cb 100644 GIT binary patch literal 73728 zcmeI)-%i_B9Ki7yD29{}TB)*7g|NH}8uiZz?b_W`T^39iH6&d~E08v2S>slgLeeJA zG%nMP$JtZtX4+++V3T&a2iWC~|HgKl7N*@4e=Q=L(+jf64W8 z8!JaEe`o(%K3!T{{Qc6Sh2IwL&;L4qf9_9_h3x_h46n$_!wqS?ZuUCHkCnsL(?S2G z*)@i(M!#?E^}8KoQ0e%ISIZ5()YR2VZC5{3wOQFUwO&&-{~}Gjp@j?63I}V8%FS!i z$gi_%bcU^J`^2uwKE5(lO*n^Jx}9Q|>|Lf6#@W2ARJNpXF(}q9@xZVwv-ip?U+-C_ zbs}mBpIV!)E_~W;nSZ5MdpJYTj37_p&8lEs53xEG4qGm$pU+LqCs!ZO9IDvqc(f?d z|9nnX>YLK|q2K=}#>wlx*|WU9dlG)-!P(WR`h!z$*JBsD4GHoDy^m)rj8oWu?xEi;t?<**Wm(zWlulb#`}?jDG&DF^@oH+8zO3r1 z7Nm>9a#>YuTBW0j7;oy2^@dujH`Us+YE>=QYX{9nNu-O|e$onE_OwyiFEx(TC;E|E zde*F0YNCdHz1F~k*X^Hu-tLaX>85_@w#iEmw`?!evdHiy zM}em9)f;-{am{JGcRNjuq}tH;^oCw5>j$cP$9Y+tNEBKH`;On$tGbvR8oFSrl$*J1 z;cYo9E7z_`Kby`_*!Qgcxf~q;?^ZsCy?e#k*ptT6_Y~#S+BSGxRI8fD;u+j&_IHgR z%ohncV&-;>TyAe?SDQfVSWRgrF_udQ<$-;C5Cz*#s_nReI+1QXyFFWY|!_40=N2&ef z^C?fR`XKOrzccD4grPQrHS)ln%rxFymOO9x&GDX6(N}b(n?GW0J*#;rrpIfSoR}UD9dv&V_xFoYct3eUAC{Q$RGeHCviGOk_`NRXwoexq zmGXv^ab6LIZ@OaAZM8?1cx@4{qbyC?@8)IY`gQ44amw_f*V`>b%JAMb?5X1%Pb;seGfbngA^!iuF&1}T zi-H?HUT<_Njh+23fp;j$%7X{e+qy&CYUz9X=Bq*5GW)&ZSLV>_4^9#j=c4?Hc_xDq zlxaVF-ADS2Fr86QLd=Ruu`_yMJs0<>Xl$%l5x|wXMdjNEvjRA=o>nn2d0s3tm+Ylx zPJE>NyNvi^LjVB;5I_I{1Q0*~0R#|00D+H2;FdJ6Z|!UsKi@9y+$-L_cel9Rs`O0D zYGced{oZx5{F+r^#FvZ7y7{*R3KVnYA{1Q0*~0R#|0009ILKmdV{RA6&n zUw+>Y1MJ`bi$D5jLjVB;5I_I{1Q0*~0R#|00D%iE!216J4=!Cp009ILKmY**5I_I{ z1Q0;L6JY&MC?J3U0tg_000IagfB*srAaL;o?0^5y-~V6yai)g|AbR%5pUN`{pa^`@=L=YrAOHYzZD`a0 diff --git a/src/Artemis.Storage/StorageContext.cs b/src/Artemis.Storage/StorageContext.cs index 791e0818e..e9cdb027d 100644 --- a/src/Artemis.Storage/StorageContext.cs +++ b/src/Artemis.Storage/StorageContext.cs @@ -5,24 +5,12 @@ namespace Artemis.Storage { internal class StorageContext : DbContext { - internal DbSet Profiles { get; set; } - internal DbSet Settings { get; set; } + internal DbSet Profiles { get; set; } + internal DbSet Settings { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlite("Data Source=Storage.db"); } - - #region Overrides of DbContext - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - // Composite keys must be configured with fluent API in Core - modelBuilder.Entity().HasKey(l => new {l.ProfileId, l.Name}); - - base.OnModelCreating(modelBuilder); - } - - #endregion } } \ No newline at end of file diff --git a/src/Artemis.UI/Adorners/BoundingBoxAdorner.cs b/src/Artemis.UI/Adorners/BoundingBoxAdorner.cs new file mode 100644 index 000000000..d585da88a --- /dev/null +++ b/src/Artemis.UI/Adorners/BoundingBoxAdorner.cs @@ -0,0 +1,44 @@ +using System.Windows; +using System.Windows.Documents; +using System.Windows.Media; + +namespace Artemis.UI.Adorners +{ + public class BoundingBoxAdorner : Adorner + { + private Color _boundingBoxColor; + private Rect _boundingBoxRect; + + public BoundingBoxAdorner(UIElement adornedElement, Color boundingBoxColor) : base(adornedElement) + { + _boundingBoxRect = new Rect(new Size(0, 0)); + BoundingBoxColor = boundingBoxColor; + + IsHitTestVisible = false; + } + + public Color BoundingBoxColor + { + get => _boundingBoxColor; + set + { + _boundingBoxColor = value; + InvalidateVisual(); + } + } + + protected override void OnRender(DrawingContext drawingContext) + { + var renderBrush = new SolidColorBrush(BoundingBoxColor) {Opacity = 0.2}; + var renderPen = new Pen(new SolidColorBrush(BoundingBoxColor), 1.5); + + drawingContext.DrawRectangle(renderBrush, renderPen, _boundingBoxRect); + } + + public void Update(Point startingPoint, Point currentPoint) + { + _boundingBoxRect = new Rect(startingPoint, currentPoint); + InvalidateVisual(); + } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index cefcbc905..e09810ea4 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -39,6 +39,9 @@ ..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll + + ..\packages\HidSharp.1.5\lib\net35\HidSharp.dll + ..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll @@ -63,6 +66,42 @@ ..\packages\PropertyChanged.Fody.2.2.4.0\lib\net452\PropertyChanged.dll + + ..\packages\RGB.NET.Brushes.0.0.1.26\lib\net45\RGB.NET.Brushes.dll + + + ..\packages\RGB.NET.Core.0.0.1.26\lib\net45\RGB.NET.Core.dll + + + ..\packages\RGB.NET.Decorators.0.0.1.26\lib\net45\RGB.NET.Decorators.dll + + + ..\packages\RGB.NET.Devices.Asus.0.0.1.26\lib\net45\RGB.NET.Devices.Asus.dll + + + ..\packages\RGB.NET.Devices.CoolerMaster.0.0.1.26\lib\net45\RGB.NET.Devices.CoolerMaster.dll + + + ..\packages\RGB.NET.Devices.Corsair.0.0.1.26\lib\net45\RGB.NET.Devices.Corsair.dll + + + ..\packages\RGB.NET.Devices.Logitech.0.0.1.26\lib\net45\RGB.NET.Devices.Logitech.dll + + + ..\packages\RGB.NET.Devices.Msi.0.0.1.26\lib\net45\RGB.NET.Devices.Msi.dll + + + ..\packages\RGB.NET.Devices.Novation.0.0.1.26\lib\net45\RGB.NET.Devices.Novation.dll + + + ..\packages\RGB.NET.Devices.Razer.0.0.1.26\lib\net45\RGB.NET.Devices.Razer.dll + + + ..\packages\RGB.NET.Groups.0.0.1.26\lib\net45\RGB.NET.Groups.dll + + + ..\packages\Sanford.Multimedia.Midi.6.4.1\lib\net20\Sanford.Multimedia.Midi.dll + ..\packages\Stylet.1.1.21\lib\net45\Stylet.dll @@ -70,6 +109,9 @@ + + ..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll + ..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll @@ -91,6 +133,7 @@ MSBuild:Compile Designer + @@ -165,58 +208,6 @@ - - {347c5f0f-f490-4dec-9c1c-6e84750d838d} - RGB.NET.Brushes - - - {5a4f9a75-75fe-47cd-90e5-914d5b20d232} - RGB.NET.Core - - - {7012c431-244a-453f-b7fd-59e030cdbc44} - RGB.NET.Decorators - - - {4f2f3fbd-a1e4-4968-a2ad-0514959e5e59} - RGB.NET.Devices.Asus - - - {85609427-d433-44e2-a249-ce890b66d845} - RGB.NET.Devices.CoolerMaster - - - {dda8c4c2-8abf-4fa0-9af9-c47ad0bfe47d} - RGB.NET.Devices.Corsair - - - {e7b2f174-fcc6-4fc7-9970-3138b5f4c921} - RGB.NET.Devices.Logitech - - - {4efd77c7-fdb4-4c6b-970c-0ef66d24be09} - RGB.NET.Devices.Msi - - - {db2911f6-404c-4bc8-b35f-232a7450755f} - RGB.NET.Devices.Novation - - - {24ff4acb-d679-4b2d-86d4-50ab6c02d816} - RGB.NET.Devices.Razer - - - {2a39f859-aad0-4c16-94f8-78057820b376} - RGB.NET.Groups - - - {f905c418-76bb-4ba6-88ab-0793bc2681d3} - RGB.NET.Input.Corsair - - - {e60c3c6f-903f-4d80-99d0-7a1e50af5a9d} - RGB.NET.Input - {9b811f9b-86b9-4771-87af-72bae7078a36} Artemis.Core @@ -250,5 +241,17 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs b/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs index 436302cc3..19c880803 100644 --- a/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs +++ b/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs @@ -1,5 +1,6 @@ using System.Windows; using System.Windows.Controls; +using System.Windows.Media; using RGB.NET.Core; namespace Artemis.UI.Controls.Visualizers @@ -32,5 +33,15 @@ namespace Artemis.UI.Controls.Visualizers // ReSharper restore InconsistentNaming #endregion + + public void Select() + { + BorderBrush = new SolidColorBrush(Colors.RoyalBlue); + } + + public void Deselect() + { + BorderBrush = new SolidColorBrush(Colors.Black); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs b/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs index bfc6e281e..d01cd3333 100644 --- a/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs +++ b/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs @@ -18,8 +18,8 @@ namespace Artemis.UI.Controls.Visualizers #endregion #region Properties & Fields - - private Canvas _canvas; + + public Canvas Canvas { get; private set; } #endregion @@ -51,7 +51,7 @@ namespace Artemis.UI.Controls.Visualizers /// public override void OnApplyTemplate() { - _canvas = (Canvas) GetTemplateChild(PART_CANVAS); + Canvas = (Canvas) GetTemplateChild(PART_CANVAS); LayoutLeds(); } @@ -63,14 +63,14 @@ namespace Artemis.UI.Controls.Visualizers private void LayoutLeds() { - if (_canvas == null) return; + if (Canvas == null) return; - _canvas.Children.Clear(); + Canvas.Children.Clear(); if (Device == null) return; foreach (Led led in Device) - _canvas.Children.Add(new LedVisualizer {Led = led}); + Canvas.Children.Add(new LedVisualizer {Led = led}); } #endregion diff --git a/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs b/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs index 5d27f1773..18b18e1fe 100644 --- a/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs +++ b/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs @@ -1,7 +1,14 @@ using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using Artemis.UI.Adorners; using RGB.NET.Core; +using RGB.NET.Groups; +using Point = System.Windows.Point; namespace Artemis.UI.Controls.Visualizers { @@ -22,6 +29,8 @@ namespace Artemis.UI.Controls.Visualizers private RGBSurface _surface; private Canvas _canvas; + private BoundingBoxAdorner _boundingBox; + private Point _startingPoint; //TODO DarthAffe 17.06.2017: This is ugly - redesign how device connect/disconnect is generally handled! private readonly List _newDevices = new List(); @@ -74,9 +83,70 @@ namespace Artemis.UI.Controls.Visualizers /// public override void OnApplyTemplate() { + // Detach any existing event handlers + if (_canvas != null) + { + _canvas.MouseLeftButtonDown -= ScrollViewerOnMouseLeftButtonDown; + _canvas.MouseLeftButtonUp -= ScrollViewerOnMouseLeftButtonUp; + } _canvas?.Children.Clear(); - _canvas = (Canvas)GetTemplateChild(PART_CANVAS); + _canvas = (Canvas) GetTemplateChild(PART_CANVAS); + UpdateSurface(); + + if (_canvas == null) return; + _canvas.MouseLeftButtonDown += ScrollViewerOnMouseLeftButtonDown; + _canvas.MouseLeftButtonUp += ScrollViewerOnMouseLeftButtonUp; + _canvas.MouseMove += ScrollViewerOnMouseMove; + } + + + private void ScrollViewerOnMouseLeftButtonDown(object sender, MouseButtonEventArgs mouseButtonEventArgs) + { + _canvas.CaptureMouse(); + _startingPoint = mouseButtonEventArgs.GetPosition(_canvas); + _boundingBox = new BoundingBoxAdorner(_canvas, Colors.RoyalBlue); + + var adornerLayer = AdornerLayer.GetAdornerLayer(_canvas); + adornerLayer.Add(_boundingBox); + } + + private void ScrollViewerOnMouseLeftButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs) + { + _canvas.ReleaseMouseCapture(); + var adornerLayer = AdornerLayer.GetAdornerLayer(_canvas); + var adorners = adornerLayer.GetAdorners(_canvas); + if (adorners == null) return; + foreach (var adorner in adorners) + adornerLayer.Remove(adorner); + + _boundingBox = null; + } + + private void ScrollViewerOnMouseMove(object sender, MouseEventArgs mouseEventArgs) + { + if (_boundingBox == null) return; + var currentPoint = mouseEventArgs.GetPosition(_canvas); + _boundingBox.Update(_startingPoint, currentPoint); + + var ledStart = new RGB.NET.Core.Point(_startingPoint.X, _startingPoint.Y); + var ledEnd = new RGB.NET.Core.Point(currentPoint.X, currentPoint.Y); + var selection = new RectangleLedGroup(ledStart, ledEnd, 0.1); + + // Deselect all LED of each device + var deviceLeds = new List(); + foreach (var rgbDeviceVisualizer in _canvas.Children.Cast()) + deviceLeds.AddRange(rgbDeviceVisualizer.Canvas.Children.Cast()); + + foreach (var ledVisualizer in deviceLeds) + ledVisualizer?.Deselect(); + + // Select all LEDs in the bounding box + foreach (var led in selection.GetLeds()) + { + var ledVisualizer = deviceLeds.FirstOrDefault(l => l.Led == led); + ledVisualizer?.Select(); + } } private void UpdateSurface() @@ -86,7 +156,7 @@ namespace Artemis.UI.Controls.Visualizers if (_newDevices.Count > 0) { foreach (IRGBDevice device in _newDevices) - _canvas.Children.Add(new RGBDeviceVisualizer { Device = device }); + _canvas.Children.Add(new RGBDeviceVisualizer {Device = device}); _newDevices.Clear(); } @@ -96,4 +166,4 @@ namespace Artemis.UI.Controls.Visualizers #endregion } -} +} \ No newline at end of file diff --git a/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml b/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml index c4f447c65..54b756850 100644 --- a/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml +++ b/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml @@ -80,7 +80,7 @@ - + diff --git a/src/Artemis.UI/Styles/Visualizers/RGBSurfaceVisualizer.xaml b/src/Artemis.UI/Styles/Visualizers/RGBSurfaceVisualizer.xaml index 72212954d..d590a1bad 100644 --- a/src/Artemis.UI/Styles/Visualizers/RGBSurfaceVisualizer.xaml +++ b/src/Artemis.UI/Styles/Visualizers/RGBSurfaceVisualizer.xaml @@ -22,10 +22,12 @@ - + HorizontalScrollBarVisibility="Auto" + Background="Transparent"> + @@ -10,5 +11,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.sln b/src/Artemis.sln index 6976bcc7c..58e1f8529 100644 --- a/src/Artemis.sln +++ b/src/Artemis.sln @@ -11,40 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Core", "Artemis.Cor EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins", "Artemis.Plugins\Artemis.Plugins.csproj", "{CD23BC5E-57F0-46CE-A007-24D031146219}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RGB.NET", "RGB.NET", "{9E919613-35F5-410D-80B3-F4FB69BE327B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Core", "..\..\RGB.NET\RGB.NET.Core\RGB.NET.Core.csproj", "{5A4F9A75-75FE-47CD-90E5-914D5B20D232}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Input", "..\..\RGB.NET\RGB.NET.Input\RGB.NET.Input.csproj", "{E60C3C6F-903F-4D80-99D0-7A1E50AF5A9D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devices", "Devices", "{03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presets", "Presets", "{87F6ED2F-10C1-43BB-B5CE-E95DF6C8ADCE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Asus", "..\..\RGB.NET\RGB.NET.Devices.Asus\RGB.NET.Devices.Asus.csproj", "{4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.CoolerMaster", "..\..\RGB.NET\RGB.NET.Devices.CoolerMaster\RGB.NET.Devices.CoolerMaster.csproj", "{85609427-D433-44E2-A249-CE890B66D845}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Corsair", "..\..\RGB.NET\RGB.NET.Devices.Corsair\RGB.NET.Devices.Corsair.csproj", "{DDA8C4C2-8ABF-4FA0-9AF9-C47AD0BFE47D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Logitech", "..\..\RGB.NET\RGB.NET.Devices.Logitech\RGB.NET.Devices.Logitech.csproj", "{E7B2F174-FCC6-4FC7-9970-3138B5F4C921}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Msi", "..\..\RGB.NET\RGB.NET.Devices.Msi\RGB.NET.Devices.Msi.csproj", "{4EFD77C7-FDB4-4C6B-970C-0EF66D24BE09}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Novation", "..\..\RGB.NET\RGB.NET.Devices.Novation\RGB.NET.Devices.Novation.csproj", "{DB2911F6-404C-4BC8-B35F-232A7450755F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Devices.Razer", "..\..\RGB.NET\RGB.NET.Devices.Razer\RGB.NET.Devices.Razer.csproj", "{24FF4ACB-D679-4B2D-86D4-50AB6C02D816}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Input", "Input", "{F1DE1C8B-E8B1-45EF-9FE8-47EF3B2E4D6E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Input.Corsair", "..\..\RGB.NET\RGB.NET.Input.Corsair\RGB.NET.Input.Corsair.csproj", "{F905C418-76BB-4BA6-88AB-0793BC2681D3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Brushes", "..\..\RGB.NET\RGB.NET.Brushes\RGB.NET.Brushes.csproj", "{347C5F0F-F490-4DEC-9C1C-6E84750D838D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Decorators", "..\..\RGB.NET\RGB.NET.Decorators\RGB.NET.Decorators.csproj", "{7012C431-244A-453F-B7FD-59E030CDBC44}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RGB.NET.Groups", "..\..\RGB.NET\RGB.NET.Groups\RGB.NET.Groups.csproj", "{2A39F859-AAD0-4C16-94F8-78057820B376}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,80 +33,10 @@ Global {CD23BC5E-57F0-46CE-A007-24D031146219}.Debug|Any CPU.Build.0 = Debug|Any CPU {CD23BC5E-57F0-46CE-A007-24D031146219}.Release|Any CPU.ActiveCfg = Release|Any CPU {CD23BC5E-57F0-46CE-A007-24D031146219}.Release|Any CPU.Build.0 = Release|Any CPU - {5A4F9A75-75FE-47CD-90E5-914D5B20D232}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5A4F9A75-75FE-47CD-90E5-914D5B20D232}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5A4F9A75-75FE-47CD-90E5-914D5B20D232}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5A4F9A75-75FE-47CD-90E5-914D5B20D232}.Release|Any CPU.Build.0 = Release|Any CPU - {E60C3C6F-903F-4D80-99D0-7A1E50AF5A9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E60C3C6F-903F-4D80-99D0-7A1E50AF5A9D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E60C3C6F-903F-4D80-99D0-7A1E50AF5A9D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E60C3C6F-903F-4D80-99D0-7A1E50AF5A9D}.Release|Any CPU.Build.0 = Release|Any CPU - {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59}.Release|Any CPU.Build.0 = Release|Any CPU - {85609427-D433-44E2-A249-CE890B66D845}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {85609427-D433-44E2-A249-CE890B66D845}.Debug|Any CPU.Build.0 = Debug|Any CPU - {85609427-D433-44E2-A249-CE890B66D845}.Release|Any CPU.ActiveCfg = Release|Any CPU - {85609427-D433-44E2-A249-CE890B66D845}.Release|Any CPU.Build.0 = Release|Any CPU - {DDA8C4C2-8ABF-4FA0-9AF9-C47AD0BFE47D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DDA8C4C2-8ABF-4FA0-9AF9-C47AD0BFE47D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DDA8C4C2-8ABF-4FA0-9AF9-C47AD0BFE47D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DDA8C4C2-8ABF-4FA0-9AF9-C47AD0BFE47D}.Release|Any CPU.Build.0 = Release|Any CPU - {E7B2F174-FCC6-4FC7-9970-3138B5F4C921}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7B2F174-FCC6-4FC7-9970-3138B5F4C921}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7B2F174-FCC6-4FC7-9970-3138B5F4C921}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7B2F174-FCC6-4FC7-9970-3138B5F4C921}.Release|Any CPU.Build.0 = Release|Any CPU - {4EFD77C7-FDB4-4C6B-970C-0EF66D24BE09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4EFD77C7-FDB4-4C6B-970C-0EF66D24BE09}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4EFD77C7-FDB4-4C6B-970C-0EF66D24BE09}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4EFD77C7-FDB4-4C6B-970C-0EF66D24BE09}.Release|Any CPU.Build.0 = Release|Any CPU - {DB2911F6-404C-4BC8-B35F-232A7450755F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB2911F6-404C-4BC8-B35F-232A7450755F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DB2911F6-404C-4BC8-B35F-232A7450755F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB2911F6-404C-4BC8-B35F-232A7450755F}.Release|Any CPU.Build.0 = Release|Any CPU - {24FF4ACB-D679-4B2D-86D4-50AB6C02D816}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24FF4ACB-D679-4B2D-86D4-50AB6C02D816}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24FF4ACB-D679-4B2D-86D4-50AB6C02D816}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24FF4ACB-D679-4B2D-86D4-50AB6C02D816}.Release|Any CPU.Build.0 = Release|Any CPU - {F905C418-76BB-4BA6-88AB-0793BC2681D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F905C418-76BB-4BA6-88AB-0793BC2681D3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F905C418-76BB-4BA6-88AB-0793BC2681D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F905C418-76BB-4BA6-88AB-0793BC2681D3}.Release|Any CPU.Build.0 = Release|Any CPU - {347C5F0F-F490-4DEC-9C1C-6E84750D838D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {347C5F0F-F490-4DEC-9C1C-6E84750D838D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {347C5F0F-F490-4DEC-9C1C-6E84750D838D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {347C5F0F-F490-4DEC-9C1C-6E84750D838D}.Release|Any CPU.Build.0 = Release|Any CPU - {7012C431-244A-453F-B7FD-59E030CDBC44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7012C431-244A-453F-B7FD-59E030CDBC44}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7012C431-244A-453F-B7FD-59E030CDBC44}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7012C431-244A-453F-B7FD-59E030CDBC44}.Release|Any CPU.Build.0 = Release|Any CPU - {2A39F859-AAD0-4C16-94F8-78057820B376}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2A39F859-AAD0-4C16-94F8-78057820B376}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2A39F859-AAD0-4C16-94F8-78057820B376}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2A39F859-AAD0-4C16-94F8-78057820B376}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {5A4F9A75-75FE-47CD-90E5-914D5B20D232} = {9E919613-35F5-410D-80B3-F4FB69BE327B} - {E60C3C6F-903F-4D80-99D0-7A1E50AF5A9D} = {9E919613-35F5-410D-80B3-F4FB69BE327B} - {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} = {9E919613-35F5-410D-80B3-F4FB69BE327B} - {87F6ED2F-10C1-43BB-B5CE-E95DF6C8ADCE} = {9E919613-35F5-410D-80B3-F4FB69BE327B} - {4F2F3FBD-A1E4-4968-A2AD-0514959E5E59} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {85609427-D433-44E2-A249-CE890B66D845} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {DDA8C4C2-8ABF-4FA0-9AF9-C47AD0BFE47D} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {E7B2F174-FCC6-4FC7-9970-3138B5F4C921} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {4EFD77C7-FDB4-4C6B-970C-0EF66D24BE09} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {DB2911F6-404C-4BC8-B35F-232A7450755F} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {24FF4ACB-D679-4B2D-86D4-50AB6C02D816} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {F1DE1C8B-E8B1-45EF-9FE8-47EF3B2E4D6E} = {03DD6C1C-B39B-4D1E-A905-EBDA94FCEBFA} - {F905C418-76BB-4BA6-88AB-0793BC2681D3} = {F1DE1C8B-E8B1-45EF-9FE8-47EF3B2E4D6E} - {347C5F0F-F490-4DEC-9C1C-6E84750D838D} = {87F6ED2F-10C1-43BB-B5CE-E95DF6C8ADCE} - {7012C431-244A-453F-B7FD-59E030CDBC44} = {87F6ED2F-10C1-43BB-B5CE-E95DF6C8ADCE} - {2A39F859-AAD0-4C16-94F8-78057820B376} = {87F6ED2F-10C1-43BB-B5CE-E95DF6C8ADCE} - EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C203080A-4473-4CC2-844B-F552EA43D66A} EndGlobalSection