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 X { get; set; }
public double Y { get; set; } public double Y { get; set; }
public double Rotation { get; set; } public double Rotation { get; set; }
public int ZIndex { get; set; }
public string SurfaceId { get; set; } public string SurfaceId { get; set; }
public virtual SurfaceEntity Surface { get; set; } public virtual SurfaceEntity Surface { get; set; }

View File

@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Artemis.Storage.Migrations namespace Artemis.Storage.Migrations
{ {
[DbContext(typeof(StorageContext))] [DbContext(typeof(StorageContext))]
[Migration("20190429131614_InitialCreate")] [Migration("20191013153102_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -95,9 +95,7 @@ namespace Artemis.Storage.Migrations
b.Property<string>("Guid") b.Property<string>("Guid")
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd();
b.Property<string>("LayerGuid"); b.Property<string>("LayerId");
b.Property<int>("LayerId");
b.Property<string>("LedName"); b.Property<string>("LedName");
@ -105,7 +103,7 @@ namespace Artemis.Storage.Migrations
b.HasKey("Guid"); b.HasKey("Guid");
b.HasIndex("LayerGuid"); b.HasIndex("LayerId");
b.ToTable("Leds"); b.ToTable("Leds");
}); });
@ -155,6 +153,50 @@ namespace Artemis.Storage.Migrations
b.ToTable("Settings"); 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 => modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b =>
{ {
b.HasOne("Artemis.Storage.Entities.FolderEntity") b.HasOne("Artemis.Storage.Entities.FolderEntity")
@ -187,7 +229,7 @@ namespace Artemis.Storage.Migrations
{ {
b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer") b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer")
.WithMany("Leds") .WithMany("Leds")
.HasForeignKey("LayerGuid"); .HasForeignKey("LayerId");
}); });
modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
@ -196,6 +238,13 @@ namespace Artemis.Storage.Migrations
.WithMany() .WithMany()
.HasForeignKey("RootFolderGuid"); .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 #pragma warning restore 612, 618
} }
} }

View File

@ -52,6 +52,19 @@ namespace Artemis.Storage.Migrations
table.PrimaryKey("PK_Settings", x => x.Name); 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( migrationBuilder.CreateTable(
name: "Layers", name: "Layers",
columns: table => new columns: table => new
@ -93,6 +106,32 @@ namespace Artemis.Storage.Migrations
onDelete: ReferentialAction.Restrict); 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( migrationBuilder.CreateTable(
name: "LayerSettings", name: "LayerSettings",
columns: table => new columns: table => new
@ -120,15 +159,14 @@ namespace Artemis.Storage.Migrations
Guid = table.Column<string>(nullable: false), Guid = table.Column<string>(nullable: false),
LedName = table.Column<string>(nullable: true), LedName = table.Column<string>(nullable: true),
LimitedToDevice = table.Column<string>(nullable: true), LimitedToDevice = table.Column<string>(nullable: true),
LayerId = table.Column<int>(nullable: false), LayerId = table.Column<string>(nullable: true)
LayerGuid = table.Column<string>(nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Leds", x => x.Guid); table.PrimaryKey("PK_Leds", x => x.Guid);
table.ForeignKey( table.ForeignKey(
name: "FK_Leds_Layers_LayerGuid", name: "FK_Leds_Layers_LayerId",
column: x => x.LayerGuid, column: x => x.LayerId,
principalTable: "Layers", principalTable: "Layers",
principalColumn: "Guid", principalColumn: "Guid",
onDelete: ReferentialAction.Restrict); onDelete: ReferentialAction.Restrict);
@ -175,14 +213,19 @@ namespace Artemis.Storage.Migrations
column: "LayerEntityGuid"); column: "LayerEntityGuid");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Leds_LayerGuid", name: "IX_Leds_LayerId",
table: "Leds", table: "Leds",
column: "LayerGuid"); column: "LayerId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Profiles_RootFolderGuid", name: "IX_Profiles_RootFolderGuid",
table: "Profiles", table: "Profiles",
column: "RootFolderGuid"); column: "RootFolderGuid");
migrationBuilder.CreateIndex(
name: "IX_SurfacePositionEntity_SurfaceId",
table: "SurfacePositionEntity",
column: "SurfaceId");
} }
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
@ -202,9 +245,15 @@ namespace Artemis.Storage.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Settings"); name: "Settings");
migrationBuilder.DropTable(
name: "SurfacePositionEntity");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "LayerSettings"); name: "LayerSettings");
migrationBuilder.DropTable(
name: "Surfaces");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Layers"); name: "Layers");

View File

@ -93,9 +93,7 @@ namespace Artemis.Storage.Migrations
b.Property<string>("Guid") b.Property<string>("Guid")
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd();
b.Property<string>("LayerGuid"); b.Property<string>("LayerId");
b.Property<int>("LayerId");
b.Property<string>("LedName"); b.Property<string>("LedName");
@ -103,7 +101,7 @@ namespace Artemis.Storage.Migrations
b.HasKey("Guid"); b.HasKey("Guid");
b.HasIndex("LayerGuid"); b.HasIndex("LayerId");
b.ToTable("Leds"); b.ToTable("Leds");
}); });
@ -153,6 +151,50 @@ namespace Artemis.Storage.Migrations
b.ToTable("Settings"); 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 => modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b =>
{ {
b.HasOne("Artemis.Storage.Entities.FolderEntity") b.HasOne("Artemis.Storage.Entities.FolderEntity")
@ -185,7 +227,7 @@ namespace Artemis.Storage.Migrations
{ {
b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer") b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer")
.WithMany("Leds") .WithMany("Leds")
.HasForeignKey("LayerGuid"); .HasForeignKey("LayerId");
}); });
modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
@ -194,6 +236,13 @@ namespace Artemis.Storage.Migrations
.WithMany() .WithMany()
.HasForeignKey("RootFolderGuid"); .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 #pragma warning restore 612, 618
} }
} }

View File

@ -26,6 +26,7 @@ namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
public IRGBDevice Device { get; } public IRGBDevice Device { get; }
public SelectionStatus SelectionStatus { get; set; } public SelectionStatus SelectionStatus { get; set; }
public Cursor Cursor { get; set; } public Cursor Cursor { get; set; }
public int ZIndex { get; set; }
public IReadOnlyCollection<SurfaceLedViewModel> Leds => _leds.AsReadOnly(); public IReadOnlyCollection<SurfaceLedViewModel> Leds => _leds.AsReadOnly();
public Rect DeviceRectangle => new Rect(Device.Location.X, Device.Location.Y, Device.Size.Width, Device.Size.Height); 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"); SelectedSurfaceConfiguration = AddSurfaceConfiguration("Default");
}); });
} }
public SurfaceConfiguration AddSurfaceConfiguration(string name) public SurfaceConfiguration AddSurfaceConfiguration(string name)
{ {
var config = new SurfaceConfiguration(name); var config = new SurfaceConfiguration(name);
@ -107,7 +107,7 @@ namespace Artemis.UI.ViewModels.Screens
public void BringForward(SurfaceDeviceViewModel surfaceDeviceViewModel) public void BringForward(SurfaceDeviceViewModel surfaceDeviceViewModel)
{ {
Console.WriteLine("Bring forward"); surfaceDeviceViewModel.ZIndex++;
} }
public void SendToBack(SurfaceDeviceViewModel surfaceDeviceViewModel) public void SendToBack(SurfaceDeviceViewModel surfaceDeviceViewModel)
@ -117,7 +117,7 @@ namespace Artemis.UI.ViewModels.Screens
public void SendBackward(SurfaceDeviceViewModel surfaceDeviceViewModel) public void SendBackward(SurfaceDeviceViewModel surfaceDeviceViewModel)
{ {
Console.WriteLine("Send backward"); surfaceDeviceViewModel.ZIndex--;
} }
#endregion #endregion

View File

@ -12,7 +12,8 @@
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="450" d:DesignWidth="800"
Cursor="{Binding Cursor}" Cursor="{Binding Cursor}"
MouseEnter="{s:Action MouseEnter}" MouseEnter="{s:Action MouseEnter}"
MouseLeave="{s:Action MouseLeave}"> MouseLeave="{s:Action MouseLeave}"
ToolTip="{Binding Device.DeviceInfo.DeviceName}">
<UserControl.Resources> <UserControl.Resources>
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" /> <converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
</UserControl.Resources> </UserControl.Resources>

View File

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