mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Added active surface-config management code
Added surface-config creation
This commit is contained in:
1 parent
10b2328561
commit
e26516bce0
15 files changed
+268
-140
No files matched your search
@@ -75,14 +75,14 @@
|
||||
<Reference Include="MahApps.Metro, Version=1.6.5.1, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.6.5\lib\net47\MahApps.Metro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MaterialDesignColors, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll</HintPath>
|
||||
<Reference Include="MaterialDesignColors, Version=1.2.0.325, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignColors.1.2.0\lib\net45\MaterialDesignColors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MaterialDesignThemes.MahApps, Version=0.0.10.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignThemes.MahApps.0.0.12\lib\net45\MaterialDesignThemes.MahApps.dll</HintPath>
|
||||
<Reference Include="MaterialDesignThemes.MahApps, Version=0.1.0.325, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignThemes.MahApps.0.1.0\lib\net45\MaterialDesignThemes.MahApps.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MaterialDesignThemes.Wpf, Version=2.5.1.1345, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignThemes.2.5.1\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
|
||||
<Reference Include="MaterialDesignThemes.Wpf, Version=2.6.0.325, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MaterialDesignThemes.2.6.0\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Sqlite, Version=2.2.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Data.Sqlite.Core.2.2.4\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
||||
@@ -119,8 +119,8 @@
|
||||
<Reference Include="SQLitePCLRaw.provider.e_sqlite3, Version=1.1.12.351, Culture=neutral, PublicKeyToken=9c301db686d0bd12, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SQLitePCLRaw.provider.e_sqlite3.net45.1.1.12\lib\net45\SQLitePCLRaw.provider.e_sqlite3.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Stylet, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Stylet.1.2.0\lib\net45\Stylet.dll</HintPath>
|
||||
<Reference Include="Stylet, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Stylet.1.3.0\lib\net45\Stylet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
public SettingsViewModel(IRgbService rgbService)
|
||||
{
|
||||
DeviceSettingsViewModels = new BindableCollection<RgbDeviceSettingsViewModel>();
|
||||
foreach (var device in rgbService.Surface.Devices)
|
||||
foreach (var device in rgbService.LoadedDevices)
|
||||
DeviceSettingsViewModels.Add(new RgbDeviceSettingsViewModel(device));
|
||||
|
||||
rgbService.DeviceLoaded += UpdateDevices;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
_surfaceService = surfaceService;
|
||||
_rgbService.DeviceLoaded += RgbServiceOnDeviceLoaded;
|
||||
|
||||
foreach (var surfaceDevice in _rgbService.Surface.Devices)
|
||||
foreach (var surfaceDevice in _rgbService.LoadedDevices)
|
||||
{
|
||||
var device = new SurfaceDeviceViewModel(surfaceDevice) {Cursor = Cursors.Hand};
|
||||
Devices.Add(device);
|
||||
@@ -62,15 +62,16 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
|
||||
private async Task LoadSurfaceConfigurations()
|
||||
{
|
||||
Execute.OnUIThread(async () =>
|
||||
await Execute.OnUIThreadAsync(async () =>
|
||||
{
|
||||
SurfaceConfigurations.Clear();
|
||||
|
||||
// Get surface configs
|
||||
var configs = await _surfaceService.GetSurfaceConfigurations();
|
||||
var configs = await _surfaceService.GetSurfaceConfigurationsAsync();
|
||||
// Populate the UI collection
|
||||
foreach (var surfaceConfiguration in configs)
|
||||
SurfaceConfigurations.Add(surfaceConfiguration);
|
||||
|
||||
// Select either the first active surface or the first available surface
|
||||
SelectedSurfaceConfiguration = SurfaceConfigurations.FirstOrDefault(s => s.IsActive) ?? SurfaceConfigurations.FirstOrDefault();
|
||||
|
||||
@@ -82,12 +83,12 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
|
||||
public SurfaceConfiguration AddSurfaceConfiguration(string name)
|
||||
{
|
||||
var config = new SurfaceConfiguration(name);
|
||||
var config = _surfaceService.CreateSurfaceConfiguration(name);
|
||||
Execute.OnUIThread(() => SurfaceConfigurations.Add(config));
|
||||
return config;
|
||||
}
|
||||
|
||||
public void ConfigurationDialogClosing()
|
||||
public void ConfirmationDialogClosing()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(NewConfigurationName))
|
||||
{
|
||||
@@ -102,22 +103,56 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
|
||||
public void BringToFront(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
Console.WriteLine("Bring to front");
|
||||
var original = surfaceDeviceViewModel.ZIndex;
|
||||
surfaceDeviceViewModel.ZIndex = Devices.Count;
|
||||
foreach (var deviceViewModel in Devices)
|
||||
{
|
||||
if (deviceViewModel.ZIndex >= original && deviceViewModel != surfaceDeviceViewModel)
|
||||
deviceViewModel.ZIndex--;
|
||||
}
|
||||
|
||||
foreach (var deviceViewModel in Devices)
|
||||
Console.WriteLine(deviceViewModel.ZIndex);
|
||||
}
|
||||
|
||||
public void BringForward(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
surfaceDeviceViewModel.ZIndex++;
|
||||
var newIndex = Math.Max(Devices.Count, surfaceDeviceViewModel.ZIndex + 1);
|
||||
var neighbor = Devices.FirstOrDefault(d => d.ZIndex == newIndex);
|
||||
if (neighbor != null)
|
||||
neighbor.ZIndex--;
|
||||
|
||||
surfaceDeviceViewModel.ZIndex = newIndex;
|
||||
|
||||
foreach (var deviceViewModel in Devices)
|
||||
Console.WriteLine(deviceViewModel.ZIndex);
|
||||
}
|
||||
|
||||
public void SendToBack(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
Console.WriteLine("Send to back");
|
||||
var original = surfaceDeviceViewModel.ZIndex;
|
||||
surfaceDeviceViewModel.ZIndex = 1;
|
||||
foreach (var deviceViewModel in Devices)
|
||||
{
|
||||
if (deviceViewModel.ZIndex <= original && deviceViewModel != surfaceDeviceViewModel)
|
||||
deviceViewModel.ZIndex++;
|
||||
}
|
||||
|
||||
foreach (var deviceViewModel in Devices)
|
||||
Console.WriteLine(deviceViewModel.ZIndex);
|
||||
}
|
||||
|
||||
public void SendBackward(SurfaceDeviceViewModel surfaceDeviceViewModel)
|
||||
{
|
||||
surfaceDeviceViewModel.ZIndex--;
|
||||
var newIndex = Math.Max(0, surfaceDeviceViewModel.ZIndex - 1);
|
||||
var neighbor = Devices.FirstOrDefault(d => d.ZIndex == newIndex);
|
||||
if (neighbor != null)
|
||||
neighbor.ZIndex++;
|
||||
|
||||
surfaceDeviceViewModel.ZIndex = newIndex;
|
||||
|
||||
foreach (var deviceViewModel in Devices)
|
||||
Console.WriteLine(deviceViewModel.ZIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -148,66 +148,39 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</materialDesign:DialogHost.DialogContent>
|
||||
<materialDesign:DialogHost DialogClosing="{s:Action ConfigurationDialogClosing}">
|
||||
<materialDesign:DialogHost.DialogContent>
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock>
|
||||
Add a new surface layout.
|
||||
</TextBlock>
|
||||
<TextBox Margin="0 8 0 0" HorizontalAlignment="Stretch" Text="{Binding NewConfigurationName}" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="materialDesign:DialogHost.CloseDialogCommand">
|
||||
<Button.CommandParameter>
|
||||
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
True
|
||||
</system:Boolean>
|
||||
</Button.CommandParameter>
|
||||
ACCEPT
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="materialDesign:DialogHost.CloseDialogCommand">
|
||||
<Button.CommandParameter>
|
||||
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
False
|
||||
</system:Boolean>
|
||||
</Button.CommandParameter>
|
||||
CANCEL
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox Grid.Row="0" ItemsSource="{Binding SurfaceConfigurations}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type models:SurfaceConfiguration}">
|
||||
<TextBlock Text="{Binding Name}" ToolTip="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
</ListBox>
|
||||
<materialDesign:PopupBox
|
||||
PopupMode="Click"
|
||||
Grid.Row="0"
|
||||
Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
|
||||
PlacementMode="LeftAndAlignMiddles"
|
||||
UnfurlOrientation="Horizontal"
|
||||
ToolTip="Manage surface layouts"
|
||||
Margin="0 0 10 10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom">
|
||||
<StackPanel
|
||||
Orientation="Horizontal">
|
||||
<Button ToolTip="Add a new surface layout" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
|
||||
<materialDesign:PackIcon Kind="Add" />
|
||||
</Button>
|
||||
<Button ToolTip="Remove selected surface layout" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
|
||||
<materialDesign:PackIcon Kind="Delete" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</materialDesign:DialogHost.DialogContent>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox Grid.Row="0" ItemsSource="{Binding SurfaceConfigurations}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type models:SurfaceConfiguration}">
|
||||
<TextBlock Text="{Binding Name}" ToolTip="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ListBox.Resources>
|
||||
</ListBox>
|
||||
<materialDesign:PopupBox
|
||||
Grid.Row="0"
|
||||
Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
|
||||
PlacementMode="LeftAndAlignMiddles"
|
||||
UnfurlOrientation="Horizontal"
|
||||
ToolTip="Manage surface layouts"
|
||||
Margin="0 0 10 10"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom">
|
||||
<StackPanel
|
||||
Orientation="Horizontal">
|
||||
<Button ToolTip="Add a new surface layout" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
|
||||
<materialDesign:PackIcon Kind="Add" />
|
||||
</Button>
|
||||
<Button ToolTip="Remove selected surface layout" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
|
||||
<materialDesign:PackIcon Kind="Delete" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</materialDesign:PopupBox>
|
||||
</Grid>
|
||||
</materialDesign:DialogHost>
|
||||
</materialDesign:PopupBox>
|
||||
</Grid>
|
||||
</materialDesign:DialogHost>
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<package id="Fody" version="5.0.6" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="Humanizer.Core" version="2.6.2" targetFramework="net461" />
|
||||
<package id="MahApps.Metro" version="1.6.5" targetFramework="net472" />
|
||||
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net461" />
|
||||
<package id="MaterialDesignThemes" version="2.5.1" targetFramework="net461" />
|
||||
<package id="MaterialDesignThemes.MahApps" version="0.0.12" targetFramework="net461" />
|
||||
<package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" />
|
||||
<package id="MaterialDesignThemes" version="2.6.0" targetFramework="net472" />
|
||||
<package id="MaterialDesignThemes.MahApps" version="0.1.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Data.Sqlite" version="2.2.4" targetFramework="net472" />
|
||||
<package id="Microsoft.Data.Sqlite.Core" version="2.2.4" targetFramework="net472" />
|
||||
<package id="Ninject" version="3.3.4" targetFramework="net461" />
|
||||
@@ -20,6 +20,6 @@
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.osx" version="1.1.12" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.lib.e_sqlite3.v110_xp" version="1.1.12" targetFramework="net472" />
|
||||
<package id="SQLitePCLRaw.provider.e_sqlite3.net45" version="1.1.12" targetFramework="net472" />
|
||||
<package id="Stylet" version="1.2.0" targetFramework="net472" />
|
||||
<package id="Stylet" version="1.3.0" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
||||
Reference in new issue
Block a user