mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Devices - Added option to disable default layouts
This commit is contained in:
parent
fb3f7e0cc1
commit
cef37677f2
@ -33,6 +33,8 @@ namespace Artemis.Core
|
|||||||
BlueScale = 1;
|
BlueScale = 1;
|
||||||
IsEnabled = true;
|
IsEnabled = true;
|
||||||
|
|
||||||
|
LedIds = new ReadOnlyDictionary<LedId, ArtemisLed>(new Dictionary<LedId, ArtemisLed>());
|
||||||
|
Leds = new ReadOnlyCollection<ArtemisLed>(new List<ArtemisLed>());
|
||||||
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
||||||
InputMappings = new Dictionary<ArtemisLed, ArtemisLed>();
|
InputMappings = new Dictionary<ArtemisLed, ArtemisLed>();
|
||||||
Categories = new HashSet<DeviceCategory>();
|
Categories = new HashSet<DeviceCategory>();
|
||||||
@ -51,6 +53,8 @@ namespace Artemis.Core
|
|||||||
RgbDevice = rgbDevice;
|
RgbDevice = rgbDevice;
|
||||||
DeviceProvider = deviceProvider;
|
DeviceProvider = deviceProvider;
|
||||||
|
|
||||||
|
LedIds = new ReadOnlyDictionary<LedId, ArtemisLed>(new Dictionary<LedId, ArtemisLed>());
|
||||||
|
Leds = new ReadOnlyCollection<ArtemisLed>(new List<ArtemisLed>());
|
||||||
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
||||||
InputMappings = new Dictionary<ArtemisLed, ArtemisLed>();
|
InputMappings = new Dictionary<ArtemisLed, ArtemisLed>();
|
||||||
Categories = new HashSet<DeviceCategory>();
|
Categories = new HashSet<DeviceCategory>();
|
||||||
@ -258,6 +262,19 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether falling back to default layouts is enabled or not
|
||||||
|
/// </summary>
|
||||||
|
public bool DisableDefaultLayout
|
||||||
|
{
|
||||||
|
get => DeviceEntity.DisableDefaultLayout;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
DeviceEntity.DisableDefaultLayout = value;
|
||||||
|
OnPropertyChanged(nameof(DisableDefaultLayout));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the logical layout of the device e.g. DE, UK or US.
|
/// Gets or sets the logical layout of the device e.g. DE, UK or US.
|
||||||
/// <para>Only applicable to keyboards</para>
|
/// <para>Only applicable to keyboards</para>
|
||||||
@ -532,6 +549,11 @@ namespace Artemis.Core
|
|||||||
else
|
else
|
||||||
LogicalLayout = DeviceEntity.LogicalLayout;
|
LogicalLayout = DeviceEntity.LogicalLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearLayout()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -354,14 +354,21 @@ namespace Artemis.Core.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally fall back to a default layout
|
// Finally fall back to a default layout
|
||||||
|
if (!device.DisableDefaultLayout)
|
||||||
layout = ArtemisLayout.GetDefaultLayout(device);
|
layout = ArtemisLayout.GetDefaultLayout(device);
|
||||||
if (layout != null)
|
|
||||||
ApplyDeviceLayout(device, layout);
|
ApplyDeviceLayout(device, layout);
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyDeviceLayout(ArtemisDevice device, ArtemisLayout layout)
|
public void ApplyDeviceLayout(ArtemisDevice device, ArtemisLayout? layout)
|
||||||
{
|
{
|
||||||
|
if (layout == null)
|
||||||
|
{
|
||||||
|
if (device.Layout != null)
|
||||||
|
device.ClearLayout();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (layout.Source == LayoutSource.Default)
|
if (layout.Source == LayoutSource.Default)
|
||||||
device.ApplyLayout(layout, false, false);
|
device.ApplyLayout(layout, false, false);
|
||||||
else
|
else
|
||||||
|
|||||||
@ -22,6 +22,7 @@ namespace Artemis.Storage.Entities.Surface
|
|||||||
public float BlueScale { get; set; }
|
public float BlueScale { get; set; }
|
||||||
public bool IsEnabled { get; set; }
|
public bool IsEnabled { get; set; }
|
||||||
|
|
||||||
|
public bool DisableDefaultLayout { get; set; }
|
||||||
public int PhysicalLayout { get; set; }
|
public int PhysicalLayout { get; set; }
|
||||||
public string LogicalLayout { get; set; }
|
public string LogicalLayout { get; set; }
|
||||||
public string CustomLayoutPath { get; set; }
|
public string CustomLayoutPath { get; set; }
|
||||||
|
|||||||
41
src/Artemis.UI.Shared/Behaviors/OpenInBrowser.cs
Normal file
41
src/Artemis.UI.Shared/Behaviors/OpenInBrowser.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Microsoft.Xaml.Behaviors;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a behavior that opens the URI of the hyperlink in the browser when requested
|
||||||
|
/// </summary>
|
||||||
|
public class OpenInBrowser : Behavior<Hyperlink>
|
||||||
|
{
|
||||||
|
private Hyperlink? _hyperLink;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnAttached()
|
||||||
|
{
|
||||||
|
base.OnAttached();
|
||||||
|
|
||||||
|
_hyperLink = AssociatedObject;
|
||||||
|
if (_hyperLink == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_hyperLink.RequestNavigate += HyperLinkOnRequestNavigate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnDetaching()
|
||||||
|
{
|
||||||
|
if (_hyperLink == null) return;
|
||||||
|
_hyperLink.RequestNavigate -= HyperLinkOnRequestNavigate;
|
||||||
|
|
||||||
|
base.OnDetaching();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HyperLinkOnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||||
|
{
|
||||||
|
Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,6 +7,7 @@
|
|||||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance local:DevicePropertiesTabViewModel}">
|
d:DataContext="{d:DesignInstance local:DevicePropertiesTabViewModel}">
|
||||||
@ -192,15 +193,25 @@
|
|||||||
|
|
||||||
<!-- Layout -->
|
<!-- Layout -->
|
||||||
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}">
|
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}">
|
||||||
Custom layout
|
Layout
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||||
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
TextAlignment="Justify">
|
TextAlignment="Justify">
|
||||||
Select a custom layout below if you want to change the appearance and/or LEDs of this device.
|
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>
|
</TextBlock>
|
||||||
|
|
||||||
|
<CheckBox Margin="0 0 0 5" Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding UseDefaultLayout}">
|
||||||
|
<CheckBox.Content>
|
||||||
|
<TextBlock Margin="0 -5 0 0">
|
||||||
|
Use default layout if needed
|
||||||
|
<materialDesign:PackIcon Kind="HelpCircle"
|
||||||
|
ToolTip="If there is no built-in layout and no custom layout, with this enabled Artemis will fall back to the default layout of this device type." />
|
||||||
|
</TextBlock>
|
||||||
|
</CheckBox.Content>
|
||||||
|
</CheckBox>
|
||||||
|
|
||||||
<TextBox Style="{StaticResource MaterialDesignFilledTextBox}"
|
<TextBox Style="{StaticResource MaterialDesignFilledTextBox}"
|
||||||
Text="{Binding Device.CustomLayoutPath}"
|
Text="{Binding Device.CustomLayoutPath}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
@ -210,10 +221,25 @@
|
|||||||
<materialDesign:HintAssist.Hint>
|
<materialDesign:HintAssist.Hint>
|
||||||
<StackPanel Orientation="Horizontal" Margin="-2 0 0 0">
|
<StackPanel Orientation="Horizontal" Margin="-2 0 0 0">
|
||||||
<materialDesign:PackIcon Kind="Xml" Width="20" />
|
<materialDesign:PackIcon Kind="Xml" Width="20" />
|
||||||
<TextBlock>Layout path</TextBlock>
|
<TextBlock>Custom layout path</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</materialDesign:HintAssist.Hint>
|
</materialDesign:HintAssist.Hint>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
|
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||||
|
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
TextAlignment="Justify">
|
||||||
|
Select a custom layout below if you want to change the appearance and/or LEDs of this device.
|
||||||
|
For info on how to create layouts, check out
|
||||||
|
<Hyperlink Style="{StaticResource ArtemisHyperlink}"
|
||||||
|
NavigateUri="https://wiki.artemis-rgb.com/en/guides/developer/layouts">
|
||||||
|
this wiki article
|
||||||
|
<b:Interaction.Behaviors>
|
||||||
|
<shared:OpenInBrowser />
|
||||||
|
</b:Interaction.Behaviors>
|
||||||
|
</Hyperlink>
|
||||||
|
.
|
||||||
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
|
|||||||
@ -134,6 +134,16 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
|
|||||||
set => SetCategory(DeviceCategory.Peripherals, value);
|
set => SetCategory(DeviceCategory.Peripherals, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool UseDefaultLayout
|
||||||
|
{
|
||||||
|
get => !Device.DisableDefaultLayout;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Device.DisableDefaultLayout = !value;
|
||||||
|
NotifyOfPropertyChange(nameof(UseDefaultLayout));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ApplyScaling()
|
public void ApplyScaling()
|
||||||
{
|
{
|
||||||
Device.RedScale = RedScale / 100f;
|
Device.RedScale = RedScale / 100f;
|
||||||
@ -255,7 +265,7 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
|
|||||||
|
|
||||||
private void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
private void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == nameof(Device.CustomLayoutPath))
|
if (e.PropertyName == nameof(Device.CustomLayoutPath) || e.PropertyName == nameof(Device.DisableDefaultLayout))
|
||||||
_rgbService.ApplyBestDeviceLayout(Device);
|
_rgbService.ApplyBestDeviceLayout(Device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user