1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Added devices ZIndex

This commit is contained in:
SpoinkyNL 2019-10-13 22:48:02 +02:00
parent 44549f86aa
commit 1ae103accc
9 changed files with 172 additions and 44 deletions

View File

@ -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; }
}
}

View File

@ -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; }

View File

@ -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<string>("Guid")
.ValueGeneratedOnAdd();
b.Property<string>("LayerGuid");
b.Property<int>("LayerId");
b.Property<string>("LayerId");
b.Property<string>("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<string>("Guid")
.ValueGeneratedOnAdd();
b.Property<bool>("IsActive");
b.Property<string>("Name");
b.HasKey("Guid");
b.ToTable("Surfaces");
});
modelBuilder.Entity("Artemis.Storage.Entities.SurfacePositionEntity", b =>
{
b.Property<string>("Guid")
.ValueGeneratedOnAdd();
b.Property<int>("DeviceId");
b.Property<string>("DeviceManufacturer");
b.Property<string>("DeviceModel");
b.Property<string>("DeviceName");
b.Property<double>("Rotation");
b.Property<string>("SurfaceId");
b.Property<double>("X");
b.Property<double>("Y");
b.Property<int>("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
}
}

View File

@ -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<string>(nullable: false),
Name = table.Column<string>(nullable: true),
IsActive = table.Column<bool>(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<string>(nullable: false),
DeviceId = table.Column<int>(nullable: false),
DeviceName = table.Column<string>(nullable: true),
DeviceModel = table.Column<string>(nullable: true),
DeviceManufacturer = table.Column<string>(nullable: true),
X = table.Column<double>(nullable: false),
Y = table.Column<double>(nullable: false),
Rotation = table.Column<double>(nullable: false),
ZIndex = table.Column<int>(nullable: false),
SurfaceId = table.Column<string>(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<string>(nullable: false),
LedName = table.Column<string>(nullable: true),
LimitedToDevice = table.Column<string>(nullable: true),
LayerId = table.Column<int>(nullable: false),
LayerGuid = table.Column<string>(nullable: true)
LayerId = table.Column<string>(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");

View File

@ -93,9 +93,7 @@ namespace Artemis.Storage.Migrations
b.Property<string>("Guid")
.ValueGeneratedOnAdd();
b.Property<string>("LayerGuid");
b.Property<int>("LayerId");
b.Property<string>("LayerId");
b.Property<string>("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<string>("Guid")
.ValueGeneratedOnAdd();
b.Property<bool>("IsActive");
b.Property<string>("Name");
b.HasKey("Guid");
b.ToTable("Surfaces");
});
modelBuilder.Entity("Artemis.Storage.Entities.SurfacePositionEntity", b =>
{
b.Property<string>("Guid")
.ValueGeneratedOnAdd();
b.Property<int>("DeviceId");
b.Property<string>("DeviceManufacturer");
b.Property<string>("DeviceModel");
b.Property<string>("DeviceName");
b.Property<double>("Rotation");
b.Property<string>("SurfaceId");
b.Property<double>("X");
b.Property<double>("Y");
b.Property<int>("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
}
}

View File

@ -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<SurfaceLedViewModel> Leds => _leds.AsReadOnly();
public Rect DeviceRectangle => new Rect(Device.Location.X, Device.Location.Y, Device.Size.Width, Device.Size.Height);

View File

@ -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

View File

@ -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}">
<UserControl.Resources>
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
</UserControl.Resources>

View File

@ -57,7 +57,7 @@
<Grid.Background>
<ImageBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,15,15" ImageSource="/Artemis.UI;component/Resources/tile.png" />
</Grid.Background>
<ItemsControl ItemsSource="{Binding Devices}" ClipToBounds="True">
<ItemsControl ItemsSource="{Binding Devices}" ClipToBounds="True" Panel.ZIndex="{Binding Device.ZIndex}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />