Fix device ZIndex application

This commit is contained in:
SpoinkyNL committed 2019-11-13 22:52:24 +01:00
1 parent 61b675ae6c
commit dcf5dbb696
7 files changed
+49 -40

No files matched your search

@@ -37,8 +37,6 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
var targetFps = Math.Min(settingsService.GetSetting("TargetFrameRate", 25).Value, 25);
_updateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / targetFps};
_updateTrigger.Update += UpdateLeds;
_updateTrigger.Start();
}
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
@@ -69,6 +67,13 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
else
viewModel.Device = surfaceDeviceConfiguration;
}
// Sort the devices by ZIndex
Execute.OnUIThread(() =>
{
foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList())
Devices.Move(Devices.IndexOf(device), device.ZIndex - 1);
});
}
protected override void OnActivate()
@@ -13,8 +13,12 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
public ProfileLedViewModel(Led led)
{
Led = led;
X = Led.LedRectangle.X;
Y = Led.LedRectangle.Y;
Width = Led.LedRectangle.Width;
Height = Led.LedRectangle.Height;
Execute.OnUIThread(() => { CreateLedGeometry(); });
Execute.OnUIThread(CreateLedGeometry);
}
public Led Led { get; }
@@ -28,8 +32,6 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
public Geometry StrokeGeometry { get; private set; }
public Color DisplayColor { get; private set; }
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
private void CreateLedGeometry()
{
switch (Led.Shape)
@@ -103,18 +105,6 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
if (!DisplayColor.Equals(newColor))
DisplayColor = newColor;
});
if (Math.Abs(Led.LedRectangle.X - X) > 0.1)
X = Led.LedRectangle.X;
if (Math.Abs(Led.LedRectangle.Y - Y) > 0.1)
Y = Led.LedRectangle.Y;
if (Math.Abs(Led.LedRectangle.Width - Width) > 0.1)
Width = Led.LedRectangle.Width;
if (Math.Abs(Led.LedRectangle.Height - Height) > 0.1)
Height = Led.LedRectangle.Height;
}
}
}