From 1ae103acccac158d9d5b7a3f760702b721fcdee5 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sun, 13 Oct 2019 22:48:02 +0200 Subject: [PATCH] Added devices ZIndex --- .../Entities/SurfaceDeviceEntity.cs | 22 ------- .../Entities/SurfacePositionEntity.cs | 1 + ... 20191013153102_InitialCreate.Designer.cs} | 61 +++++++++++++++++-- ...ate.cs => 20191013153102_InitialCreate.cs} | 61 +++++++++++++++++-- .../Migrations/StorageContextModelSnapshot.cs | 59 ++++++++++++++++-- .../SurfaceEditor/SurfaceDeviceViewModel.cs | 1 + .../Screens/SurfaceEditorViewModel.cs | 6 +- .../SurfaceEditor/SurfaceDeviceView.xaml | 3 +- .../Views/Screens/SurfaceEditorView.xaml | 2 +- 9 files changed, 172 insertions(+), 44 deletions(-) delete mode 100644 src/Artemis.Storage/Entities/SurfaceDeviceEntity.cs rename src/Artemis.Storage/Migrations/{20190429131614_InitialCreate.Designer.cs => 20191013153102_InitialCreate.Designer.cs} (77%) rename src/Artemis.Storage/Migrations/{20190429131614_InitialCreate.cs => 20191013153102_InitialCreate.cs} (77%) diff --git a/src/Artemis.Storage/Entities/SurfaceDeviceEntity.cs b/src/Artemis.Storage/Entities/SurfaceDeviceEntity.cs deleted file mode 100644 index 30fcc71c8..000000000 --- a/src/Artemis.Storage/Entities/SurfaceDeviceEntity.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Artemis.Storage.Entities -{ - public class SurfaceDeviceEntity - { - [Key] - public string Guid { get; set; } - - public int DeviceId { get; set; } - public string DeviceName { get; set; } - public string DeviceModel { get; set; } - public string DeviceManufacturer { get; set; } - - public double X { get; set; } - public double Y { get; set; } - public double Rotation { get; set; } - - public string SurfaceId { get; set; } - public virtual SurfaceEntity Surface { get; set; } - } -} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/SurfacePositionEntity.cs b/src/Artemis.Storage/Entities/SurfacePositionEntity.cs index 7f2bfcbc9..5c115c363 100644 --- a/src/Artemis.Storage/Entities/SurfacePositionEntity.cs +++ b/src/Artemis.Storage/Entities/SurfacePositionEntity.cs @@ -15,6 +15,7 @@ namespace Artemis.Storage.Entities public double X { get; set; } public double Y { get; set; } public double Rotation { get; set; } + public int ZIndex { get; set; } public string SurfaceId { get; set; } public virtual SurfaceEntity Surface { get; set; } diff --git a/src/Artemis.Storage/Migrations/20190429131614_InitialCreate.Designer.cs b/src/Artemis.Storage/Migrations/20191013153102_InitialCreate.Designer.cs similarity index 77% rename from src/Artemis.Storage/Migrations/20190429131614_InitialCreate.Designer.cs rename to src/Artemis.Storage/Migrations/20191013153102_InitialCreate.Designer.cs index 9c1adaaad..e168cd87d 100644 --- a/src/Artemis.Storage/Migrations/20190429131614_InitialCreate.Designer.cs +++ b/src/Artemis.Storage/Migrations/20191013153102_InitialCreate.Designer.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Artemis.Storage.Migrations { [DbContext(typeof(StorageContext))] - [Migration("20190429131614_InitialCreate")] + [Migration("20191013153102_InitialCreate")] partial class InitialCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -95,9 +95,7 @@ namespace Artemis.Storage.Migrations b.Property("Guid") .ValueGeneratedOnAdd(); - b.Property("LayerGuid"); - - b.Property("LayerId"); + b.Property("LayerId"); b.Property("LedName"); @@ -105,7 +103,7 @@ namespace Artemis.Storage.Migrations b.HasKey("Guid"); - b.HasIndex("LayerGuid"); + b.HasIndex("LayerId"); b.ToTable("Leds"); }); @@ -155,6 +153,50 @@ namespace Artemis.Storage.Migrations b.ToTable("Settings"); }); + modelBuilder.Entity("Artemis.Storage.Entities.SurfaceEntity", b => + { + b.Property("Guid") + .ValueGeneratedOnAdd(); + + b.Property("IsActive"); + + b.Property("Name"); + + b.HasKey("Guid"); + + b.ToTable("Surfaces"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.SurfacePositionEntity", b => + { + b.Property("Guid") + .ValueGeneratedOnAdd(); + + b.Property("DeviceId"); + + b.Property("DeviceManufacturer"); + + b.Property("DeviceModel"); + + b.Property("DeviceName"); + + b.Property("Rotation"); + + b.Property("SurfaceId"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("ZIndex"); + + b.HasKey("Guid"); + + b.HasIndex("SurfaceId"); + + b.ToTable("SurfacePositionEntity"); + }); + modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b => { b.HasOne("Artemis.Storage.Entities.FolderEntity") @@ -187,7 +229,7 @@ namespace Artemis.Storage.Migrations { b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer") .WithMany("Leds") - .HasForeignKey("LayerGuid"); + .HasForeignKey("LayerId"); }); modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => @@ -196,6 +238,13 @@ namespace Artemis.Storage.Migrations .WithMany() .HasForeignKey("RootFolderGuid"); }); + + modelBuilder.Entity("Artemis.Storage.Entities.SurfacePositionEntity", b => + { + b.HasOne("Artemis.Storage.Entities.SurfaceEntity", "Surface") + .WithMany("SurfacePositions") + .HasForeignKey("SurfaceId"); + }); #pragma warning restore 612, 618 } } diff --git a/src/Artemis.Storage/Migrations/20190429131614_InitialCreate.cs b/src/Artemis.Storage/Migrations/20191013153102_InitialCreate.cs similarity index 77% rename from src/Artemis.Storage/Migrations/20190429131614_InitialCreate.cs rename to src/Artemis.Storage/Migrations/20191013153102_InitialCreate.cs index ee606d7e1..c6f6d4f58 100644 --- a/src/Artemis.Storage/Migrations/20190429131614_InitialCreate.cs +++ b/src/Artemis.Storage/Migrations/20191013153102_InitialCreate.cs @@ -52,6 +52,19 @@ namespace Artemis.Storage.Migrations table.PrimaryKey("PK_Settings", x => x.Name); }); + migrationBuilder.CreateTable( + name: "Surfaces", + columns: table => new + { + Guid = table.Column(nullable: false), + Name = table.Column(nullable: true), + IsActive = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Surfaces", x => x.Guid); + }); + migrationBuilder.CreateTable( name: "Layers", columns: table => new @@ -93,6 +106,32 @@ namespace Artemis.Storage.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "SurfacePositionEntity", + columns: table => new + { + Guid = table.Column(nullable: false), + DeviceId = table.Column(nullable: false), + DeviceName = table.Column(nullable: true), + DeviceModel = table.Column(nullable: true), + DeviceManufacturer = table.Column(nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Rotation = table.Column(nullable: false), + ZIndex = table.Column(nullable: false), + SurfaceId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SurfacePositionEntity", x => x.Guid); + table.ForeignKey( + name: "FK_SurfacePositionEntity_Surfaces_SurfaceId", + column: x => x.SurfaceId, + principalTable: "Surfaces", + principalColumn: "Guid", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateTable( name: "LayerSettings", columns: table => new @@ -120,15 +159,14 @@ namespace Artemis.Storage.Migrations Guid = table.Column(nullable: false), LedName = table.Column(nullable: true), LimitedToDevice = table.Column(nullable: true), - LayerId = table.Column(nullable: false), - LayerGuid = table.Column(nullable: true) + LayerId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Leds", x => x.Guid); table.ForeignKey( - name: "FK_Leds_Layers_LayerGuid", - column: x => x.LayerGuid, + name: "FK_Leds_Layers_LayerId", + column: x => x.LayerId, principalTable: "Layers", principalColumn: "Guid", onDelete: ReferentialAction.Restrict); @@ -175,14 +213,19 @@ namespace Artemis.Storage.Migrations column: "LayerEntityGuid"); migrationBuilder.CreateIndex( - name: "IX_Leds_LayerGuid", + name: "IX_Leds_LayerId", table: "Leds", - column: "LayerGuid"); + column: "LayerId"); migrationBuilder.CreateIndex( name: "IX_Profiles_RootFolderGuid", table: "Profiles", column: "RootFolderGuid"); + + migrationBuilder.CreateIndex( + name: "IX_SurfacePositionEntity_SurfaceId", + table: "SurfacePositionEntity", + column: "SurfaceId"); } protected override void Down(MigrationBuilder migrationBuilder) @@ -202,9 +245,15 @@ namespace Artemis.Storage.Migrations migrationBuilder.DropTable( name: "Settings"); + migrationBuilder.DropTable( + name: "SurfacePositionEntity"); + migrationBuilder.DropTable( name: "LayerSettings"); + migrationBuilder.DropTable( + name: "Surfaces"); + migrationBuilder.DropTable( name: "Layers"); diff --git a/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs b/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs index 4f579d102..d451cedaf 100644 --- a/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs +++ b/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs @@ -93,9 +93,7 @@ namespace Artemis.Storage.Migrations b.Property("Guid") .ValueGeneratedOnAdd(); - b.Property("LayerGuid"); - - b.Property("LayerId"); + b.Property("LayerId"); b.Property("LedName"); @@ -103,7 +101,7 @@ namespace Artemis.Storage.Migrations b.HasKey("Guid"); - b.HasIndex("LayerGuid"); + b.HasIndex("LayerId"); b.ToTable("Leds"); }); @@ -153,6 +151,50 @@ namespace Artemis.Storage.Migrations b.ToTable("Settings"); }); + modelBuilder.Entity("Artemis.Storage.Entities.SurfaceEntity", b => + { + b.Property("Guid") + .ValueGeneratedOnAdd(); + + b.Property("IsActive"); + + b.Property("Name"); + + b.HasKey("Guid"); + + b.ToTable("Surfaces"); + }); + + modelBuilder.Entity("Artemis.Storage.Entities.SurfacePositionEntity", b => + { + b.Property("Guid") + .ValueGeneratedOnAdd(); + + b.Property("DeviceId"); + + b.Property("DeviceManufacturer"); + + b.Property("DeviceModel"); + + b.Property("DeviceName"); + + b.Property("Rotation"); + + b.Property("SurfaceId"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("ZIndex"); + + b.HasKey("Guid"); + + b.HasIndex("SurfaceId"); + + b.ToTable("SurfacePositionEntity"); + }); + modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b => { b.HasOne("Artemis.Storage.Entities.FolderEntity") @@ -185,7 +227,7 @@ namespace Artemis.Storage.Migrations { b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer") .WithMany("Leds") - .HasForeignKey("LayerGuid"); + .HasForeignKey("LayerId"); }); modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => @@ -194,6 +236,13 @@ namespace Artemis.Storage.Migrations .WithMany() .HasForeignKey("RootFolderGuid"); }); + + modelBuilder.Entity("Artemis.Storage.Entities.SurfacePositionEntity", b => + { + b.HasOne("Artemis.Storage.Entities.SurfaceEntity", "Surface") + .WithMany("SurfacePositions") + .HasForeignKey("SurfaceId"); + }); #pragma warning restore 612, 618 } } diff --git a/src/Artemis.UI/ViewModels/Controls/SurfaceEditor/SurfaceDeviceViewModel.cs b/src/Artemis.UI/ViewModels/Controls/SurfaceEditor/SurfaceDeviceViewModel.cs index 3d7e2ba07..d86876553 100644 --- a/src/Artemis.UI/ViewModels/Controls/SurfaceEditor/SurfaceDeviceViewModel.cs +++ b/src/Artemis.UI/ViewModels/Controls/SurfaceEditor/SurfaceDeviceViewModel.cs @@ -26,6 +26,7 @@ namespace Artemis.UI.ViewModels.Controls.SurfaceEditor public IRGBDevice Device { get; } public SelectionStatus SelectionStatus { get; set; } public Cursor Cursor { get; set; } + public int ZIndex { get; set; } public IReadOnlyCollection Leds => _leds.AsReadOnly(); public Rect DeviceRectangle => new Rect(Device.Location.X, Device.Location.Y, Device.Size.Width, Device.Size.Height); diff --git a/src/Artemis.UI/ViewModels/Screens/SurfaceEditorViewModel.cs b/src/Artemis.UI/ViewModels/Screens/SurfaceEditorViewModel.cs index 6fe13a358..c033b861b 100644 --- a/src/Artemis.UI/ViewModels/Screens/SurfaceEditorViewModel.cs +++ b/src/Artemis.UI/ViewModels/Screens/SurfaceEditorViewModel.cs @@ -79,7 +79,7 @@ namespace Artemis.UI.ViewModels.Screens SelectedSurfaceConfiguration = AddSurfaceConfiguration("Default"); }); } - + public SurfaceConfiguration AddSurfaceConfiguration(string name) { var config = new SurfaceConfiguration(name); @@ -107,7 +107,7 @@ namespace Artemis.UI.ViewModels.Screens public void BringForward(SurfaceDeviceViewModel surfaceDeviceViewModel) { - Console.WriteLine("Bring forward"); + surfaceDeviceViewModel.ZIndex++; } public void SendToBack(SurfaceDeviceViewModel surfaceDeviceViewModel) @@ -117,7 +117,7 @@ namespace Artemis.UI.ViewModels.Screens public void SendBackward(SurfaceDeviceViewModel surfaceDeviceViewModel) { - Console.WriteLine("Send backward"); + surfaceDeviceViewModel.ZIndex--; } #endregion diff --git a/src/Artemis.UI/Views/Controls/SurfaceEditor/SurfaceDeviceView.xaml b/src/Artemis.UI/Views/Controls/SurfaceEditor/SurfaceDeviceView.xaml index 48245d358..db32f95d5 100644 --- a/src/Artemis.UI/Views/Controls/SurfaceEditor/SurfaceDeviceView.xaml +++ b/src/Artemis.UI/Views/Controls/SurfaceEditor/SurfaceDeviceView.xaml @@ -12,7 +12,8 @@ d:DesignHeight="450" d:DesignWidth="800" Cursor="{Binding Cursor}" MouseEnter="{s:Action MouseEnter}" - MouseLeave="{s:Action MouseLeave}"> + MouseLeave="{s:Action MouseLeave}" + ToolTip="{Binding Device.DeviceInfo.DeviceName}"> diff --git a/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml b/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml index 027888b69..77751674a 100644 --- a/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml +++ b/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml @@ -57,7 +57,7 @@ - +