mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 13:28:33 +00:00
Removed Device info and properties tabs
This commit is contained in:
parent
db069ea8bf
commit
af03f291d3
@ -40,9 +40,7 @@ public interface IDeviceVmFactory : IVmFactory
|
||||
DevicePropertiesViewModel DevicePropertiesViewModel(ArtemisDevice device);
|
||||
DeviceSettingsViewModel DeviceSettingsViewModel(ArtemisDevice device, DevicesTabViewModel devicesTabViewModel);
|
||||
DeviceDetectInputViewModel DeviceDetectInputViewModel(ArtemisDevice device);
|
||||
DevicePropertiesTabViewModel DevicePropertiesTabViewModel(ArtemisDevice device);
|
||||
DeviceLayoutTabViewModel DeviceLayoutTabViewModel(ArtemisDevice device);
|
||||
DeviceInfoTabViewModel DeviceInfoTabViewModel(ArtemisDevice device);
|
||||
DeviceLedsTabViewModel DeviceLedsTabViewModel(ArtemisDevice device, ObservableCollection<ArtemisLed> selectedLeds);
|
||||
InputMappingsTabViewModel InputMappingsTabViewModel(ArtemisDevice device, ObservableCollection<ArtemisLed> selectedLeds);
|
||||
DeviceGeneralTabViewModel DeviceGeneralTabViewModel(ArtemisDevice device);
|
||||
@ -71,21 +69,11 @@ public class DeviceFactory : IDeviceVmFactory
|
||||
return _container.Resolve<DeviceDetectInputViewModel>(new object[] { device });
|
||||
}
|
||||
|
||||
public DevicePropertiesTabViewModel DevicePropertiesTabViewModel(ArtemisDevice device)
|
||||
{
|
||||
return _container.Resolve<DevicePropertiesTabViewModel>(new object[] { device });
|
||||
}
|
||||
|
||||
public DeviceLayoutTabViewModel DeviceLayoutTabViewModel(ArtemisDevice device)
|
||||
{
|
||||
return _container.Resolve<DeviceLayoutTabViewModel>(new object[] { device });
|
||||
}
|
||||
|
||||
public DeviceInfoTabViewModel DeviceInfoTabViewModel(ArtemisDevice device)
|
||||
{
|
||||
return _container.Resolve<DeviceInfoTabViewModel>(new object[] { device });
|
||||
}
|
||||
|
||||
public DeviceLedsTabViewModel DeviceLedsTabViewModel(ArtemisDevice device, ObservableCollection<ArtemisLed> selectedLeds)
|
||||
{
|
||||
return _container.Resolve<DeviceLedsTabViewModel>(new object[] { device, selectedLeds });
|
||||
|
||||
@ -66,8 +66,6 @@ public class DevicePropertiesViewModel : DialogViewModelBase<object>
|
||||
{
|
||||
Tabs.Add(_deviceVmFactory.DeviceGeneralTabViewModel(Device));
|
||||
Tabs.Add(_deviceVmFactory.DeviceLayoutTabViewModel(Device));
|
||||
//Tabs.Add(_deviceVmFactory.DevicePropertiesTabViewModel(Device));
|
||||
//Tabs.Add(_deviceVmFactory.DeviceInfoTabViewModel(Device));
|
||||
if (Device.DeviceType == RGBDeviceType.Keyboard)
|
||||
Tabs.Add(_deviceVmFactory.InputMappingsTabViewModel(Device, SelectedLeds));
|
||||
Tabs.Add(_deviceVmFactory.DeviceLedsTabViewModel(Device, SelectedLeds));
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:device="clr-namespace:Artemis.UI.Screens.Device"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Device.DeviceInfoTabView"
|
||||
x:DataType="device:DeviceInfoTabViewModel">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<Grid RowDefinitions="Auto,*" ColumnDefinitions="*,*" Margin="-5">
|
||||
<!-- First row -->
|
||||
<Border Classes="card" Grid.Column="0" Grid.Row="0" Margin="5">
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<TextBlock FontWeight="Bold">Device name</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.RgbDevice.DeviceInfo.DeviceName}" />
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<TextBlock FontWeight="Bold">Manufacturer</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.RgbDevice.DeviceInfo.Manufacturer}" />
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
|
||||
<TextBlock FontWeight="Bold">Device type</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.DeviceType}" />
|
||||
<Border Classes="card-separator" IsVisible="{CompiledBinding IsKeyboard}" />
|
||||
|
||||
<StackPanel IsVisible="{CompiledBinding IsKeyboard}">
|
||||
<TextBlock FontWeight="Bold">Physical layout</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.PhysicalLayout}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Classes="card" Grid.Row="0" Grid.Column="1" Margin="5">
|
||||
<StackPanel VerticalAlignment="Top">
|
||||
<TextBlock FontWeight="Bold">Size (1px = 1mm)</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.RgbDevice.Size}" />
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<TextBlock FontWeight="Bold">Location (1px = 1mm)</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.RgbDevice.Location}" />
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<TextBlock FontWeight="Bold">Rotation (degrees)</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.RgbDevice.Rotation.Degrees}" />
|
||||
<Border Classes="card-separator" IsVisible="{CompiledBinding IsKeyboard}" />
|
||||
|
||||
<StackPanel IsVisible="{CompiledBinding IsKeyboard}">
|
||||
<TextBlock FontWeight="Bold">Logical layout</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.LogicalLayout}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Second row -->
|
||||
<Border Classes="card" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="5">
|
||||
<StackPanel>
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock FontWeight="Bold">Default layout file path</TextBlock>
|
||||
<Button Grid.Column="1"
|
||||
Classes="icon-button"
|
||||
ToolTip.Tip="Copy path to clipboard"
|
||||
Click="LayoutPathButton_OnClick">
|
||||
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
|
||||
</Button>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
TextWrapping="Wrap"
|
||||
Text="{CompiledBinding DefaultLayoutPath}" />
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock FontWeight="Bold">Image file path</TextBlock>
|
||||
<Button Grid.Column="1"
|
||||
Classes="icon-button"
|
||||
ToolTip.Tip="Copy path to clipboard"
|
||||
Click="ImagePathButton_OnClick">
|
||||
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
|
||||
</Button>
|
||||
</Grid>
|
||||
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding Device.Layout.Image.LocalPath}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
</UserControl>
|
||||
@ -1,24 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Device;
|
||||
|
||||
public partial class DeviceInfoTabView : ReactiveUserControl<DeviceInfoTabViewModel>
|
||||
{
|
||||
public DeviceInfoTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LayoutPathButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
TopLevel.GetTopLevel(this).Clipboard.SetTextAsync(ViewModel.DefaultLayoutPath);
|
||||
}
|
||||
|
||||
private void ImagePathButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
TopLevel.GetTopLevel(this).Clipboard.SetTextAsync(ViewModel.Device.Layout.Image.LocalPath);
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.UI.Screens.Device;
|
||||
|
||||
public class DeviceInfoTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
public DeviceInfoTabViewModel(ArtemisDevice device, INotificationService notificationService)
|
||||
{
|
||||
_notificationService = notificationService;
|
||||
|
||||
Device = device;
|
||||
DisplayName = "Info";
|
||||
|
||||
DefaultLayoutPath = Device.DeviceProvider.LoadLayout(Device).FilePath;
|
||||
}
|
||||
|
||||
public bool IsKeyboard => Device.DeviceType == RGBDeviceType.Keyboard;
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
public string DefaultLayoutPath { get; }
|
||||
}
|
||||
@ -1,204 +0,0 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:device="clr-namespace:Artemis.UI.Screens.Device"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="1200"
|
||||
x:Class="Artemis.UI.Screens.Device.DevicePropertiesTabView"
|
||||
x:DataType="device:DevicePropertiesTabViewModel">
|
||||
<UserControl.Resources>
|
||||
<converters:SKColorToColorConverter x:Key="SKColorToColorConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<!-- Body -->
|
||||
<Grid RowDefinitions="*,Auto">
|
||||
<StackPanel Grid.Row="0">
|
||||
<!-- Layout -->
|
||||
<TextBlock Classes="h4">
|
||||
Categories
|
||||
</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
Artemis uses categories to determine where the layers of imported profiles are applied to.
|
||||
</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
You can hover over a category for a more detailed description.
|
||||
</TextBlock>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{CompiledBinding HasDeskCategory}"
|
||||
ToolTip.Tip="A device acting as desk ornamentation such as a LED strip"
|
||||
Content="Desk" />
|
||||
<CheckBox IsChecked="{CompiledBinding HasMonitorCategory}"
|
||||
ToolTip.Tip="A device attached to the monitor such as ambilight LEDs"
|
||||
Content="Monitor" />
|
||||
<CheckBox ToolTip.Tip="A device inside your computer case"
|
||||
IsChecked="{CompiledBinding HasCaseCategory}"
|
||||
Content="Case" />
|
||||
<CheckBox IsChecked="{CompiledBinding HasRoomCategory}"
|
||||
ToolTip.Tip="A device elsewhere in the room"
|
||||
Content="Room" />
|
||||
<CheckBox IsChecked="{CompiledBinding HasPeripheralsCategory}"
|
||||
ToolTip.Tip="A peripheral such as a mouse or keyboard"
|
||||
Content="Peripheral" />
|
||||
</StackPanel>
|
||||
|
||||
<Grid Margin="0 25" ColumnDefinitions="*,40,*">
|
||||
<Grid Grid.Column="0" ColumnDefinitions="*,Auto,Auto" RowDefinitions="*,*,*,*,*">
|
||||
<TextBlock Grid.Row="0" Grid.ColumnSpan="3" Classes="h4">
|
||||
Surface properties
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">X-coordinate</TextBlock>
|
||||
<NumericUpDown Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="10 0"
|
||||
VerticalAlignment="Center"
|
||||
Value="{CompiledBinding X}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" VerticalAlignment="Center">mm</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">Y-coordinate</TextBlock>
|
||||
<NumericUpDown Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Margin="10 0"
|
||||
VerticalAlignment="Center"
|
||||
Value="{CompiledBinding Y}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="2" VerticalAlignment="Center">mm</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center">Scale</TextBlock>
|
||||
<NumericUpDown Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Margin="10 0"
|
||||
VerticalAlignment="Center"
|
||||
Increment="0.1"
|
||||
FormatString="F1"
|
||||
Value="{CompiledBinding Scale}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="2" VerticalAlignment="Center">times</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Rotation</TextBlock>
|
||||
<NumericUpDown Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Margin="10 0"
|
||||
VerticalAlignment="Center"
|
||||
Value="{CompiledBinding Rotation}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="2" VerticalAlignment="Center">deg</TextBlock>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Rectangle Grid.Column="1" VerticalAlignment="Stretch" Width="1" Fill="{DynamicResource ButtonBorderBrush}" Margin="0 0 0 5" />
|
||||
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock Classes="h4">
|
||||
Color calibration
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
Use the sliders below to adjust the colors of your device so that it matches your other devices.
|
||||
</TextBlock>
|
||||
|
||||
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="*,*,*,*">
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="R" VerticalAlignment="Center" />
|
||||
<Slider Grid.Row="0" Grid.Column="1" Minimum="0" Maximum="200" Value="{CompiledBinding RedScale}" Margin="10 0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Width="65"
|
||||
Value="{CompiledBinding RedScale}"
|
||||
ShowButtonSpinner="False"
|
||||
FormatString="{}{0:0.0}"
|
||||
Minimum="0"
|
||||
Maximum="200"
|
||||
ClipValueToMinMax="True" />
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="G" VerticalAlignment="Center" />
|
||||
<Slider Grid.Row="1" Grid.Column="1" Minimum="0" Maximum="200" Value="{CompiledBinding GreenScale}" Margin="10 0" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Width="65"
|
||||
Value="{CompiledBinding GreenScale}"
|
||||
ShowButtonSpinner="False"
|
||||
FormatString="{}{0:0.0}"
|
||||
Minimum="0"
|
||||
Maximum="200"
|
||||
ClipValueToMinMax="True" />
|
||||
|
||||
<Label Grid.Row="2" Grid.Column="0" Content="B" VerticalAlignment="Center" />
|
||||
<Slider Grid.Row="2" Grid.Column="1" Minimum="0" Maximum="200" Value="{CompiledBinding BlueScale}" Margin="10 0" Ticks="100" VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Width="65"
|
||||
Value="{CompiledBinding BlueScale}"
|
||||
ShowButtonSpinner="False"
|
||||
FormatString="{}{0:0.0}"
|
||||
Minimum="0"
|
||||
Maximum="200"
|
||||
ClipValueToMinMax="True" />
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" IsChecked="{CompiledBinding DisplayOnDevices}" Content="Show preview" VerticalAlignment="Center" />
|
||||
<controls:ColorPickerButton Grid.Row="3"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Color="{CompiledBinding CurrentColor, Converter={StaticResource SKColorToColorConverter}}"
|
||||
ShowAcceptDismissButtons="False" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Layout -->
|
||||
<TextBlock Classes="h4">
|
||||
Layout
|
||||
</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
The device layout is used to determine the position of LEDs and to create the visual representation of the device you see on the left side of this window.
|
||||
</TextBlock>
|
||||
|
||||
<CheckBox Margin="0 0 0 5" IsChecked="{CompiledBinding Device.DisableDefaultLayout}">
|
||||
<CheckBox.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock>Don't load default layout</TextBlock>
|
||||
<avalonia:MaterialIcon Kind="HelpCircle"
|
||||
Margin="5 0"
|
||||
ToolTip.Tip="With this enabled Artemis will not load a layout for this device unless you specifically provide one." />
|
||||
</StackPanel>
|
||||
</CheckBox.Content>
|
||||
</CheckBox>
|
||||
|
||||
<Grid>
|
||||
<TextBox Text="{CompiledBinding Device.CustomLayoutPath}"
|
||||
Watermark="Custom layout path"
|
||||
UseFloatingWatermark="True"
|
||||
IsReadOnly="True"
|
||||
PointerReleased="InputElement_OnPointerReleased"
|
||||
Padding="10 5 36 6" />
|
||||
<Button Classes="AppBarButton" HorizontalAlignment="Right" Command="{CompiledBinding ClearCustomLayout}" Padding="6" Margin="5 0">
|
||||
<avalonia:MaterialIcon Kind="CloseCircle" />
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<controls:HyperlinkButton NavigateUri="https://wiki.artemis-rgb.com/en/guides/developer/layouts" Margin="0 20" HorizontalAlignment="Right">
|
||||
Learn more about layouts on the wiki
|
||||
</controls:HyperlinkButton>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Buttons -->
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,*">
|
||||
<Button Grid.Column="0"
|
||||
IsVisible="{CompiledBinding RequiresManualSetup}"
|
||||
Command="{CompiledBinding RestartSetup}"
|
||||
ToolTip.Tip="Restart device setup, allowing you to select a new physical and logical layout">
|
||||
Restart setup
|
||||
</Button>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button IsCancel="True" Command="{CompiledBinding Reset}" Margin="0 0 5 0">Reset</Button>
|
||||
<Button Classes="accent" IsDefault="True" Command="{CompiledBinding Apply}">Apply</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@ -1,19 +0,0 @@
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Device;
|
||||
|
||||
public partial class DevicePropertiesTabView : ReactiveUserControl<DevicePropertiesTabViewModel>
|
||||
{
|
||||
public DevicePropertiesTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
ViewModel?.BrowseCustomLayout();
|
||||
}
|
||||
}
|
||||
@ -1,279 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Screens.Device;
|
||||
|
||||
public class DevicePropertiesTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly List<DeviceCategory> _categories;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly float _initialBlueScale;
|
||||
private readonly float _initialGreenScale;
|
||||
private readonly float _initialRedScale;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly IWindowService _windowService;
|
||||
private float _blueScale;
|
||||
private SKColor _currentColor;
|
||||
private bool _displayOnDevices;
|
||||
private float _greenScale;
|
||||
private float _redScale;
|
||||
private int _rotation;
|
||||
private float _scale;
|
||||
private int _x;
|
||||
private int _y;
|
||||
|
||||
public DevicePropertiesTabViewModel(ArtemisDevice device, ICoreService coreService, IRgbService rgbService, IWindowService windowService, INotificationService notificationService)
|
||||
{
|
||||
_coreService = coreService;
|
||||
_rgbService = rgbService;
|
||||
_windowService = windowService;
|
||||
_notificationService = notificationService;
|
||||
_categories = new List<DeviceCategory>(device.Categories);
|
||||
|
||||
Device = device;
|
||||
DisplayName = "Properties";
|
||||
|
||||
X = (int) Device.X;
|
||||
Y = (int) Device.Y;
|
||||
Scale = Device.Scale;
|
||||
Rotation = (int) Device.Rotation;
|
||||
RedScale = Device.RedScale * 100f;
|
||||
GreenScale = Device.GreenScale * 100f;
|
||||
BlueScale = Device.BlueScale * 100f;
|
||||
CurrentColor = SKColors.White;
|
||||
|
||||
// We need to store the initial values to be able to restore them when the user clicks "Cancel"
|
||||
_initialRedScale = Device.RedScale;
|
||||
_initialGreenScale = Device.GreenScale;
|
||||
_initialBlueScale = Device.BlueScale;
|
||||
|
||||
this.WhenAnyValue(x => x.RedScale, x => x.GreenScale, x => x.BlueScale).Subscribe(_ => ApplyScaling());
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
Device.PropertyChanged += DeviceOnPropertyChanged;
|
||||
_coreService.FrameRendering += OnFrameRendering;
|
||||
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
_coreService.FrameRendering -= OnFrameRendering;
|
||||
Device.PropertyChanged -= DeviceOnPropertyChanged;
|
||||
}).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
public int X
|
||||
{
|
||||
get => _x;
|
||||
set => RaiseAndSetIfChanged(ref _x, value);
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get => _y;
|
||||
set => RaiseAndSetIfChanged(ref _y, value);
|
||||
}
|
||||
|
||||
public float Scale
|
||||
{
|
||||
get => _scale;
|
||||
set => RaiseAndSetIfChanged(ref _scale, value);
|
||||
}
|
||||
|
||||
public int Rotation
|
||||
{
|
||||
get => _rotation;
|
||||
set => RaiseAndSetIfChanged(ref _rotation, value);
|
||||
}
|
||||
|
||||
public float RedScale
|
||||
{
|
||||
get => _redScale;
|
||||
set => RaiseAndSetIfChanged(ref _redScale, value);
|
||||
}
|
||||
|
||||
public float GreenScale
|
||||
{
|
||||
get => _greenScale;
|
||||
set => RaiseAndSetIfChanged(ref _greenScale, value);
|
||||
}
|
||||
|
||||
public float BlueScale
|
||||
{
|
||||
get => _blueScale;
|
||||
set => RaiseAndSetIfChanged(ref _blueScale, value);
|
||||
}
|
||||
|
||||
public SKColor CurrentColor
|
||||
{
|
||||
get => _currentColor;
|
||||
set => RaiseAndSetIfChanged(ref _currentColor, value);
|
||||
}
|
||||
|
||||
public bool DisplayOnDevices
|
||||
{
|
||||
get => _displayOnDevices;
|
||||
set => RaiseAndSetIfChanged(ref _displayOnDevices, value);
|
||||
}
|
||||
|
||||
// This solution won't scale well but I don't expect there to be many more categories.
|
||||
// If for some reason there will be, dynamically creating a view model per category may be more appropriate
|
||||
public bool HasDeskCategory
|
||||
{
|
||||
get => GetCategory(DeviceCategory.Desk);
|
||||
set => SetCategory(DeviceCategory.Desk, value);
|
||||
}
|
||||
|
||||
public bool HasMonitorCategory
|
||||
{
|
||||
get => GetCategory(DeviceCategory.Monitor);
|
||||
set => SetCategory(DeviceCategory.Monitor, value);
|
||||
}
|
||||
|
||||
public bool HasCaseCategory
|
||||
{
|
||||
get => GetCategory(DeviceCategory.Case);
|
||||
set => SetCategory(DeviceCategory.Case, value);
|
||||
}
|
||||
|
||||
public bool HasRoomCategory
|
||||
{
|
||||
get => GetCategory(DeviceCategory.Room);
|
||||
set => SetCategory(DeviceCategory.Room, value);
|
||||
}
|
||||
|
||||
public bool HasPeripheralsCategory
|
||||
{
|
||||
get => GetCategory(DeviceCategory.Peripherals);
|
||||
set => SetCategory(DeviceCategory.Peripherals, value);
|
||||
}
|
||||
|
||||
public bool RequiresManualSetup => !Device.DeviceProvider.CanDetectPhysicalLayout || !Device.DeviceProvider.CanDetectLogicalLayout;
|
||||
|
||||
public void ApplyScaling()
|
||||
{
|
||||
Device.RedScale = RedScale / 100f;
|
||||
Device.GreenScale = GreenScale / 100f;
|
||||
Device.BlueScale = BlueScale / 100f;
|
||||
|
||||
_rgbService.FlushLeds = true;
|
||||
}
|
||||
|
||||
public void ClearCustomLayout()
|
||||
{
|
||||
Device.CustomLayoutPath = null;
|
||||
_notificationService.CreateNotification()
|
||||
.WithMessage("Cleared imported layout.")
|
||||
.WithSeverity(NotificationSeverity.Informational);
|
||||
}
|
||||
|
||||
public async Task BrowseCustomLayout()
|
||||
{
|
||||
string[]? files = await _windowService.CreateOpenFileDialog()
|
||||
.WithTitle("Select device layout file")
|
||||
.HavingFilter(f => f.WithName("Layout files").WithExtension("xml"))
|
||||
.ShowAsync();
|
||||
|
||||
if (files?.Length > 0)
|
||||
{
|
||||
Device.CustomLayoutPath = files[0];
|
||||
_notificationService.CreateNotification()
|
||||
.WithTitle("Imported layout")
|
||||
.WithMessage($"File loaded from {files[0]}")
|
||||
.WithSeverity(NotificationSeverity.Informational);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RestartSetup()
|
||||
{
|
||||
if (!RequiresManualSetup)
|
||||
return;
|
||||
if (!Device.DeviceProvider.CanDetectPhysicalLayout && !await DevicePhysicalLayoutDialogViewModel.SelectPhysicalLayout(_windowService, Device))
|
||||
return;
|
||||
if (!Device.DeviceProvider.CanDetectLogicalLayout && !await DeviceLogicalLayoutDialogViewModel.SelectLogicalLayout(_windowService, Device))
|
||||
return;
|
||||
|
||||
await Task.Delay(400);
|
||||
_rgbService.SaveDevice(Device);
|
||||
_rgbService.ApplyBestDeviceLayout(Device);
|
||||
}
|
||||
|
||||
public async Task Apply()
|
||||
{
|
||||
// TODO: Validation
|
||||
|
||||
_coreService.ProfileRenderingDisabled = true;
|
||||
await Task.Delay(100);
|
||||
|
||||
Device.X = X;
|
||||
Device.Y = Y;
|
||||
Device.Scale = Scale;
|
||||
Device.Rotation = Rotation;
|
||||
Device.RedScale = RedScale / 100f;
|
||||
Device.GreenScale = GreenScale / 100f;
|
||||
Device.BlueScale = BlueScale / 100f;
|
||||
Device.Categories.Clear();
|
||||
foreach (DeviceCategory deviceCategory in _categories)
|
||||
Device.Categories.Add(deviceCategory);
|
||||
|
||||
_rgbService.SaveDevice(Device);
|
||||
|
||||
_coreService.ProfileRenderingDisabled = false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
HasDeskCategory = Device.Categories.Contains(DeviceCategory.Desk);
|
||||
HasMonitorCategory = Device.Categories.Contains(DeviceCategory.Monitor);
|
||||
HasCaseCategory = Device.Categories.Contains(DeviceCategory.Case);
|
||||
HasRoomCategory = Device.Categories.Contains(DeviceCategory.Room);
|
||||
HasPeripheralsCategory = Device.Categories.Contains(DeviceCategory.Peripherals);
|
||||
|
||||
RedScale = _initialRedScale * 100;
|
||||
GreenScale = _initialGreenScale * 100;
|
||||
BlueScale = _initialBlueScale * 100;
|
||||
}
|
||||
|
||||
private bool GetCategory(DeviceCategory category)
|
||||
{
|
||||
return _categories.Contains(category);
|
||||
}
|
||||
|
||||
private void SetCategory(DeviceCategory category, bool value)
|
||||
{
|
||||
if (value && !_categories.Contains(category))
|
||||
_categories.Add(category);
|
||||
else if (!value)
|
||||
_categories.Remove(category);
|
||||
|
||||
this.RaisePropertyChanged($"Has{category}Category");
|
||||
}
|
||||
|
||||
private void OnFrameRendering(object? sender, FrameRenderingEventArgs e)
|
||||
{
|
||||
if (!_displayOnDevices)
|
||||
return;
|
||||
|
||||
using SKPaint overlayPaint = new() {Color = CurrentColor};
|
||||
e.Canvas.DrawRect(0, 0, e.Canvas.LocalClipBounds.Width, e.Canvas.LocalClipBounds.Height, overlayPaint);
|
||||
}
|
||||
|
||||
private void DeviceOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(Device.CustomLayoutPath) || e.PropertyName == nameof(Device.DisableDefaultLayout))
|
||||
Task.Run(() => _rgbService.ApplyBestDeviceLayout(Device));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user