Profiles - Added profile adaption based on configurable hints

Layers - Added hints UI accesible from profile tree
Surface - Added device categories used by profile adaption
This commit is contained in:
Robert Beekman authored and Robert committed 2021-05-13 19:57:38 +02:00
1 parent 4865254ab6
commit 57193e739e
34 files changed
+1295 -58

No files matched your search

@@ -21,7 +21,41 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<Grid>
<!-- Layout -->
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}">
Categories
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"
Foreground="{DynamicResource MaterialDesignBodyLight}"
TextWrapping="Wrap"
TextAlignment="Justify">
Artemis uses categories to determine where the layers of imported profiles are applied to. <LineBreak/>
You can hover over a category for a more detailed description.
</TextBlock>
<StackPanel Orientation="Horizontal">
<CheckBox Style="{StaticResource MaterialDesignFilterChipOutlineCheckBox}"
IsChecked="{Binding HasDeskCategory}"
ToolTip="A device acting as desk ornamentation such as a LED strip"
Content="Desk" />
<CheckBox Style="{StaticResource MaterialDesignFilterChipOutlineCheckBox}"
IsChecked="{Binding HasMonitorCategory}"
ToolTip="A device attached to the monitor such as ambilight LEDs"
Content="Monitor" />
<CheckBox Style="{StaticResource MaterialDesignFilterChipOutlineCheckBox}"
ToolTip="A device inside your computer case"
IsChecked="{Binding HasCaseCategory}"
Content="Case" />
<CheckBox Style="{StaticResource MaterialDesignFilterChipOutlineCheckBox}"
IsChecked="{Binding HasRoomCategory}"
ToolTip="A device elsewhere in the room"
Content="Room" />
<CheckBox Style="{StaticResource MaterialDesignFilterChipOutlineCheckBox}"
IsChecked="{Binding HasPeripheralsCategory}"
ToolTip="A peripheral such as a mouse or keyboard"
Content="Peripheral" />
</StackPanel>
<Grid Margin="0 25">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="40" />
@@ -157,7 +191,7 @@
</Grid>
<!-- Layout -->
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" Margin="0 25 0 0">
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}">
Custom layout
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"
@@ -22,6 +22,7 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
private SKColor _currentColor;
private bool _displayOnDevices;
private float _greenScale;
private List<DeviceCategory> _categories;
private float _initialBlueScale;
private float _initialGreenScale;
private float _initialRedScale;
@@ -100,13 +101,45 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
get => _displayOnDevices;
set => SetAndNotify(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 void ApplyScaling()
{
Device.RedScale = RedScale / 100f;
Device.GreenScale = GreenScale / 100f;
Device.BlueScale = BlueScale / 100f;
_rgbService.Surface.Update(true);
}
@@ -151,6 +184,10 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
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.ModuleRenderingDisabled = false;
@@ -158,6 +195,12 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
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);
Device.RedScale = _initialRedScale;
Device.GreenScale = _initialGreenScale;
Device.BlueScale = _initialBlueScale;
@@ -176,6 +219,7 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
_initialRedScale = Device.RedScale;
_initialGreenScale = Device.GreenScale;
_initialBlueScale = Device.BlueScale;
_categories = new List<DeviceCategory>(Device.Categories);
CurrentColor = SKColors.White;
_coreService.FrameRendering += OnFrameRendering;
@@ -192,6 +236,21 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
base.OnDeactivate();
}
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
_categories.Remove(category);
NotifyOfPropertyChange($"Has{category}Category");
}
#region Event handlers
private void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs e)