mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Devices - Added option to disable devices
This commit is contained in:
1 parent
25dcb16964
commit
bd6c93b292
14 files changed
+118
-52
No files matched your search
@@ -5,43 +5,51 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.About"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:AboutTabViewModel}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel Margin="15" MaxWidth="800">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline2TextBlock}">
|
||||
Artemis 2
|
||||
</TextBlock>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<shared:ArtemisIcon SvgSource="/Resources/Images/Logo/bow.svg" Width="60" Height="80" Margin="0 0 20 0" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline2TextBlock}">
|
||||
Artemis 2
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" Foreground="{DynamicResource MaterialDesignBodyLight}" Text="{Binding Version}" />
|
||||
|
||||
<materialDesign:Card Margin="0 25 0 0">
|
||||
<StackPanel Margin="15">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
|
||||
Lead developer
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
Spoinky (Robert Beekman)
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Account" Width="60" Height="40" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
|
||||
Lead developer
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Margin="10 0 0 0">
|
||||
- Spoinky (Robert Beekman)
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}" Margin="0 25 0 0">
|
||||
Main contributors
|
||||
<StackPanel Orientation="Horizontal" Margin="0 25 0 0">
|
||||
<materialDesign:PackIcon Kind="AccountGroup" Width="60" Height="40" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
|
||||
Main contributors
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" LineHeight="25" Margin="10 0 0 0">
|
||||
- DarthAffe <LineBreak />
|
||||
- DrMeteor (Diogo Trindade)
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
DarthAffe
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
DrMeteor (Diogo Trindade)
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}" Margin="0 25 0 0">
|
||||
Special thanks
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
All the people on Discord provinding feedback and testing
|
||||
</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
|
||||
Aureshion - Default device images
|
||||
<StackPanel Orientation="Horizontal" Margin="0 25 0 0">
|
||||
<materialDesign:PackIcon Kind="AccountHeart" Width="60" Height="40" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
|
||||
Special thanks
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" LineHeight="25" Margin="10 0 0 0">
|
||||
- All the people on Discord providing feedback and testing<LineBreak />
|
||||
- Aureshion - Default device images
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
@@ -10,7 +10,14 @@
|
||||
d:DataContext="{d:DesignInstance local:DeviceSettingsTabViewModel}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
|
||||
<TextBlock DockPanel.Dock="Top">Below you view and manage the devices that were detected by Artemis</TextBlock>
|
||||
<StackPanel DockPanel.Dock="Top">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">Device management</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">
|
||||
Below you view and manage the devices that were detected by Artemis. <LineBreak/>
|
||||
Disabling a device will cause it to stop updating. Some SDKs will even go back to using manufacturer lighting (Artemis restart may be required).
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<ItemsControl ItemsSource="{Binding Items}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
@@ -11,19 +12,22 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
{
|
||||
private readonly ISettingsVmFactory _settingsVmFactory;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly IDialogService _dialogService;
|
||||
private bool _confirmedDisable;
|
||||
|
||||
public DeviceSettingsTabViewModel(ISurfaceService surfaceService, ISettingsVmFactory settingsVmFactory)
|
||||
public DeviceSettingsTabViewModel(ISurfaceService surfaceService, IDialogService dialogService, ISettingsVmFactory settingsVmFactory)
|
||||
{
|
||||
DisplayName = "DEVICES";
|
||||
|
||||
_surfaceService = surfaceService;
|
||||
_dialogService = dialogService;
|
||||
_settingsVmFactory = settingsVmFactory;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
// Take it off the UI thread to avoid freezing on tab change
|
||||
Task.Run(async () =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
Items.Clear();
|
||||
await Task.Delay(200);
|
||||
@@ -35,5 +39,21 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
public async Task<bool> ShowDeviceDisableDialog()
|
||||
{
|
||||
if (_confirmedDisable)
|
||||
return true;
|
||||
|
||||
bool confirmed = await _dialogService.ShowConfirmDialog(
|
||||
"Disabling device",
|
||||
"Disabling a device will cause it to stop updating. " +
|
||||
"\r\nSome SDKs will even go back to using manufacturer lighting (Artemis restart may be required)."
|
||||
);
|
||||
if (confirmed)
|
||||
_confirmedDisable = true;
|
||||
|
||||
return confirmed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Grid.Row="0" Height="140" Width="196" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
<Rectangle Grid.Row="0" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
<shared:DeviceVisualizer Device="{Binding Device}" RenderOptions.BitmapScalingMode="HighQuality" Grid.Row="0" Height="130" Width="190" />
|
||||
<Button Grid.Row="0"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
@@ -56,26 +56,26 @@
|
||||
<StackPanel>
|
||||
<Button Command="{s:Action ShowDeviceDebugger}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Tools" Margin="0 0 10 0 " VerticalAlignment="Center"/>
|
||||
<materialDesign:PackIcon Kind="Tools" Margin="0 0 10 0 " VerticalAlignment="Center" />
|
||||
<TextBlock VerticalAlignment="Center">Show device debugger</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Command="{s:Action OpenPluginDirectory}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="FolderOpen" Margin="0 0 10 0 " VerticalAlignment="Center"/>
|
||||
<materialDesign:PackIcon Kind="FolderOpen" Margin="0 0 10 0 " VerticalAlignment="Center" />
|
||||
<TextBlock VerticalAlignment="Center">Open plugin directory</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Separator/>
|
||||
<Separator />
|
||||
<Button Command="{s:Action DetectInput}" ToolTip="Teach Artemis which keypresses and/or button presses belong to this device">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="GestureDoubleTap" Margin="0 0 10 0 " VerticalAlignment="Center"/>
|
||||
<materialDesign:PackIcon Kind="GestureDoubleTap" Margin="0 0 10 0 " VerticalAlignment="Center" />
|
||||
<TextBlock VerticalAlignment="Center">Identify input</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Command="{s:Action ViewProperties}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Gear" Margin="0 0 10 0 " VerticalAlignment="Center"/>
|
||||
<materialDesign:PackIcon Kind="Gear" Margin="0 0 10 0 " VerticalAlignment="Center" />
|
||||
<TextBlock VerticalAlignment="Center">View surface properties</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
@@ -14,14 +14,13 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
{
|
||||
public class DeviceSettingsViewModel : PropertyChangedBase
|
||||
public class DeviceSettingsViewModel : Screen
|
||||
{
|
||||
private readonly IDeviceDebugVmFactory _deviceDebugVmFactory;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private bool _isDeviceEnabled;
|
||||
|
||||
public DeviceSettingsViewModel(ArtemisDevice device,
|
||||
IDeviceService deviceService,
|
||||
@@ -40,9 +39,6 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
Type = Device.RgbDevice.DeviceInfo.DeviceType.ToString().Humanize();
|
||||
Name = Device.RgbDevice.DeviceInfo.Model;
|
||||
Manufacturer = Device.RgbDevice.DeviceInfo.Manufacturer;
|
||||
|
||||
// TODO: Implement this bad boy
|
||||
IsDeviceEnabled = true;
|
||||
}
|
||||
|
||||
public ArtemisDevice Device { get; }
|
||||
@@ -56,8 +52,27 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
|
||||
public bool IsDeviceEnabled
|
||||
{
|
||||
get => _isDeviceEnabled;
|
||||
set => SetAndNotify(ref _isDeviceEnabled, value);
|
||||
get => Device.IsEnabled;
|
||||
set
|
||||
{
|
||||
Task.Run(() => UpdateIsDeviceEnabled(value));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateIsDeviceEnabled(bool value)
|
||||
{
|
||||
if (!value)
|
||||
value = !await ((DeviceSettingsTabViewModel)Parent).ShowDeviceDisableDialog();
|
||||
|
||||
Device.IsEnabled = value;
|
||||
NotifyOfPropertyChange(nameof(IsDeviceEnabled));
|
||||
SaveDevice();
|
||||
}
|
||||
|
||||
private void SaveDevice()
|
||||
{
|
||||
_surfaceService.UpdateSurfaceConfiguration(_surfaceService.ActiveSurface, true);
|
||||
}
|
||||
|
||||
public void IdentifyDevice()
|
||||
@@ -85,10 +100,10 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
public async Task DetectInput()
|
||||
{
|
||||
object madeChanges = await _dialogService.ShowDialog<SurfaceDeviceDetectInputViewModel>(
|
||||
new Dictionary<string, object> { { "device", Device } }
|
||||
new Dictionary<string, object> {{"device", Device}}
|
||||
);
|
||||
|
||||
if ((bool)madeChanges)
|
||||
if ((bool) madeChanges)
|
||||
_surfaceService.UpdateSurfaceConfiguration(_surfaceService.ActiveSurface, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="0 15 0 0">Module priority</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Style="{StaticResource MaterialDesignTextBlock}">
|
||||
Drag and drop the modules below to change their rendering priority. <LineBreak /><LineBreak />
|
||||
- Like in the profile editor, the modules at the top render over modules at the bottom <LineBreak />
|
||||
|
||||
Reference in new issue
Block a user