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

Fix device ZIndex application

This commit is contained in:
SpoinkyNL 2019-11-13 22:52:24 +01:00
parent 6a5304c3e3
commit 1a98ef62d3
7 changed files with 49 additions and 40 deletions

View File

@ -114,5 +114,10 @@ namespace Artemis.Core.Models.Surface
RgbDevice = null;
Surface = null;
}
public override string ToString()
{
return $"[{RgbDevice.DeviceInfo.DeviceType}] {RgbDevice.DeviceInfo.DeviceName} - {X}.{Y}.{ZIndex}";
}
}
}

View File

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

View File

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

View File

@ -4,18 +4,23 @@ using Stylet;
namespace Artemis.UI.ViewModels.Screens
{
public class ModuleRootViewModel : Screen
public class ModuleRootViewModel : Conductor<ModuleViewModel>.Collection.OneActive
{
public ModuleRootViewModel(Module module, IProfileEditorViewModelFactory profileEditorViewModelFactory)
{
Module = module;
ModuleViewModels = new BindableCollection<ModuleViewModel> {profileEditorViewModelFactory.CreateModuleViewModel(Module)};
ModuleViewModels.AddRange(Module.GetViewModels());
// Add the profile editor and module VMs
var profileEditor = profileEditorViewModelFactory.CreateModuleViewModel(Module);
Items.Add(profileEditor);
Items.AddRange(Module.GetViewModels());
// Activate the profile editor
ActiveItem = profileEditor;
}
public Module Module { get; }
public BindableCollection<ModuleViewModel> ModuleViewModels { get; set; }
public int FixedHeaderCount => ModuleViewModels.Count;
public int FixedHeaderCount => Items.Count;
}
}

View File

@ -101,6 +101,13 @@ namespace Artemis.UI.ViewModels.Screens
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);
});
_surfaceService.SetActiveSurfaceConfiguration(SelectedSurface);
}

View File

@ -10,8 +10,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance screens:ModuleRootViewModel}">
<dragablz:TabablzControl Margin="0 -1 0 0" FixedHeaderCount="{Binding FixedHeaderCount}"
ItemsSource="{Binding ModuleViewModels}">
<dragablz:TabablzControl Margin="0 -1 0 0" ItemsSource="{Binding Items}" SelectedItem="{Binding ActiveItem}" FixedHeaderCount="{Binding FixedHeaderCount}">
<dragablz:TabablzControl.HeaderItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
@ -19,7 +18,7 @@
</dragablz:TabablzControl.HeaderItemTemplate>
<dragablz:TabablzControl.ContentTemplate>
<DataTemplate>
<ContentControl s:View.Model="{Binding}" />
<ContentControl s:View.Model="{Binding}" IsTabStop="False"/>
</DataTemplate>
</dragablz:TabablzControl.ContentTemplate>
</dragablz:TabablzControl>

View File

@ -22,8 +22,9 @@
</UserControl.Resources>
<Grid Margin="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="300" />
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="300" MinWidth="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -175,27 +176,24 @@
</StackPanel>
</Grid>
</materialDesign:Card>
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="2" Grid.Column="1"
<GridSplitter Grid.Column="1" Grid.Row="2" Width="5" HorizontalAlignment="Stretch" />
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="2" Grid.Column="2"
VerticalAlignment="Stretch" Margin="5,0,0,0">
<materialDesign:DialogHost Identifier="SurfaceListDialogHost" CloseOnClickAway="True"
UseLayoutRounding="True">
<Grid>
<materialDesign:DialogHost Identifier="SurfaceListDialogHost" CloseOnClickAway="True" UseLayoutRounding="True">
<Grid HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0" ItemsSource="{Binding SurfaceConfigurations}"
SelectedItem="{Binding SelectedSurface}">
<ListBox Grid.Row="0" HorizontalContentAlignment="Stretch" ItemsSource="{Binding SurfaceConfigurations}" SelectedItem="{Binding SelectedSurface}">
<ListBox.Resources>
<DataTemplate DataType="{x:Type models:Surface}">
<Grid HorizontalAlignment="Stretch">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="230" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" ToolTip="{Binding Name}"
HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBlock Text="{Binding Name}" ToolTip="{Binding Name}" HorizontalAlignment="Left" VerticalAlignment="Center" />
<Button Grid.Column="1"
Command="{s:Action DeleteSurfaceConfiguration}"
CommandParameter="{Binding}"