mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Added device identification to surface editor
Fixed dialog rendering Cleaned up XAML
This commit is contained in:
1 parent
733c9bf1a5
commit
25f8f1e72f
24 files changed
+165
-79
No files matched your search
@@ -6,14 +6,16 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="213.053" d:DesignWidth="254.425">
|
||||
<StackPanel Margin="16" UseLayoutRounding="True">
|
||||
<TextBlock>
|
||||
d:DesignHeight="213.053" d:DesignWidth="254.425" >
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Style="{StaticResource MaterialDesignTitleTextBlock}">
|
||||
Add a new surface layout
|
||||
</TextBlock>
|
||||
|
||||
<TextBox materialDesign:HintAssist.Hint="Layout name" Margin="0 8 0 16"
|
||||
Style="{StaticResource MaterialDesignFloatingHintTextBox}" Text="{Binding SurfaceName}" />
|
||||
<TextBox materialDesign:HintAssist.Hint="Layout name"
|
||||
Margin="0 8 0 16"
|
||||
Style="{StaticResource MaterialDesignFloatingHintTextBox}"
|
||||
Text="{Binding SurfaceName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="351.305" d:DesignWidth="262.163"
|
||||
d:DataContext="{d:DesignInstance {x:Type surfaceEditor:SurfaceDeviceConfigViewModel}}">
|
||||
<StackPanel Margin="16" UseLayoutRounding="True">
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource MaterialDesignTitleTextBlock}" />
|
||||
|
||||
<Label>X-coordinate</Label>
|
||||
|
||||
@@ -111,6 +111,12 @@
|
||||
<ContentControl s:View.Model="{Binding}">
|
||||
<ContentControl.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Identify" Command="{s:Action IdentifyDevice}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="AlarmLight" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Bring to Front" Command="{s:Action BringToFront}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="ArrangeBringToFront" />
|
||||
|
||||
@@ -23,9 +23,10 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
|
||||
public SurfaceEditorViewModel(ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService)
|
||||
public SurfaceEditorViewModel(ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService, IDeviceService deviceService)
|
||||
{
|
||||
Devices = new ObservableCollection<SurfaceDeviceViewModel>();
|
||||
SurfaceConfigurations = new ObservableCollection<Surface>();
|
||||
@@ -36,6 +37,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
_surfaceService = surfaceService;
|
||||
_dialogService = dialogService;
|
||||
_settingsService = settingsService;
|
||||
_deviceService = deviceService;
|
||||
}
|
||||
|
||||
public ObservableCollection<SurfaceDeviceViewModel> Devices { get; set; }
|
||||
@@ -60,7 +62,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
public Surface CreateSurfaceConfiguration(string name)
|
||||
{
|
||||
var config = _surfaceService.CreateSurfaceConfiguration(name);
|
||||
Execute.OnUIThread(() => SurfaceConfigurations.Add(config));
|
||||
Execute.PostToUIThread(() => SurfaceConfigurations.Add(config));
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
_surfaceService.SetActiveSurfaceConfiguration(activeConfig);
|
||||
}
|
||||
|
||||
Execute.OnUIThread(() =>
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
// Populate the UI collection
|
||||
SurfaceConfigurations.Clear();
|
||||
@@ -104,7 +106,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
{
|
||||
if (SelectedSurface == null)
|
||||
{
|
||||
Execute.OnUIThread(Devices.Clear);
|
||||
Execute.PostToUIThread(Devices.Clear);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,14 +116,14 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
// Create VMs for missing devices
|
||||
var viewModel = Devices.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice);
|
||||
if (viewModel == null)
|
||||
Execute.OnUIThread(() => Devices.Add(new SurfaceDeviceViewModel(surfaceDeviceConfiguration)));
|
||||
Execute.PostToUIThread(() => Devices.Add(new SurfaceDeviceViewModel(surfaceDeviceConfiguration)));
|
||||
// Update existing devices
|
||||
else
|
||||
viewModel.Device = surfaceDeviceConfiguration;
|
||||
}
|
||||
|
||||
// Sort the devices by ZIndex
|
||||
Execute.OnUIThread(() =>
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
foreach (var device in Devices.OrderBy(d => d.Device.ZIndex).ToList())
|
||||
Devices.Move(Devices.IndexOf(device), device.Device.ZIndex - 1);
|
||||
@@ -174,6 +176,11 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
|
||||
#region Context menu actions
|
||||
|
||||
public void IdentifyDevice(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
_deviceService.IdentifyDevice(surfaceDeviceViewModel.Device);
|
||||
}
|
||||
|
||||
public void BringToFront(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
Devices.Move(Devices.IndexOf(surfaceDeviceViewModel), Devices.Count - 1);
|
||||
|
||||
Reference in new issue
Block a user