mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
Invalid plugin settings will fall back to their type's default
Main window remembers it's position now Surface editor's surface list size is saved
This commit is contained in:
parent
1a98ef62d3
commit
5a8a2b2684
@ -21,7 +21,14 @@ namespace Artemis.Core.Plugins.Models
|
|||||||
_pluginSettingEntity = pluginSettingEntity;
|
_pluginSettingEntity = pluginSettingEntity;
|
||||||
|
|
||||||
Name = pluginSettingEntity.Name;
|
Name = pluginSettingEntity.Name;
|
||||||
Value = JsonConvert.DeserializeObject<T>(pluginSettingEntity.Value);
|
try
|
||||||
|
{
|
||||||
|
Value = JsonConvert.DeserializeObject<T>(pluginSettingEntity.Value);
|
||||||
|
}
|
||||||
|
catch (JsonReaderException)
|
||||||
|
{
|
||||||
|
Value = default(T);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -86,5 +93,10 @@ namespace Artemis.Core.Plugins.Models
|
|||||||
{
|
{
|
||||||
SettingChanged?.Invoke(this, EventArgs.Empty);
|
SettingChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{nameof(Name)}: {Name}, {nameof(Value)}: {Value}, {nameof(HasChanged)}: {HasChanged}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,10 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
switch (Led.Shape)
|
switch (Led.Shape)
|
||||||
{
|
{
|
||||||
case Shape.Custom:
|
case Shape.Custom:
|
||||||
CreateCustomGeometry();
|
if (Led.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
|
||||||
|
CreateCustomGeometry(2.0);
|
||||||
|
else
|
||||||
|
CreateCustomGeometry(1.0);
|
||||||
break;
|
break;
|
||||||
case Shape.Rectangle:
|
case Shape.Rectangle:
|
||||||
if (Led.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
|
if (Led.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
|
||||||
@ -73,7 +76,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
DisplayGeometry = new RectangleGeometry(new Rect(1, 1, Led.LedRectangle.Width - 2, Led.LedRectangle.Height - 2), 1.6, 1.6);
|
DisplayGeometry = new RectangleGeometry(new Rect(1, 1, Led.LedRectangle.Width - 2, Led.LedRectangle.Height - 2), 1.6, 1.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateCustomGeometry()
|
private void CreateCustomGeometry(double deflateAmount)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -85,8 +88,8 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
{
|
{
|
||||||
Children = new TransformCollection
|
Children = new TransformCollection
|
||||||
{
|
{
|
||||||
new ScaleTransform(Led.LedRectangle.Width - 1, Led.LedRectangle.Height - 1),
|
new ScaleTransform(Led.LedRectangle.Width - deflateAmount, Led.LedRectangle.Height - deflateAmount),
|
||||||
new TranslateTransform(0.5, 0.5)
|
new TranslateTransform(deflateAmount/2, deflateAmount/2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,6 +6,8 @@ using System.Windows;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
|
using Artemis.Core.Plugins.Models;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Artemis.Core.Services.Storage;
|
using Artemis.Core.Services.Storage;
|
||||||
using Artemis.UI.Services.Interfaces;
|
using Artemis.UI.Services.Interfaces;
|
||||||
using Artemis.UI.ViewModels.Controls.SurfaceEditor;
|
using Artemis.UI.ViewModels.Controls.SurfaceEditor;
|
||||||
@ -19,9 +21,10 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
public class SurfaceEditorViewModel : Screen, IScreenViewModel
|
public class SurfaceEditorViewModel : Screen, IScreenViewModel
|
||||||
{
|
{
|
||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
|
private readonly ISettingsService _settingsService;
|
||||||
private readonly ISurfaceService _surfaceService;
|
private readonly ISurfaceService _surfaceService;
|
||||||
|
|
||||||
public SurfaceEditorViewModel(ISurfaceService surfaceService, IDialogService dialogService)
|
public SurfaceEditorViewModel(ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService)
|
||||||
{
|
{
|
||||||
Devices = new ObservableCollection<SurfaceDeviceViewModel>();
|
Devices = new ObservableCollection<SurfaceDeviceViewModel>();
|
||||||
SurfaceConfigurations = new ObservableCollection<Surface>();
|
SurfaceConfigurations = new ObservableCollection<Surface>();
|
||||||
@ -30,12 +33,14 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
|
|
||||||
_surfaceService = surfaceService;
|
_surfaceService = surfaceService;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
|
_settingsService = settingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<SurfaceDeviceViewModel> Devices { get; set; }
|
public ObservableCollection<SurfaceDeviceViewModel> Devices { get; set; }
|
||||||
public ObservableCollection<Surface> SurfaceConfigurations { get; set; }
|
public ObservableCollection<Surface> SurfaceConfigurations { get; set; }
|
||||||
public RectangleGeometry SelectionRectangle { get; set; }
|
public RectangleGeometry SelectionRectangle { get; set; }
|
||||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||||
|
public PluginSetting<GridLength> SurfaceListWidth { get; set; }
|
||||||
|
|
||||||
public Surface SelectedSurface
|
public Surface SelectedSurface
|
||||||
{
|
{
|
||||||
@ -56,6 +61,16 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadWorkspaceSettings()
|
||||||
|
{
|
||||||
|
SurfaceListWidth = _settingsService.GetSetting("SurfaceEditor.SurfaceListWidth", new GridLength(300.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveWorkspaceSettings()
|
||||||
|
{
|
||||||
|
SurfaceListWidth.Save();
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadSurfaceConfigurations()
|
private void LoadSurfaceConfigurations()
|
||||||
{
|
{
|
||||||
// Get surface configs
|
// Get surface configs
|
||||||
@ -116,9 +131,16 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
LoadSurfaceConfigurations();
|
LoadSurfaceConfigurations();
|
||||||
|
LoadWorkspaceSettings();
|
||||||
base.OnActivate();
|
base.OnActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate()
|
||||||
|
{
|
||||||
|
SaveWorkspaceSettings();
|
||||||
|
base.OnDeactivate();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Configuration management
|
#region Configuration management
|
||||||
|
|||||||
@ -32,12 +32,13 @@
|
|||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource MaterialDesignDisplay1TextBlock}">Profile editor</TextBlock>
|
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
<TextBlock >
|
||||||
Margin="0,0,0,5">
|
<materialDesign:PackIcon Kind="AboutOutline" Margin="0 0 0 -3"/> The profile defines what colors the LEDs will have. Multiple groups of LEDs are defined into layers. On these layers you can apply effects.
|
||||||
The profile defines what colors the LEDs will have. Multiple groups of LEDs are defined into layers. On these layers you can apply effects.
|
</TextBlock>
|
||||||
</TextBlock>
|
<Border BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="0 0 0 1" Margin="0 10" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="2" Grid.Column="0"
|
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="2" Grid.Column="0"
|
||||||
VerticalAlignment="Stretch" Margin="0,0,5,0">
|
VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||||
@ -161,8 +162,8 @@
|
|||||||
</materialDesign:DialogHost>
|
</materialDesign:DialogHost>
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
|
|
||||||
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
|
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0,5,0,0">
|
||||||
Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0,5,0,0">
|
<materialDesign:PackIcon Kind="Keyboard" Margin="0 0 0 -3"/>
|
||||||
<Run Text="Hold" />
|
<Run Text="Hold" />
|
||||||
<Run FontWeight="Bold" Text="shift" />
|
<Run FontWeight="Bold" Text="shift" />
|
||||||
<Run Text="or click and drag to select multiple LEDs at once. To move around the surface hold down" />
|
<Run Text="or click and drag to select multiple LEDs at once. To move around the surface hold down" />
|
||||||
|
|||||||
@ -12,9 +12,10 @@
|
|||||||
GlowBrush="{DynamicResource AccentColorBrush}"
|
GlowBrush="{DynamicResource AccentColorBrush}"
|
||||||
FontFamily="{StaticResource DefaultFont}"
|
FontFamily="{StaticResource DefaultFont}"
|
||||||
Title="Artemis"
|
Title="Artemis"
|
||||||
d:DesignHeight="639.411"
|
d:DesignHeight="640"
|
||||||
d:DesignWidth="1113.251"
|
d:DesignWidth="1200"
|
||||||
d:DataContext="{d:DesignInstance screens:RootViewModel}"
|
d:DataContext="{d:DesignInstance screens:RootViewModel}"
|
||||||
|
SaveWindowPosition="True"
|
||||||
Icon="/Artemis.UI;component/Resources/logo-512.png">
|
Icon="/Artemis.UI;component/Resources/logo-512.png">
|
||||||
<metro:MetroWindow.LeftWindowCommands>
|
<metro:MetroWindow.LeftWindowCommands>
|
||||||
<metro:WindowCommands>
|
<metro:WindowCommands>
|
||||||
|
|||||||
@ -24,22 +24,22 @@
|
|||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" MinWidth="100" />
|
<ColumnDefinition Width="*" MinWidth="100" />
|
||||||
<ColumnDefinition Width="5" />
|
<ColumnDefinition Width="5" />
|
||||||
<ColumnDefinition Width="300" MinWidth="100" />
|
<ColumnDefinition Width="{Binding SurfaceListWidth.Value, Mode=TwoWay}" MinWidth="100" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource MaterialDesignDisplay1TextBlock}">Surface layout</TextBlock>
|
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
<TextBlock >
|
||||||
Margin="0,0,0,5">
|
<materialDesign:PackIcon Kind="AboutOutline" Margin="0 0 0 -3"/> The surface is a digital representation of your LED setup. Set this up accurately and effects will seamlessly move from one device to the other.
|
||||||
The surface is a digital representation of your LED setup. Set this up accurately and effects will seamlessly move from one device to the other.
|
</TextBlock>
|
||||||
</TextBlock>
|
<Border BorderBrush="{DynamicResource MaterialDesignDivider}" BorderThickness="0 0 0 1" Margin="0 10" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="2" Grid.Column="0"
|
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="1" Grid.Column="0"
|
||||||
VerticalAlignment="Stretch" Margin="0,0,5,0">
|
VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||||
<Grid ClipToBounds="True"
|
<Grid ClipToBounds="True"
|
||||||
KeyUp="{s:Action EditorGridKeyUp}"
|
KeyUp="{s:Action EditorGridKeyUp}"
|
||||||
@ -176,16 +176,20 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
<GridSplitter Grid.Column="1" Grid.Row="2" Width="5" HorizontalAlignment="Stretch" />
|
|
||||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="2" Grid.Column="2"
|
<GridSplitter Grid.Column="1" Grid.Row="1" Width="5" HorizontalAlignment="Stretch" ShowsPreview="True" />
|
||||||
|
|
||||||
|
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" Grid.Row="1" Grid.Column="2"
|
||||||
VerticalAlignment="Stretch" Margin="5,0,0,0">
|
VerticalAlignment="Stretch" Margin="5,0,0,0">
|
||||||
<materialDesign:DialogHost Identifier="SurfaceListDialogHost" CloseOnClickAway="True" UseLayoutRounding="True">
|
<materialDesign:DialogHost Identifier="SurfaceListDialogHost" CloseOnClickAway="True"
|
||||||
|
UseLayoutRounding="True">
|
||||||
<Grid HorizontalAlignment="Stretch">
|
<Grid HorizontalAlignment="Stretch">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListBox Grid.Row="0" HorizontalContentAlignment="Stretch" ItemsSource="{Binding SurfaceConfigurations}" SelectedItem="{Binding SelectedSurface}">
|
<ListBox Grid.Row="0" HorizontalContentAlignment="Stretch"
|
||||||
|
ItemsSource="{Binding SurfaceConfigurations}" SelectedItem="{Binding SelectedSurface}">
|
||||||
<ListBox.Resources>
|
<ListBox.Resources>
|
||||||
<DataTemplate DataType="{x:Type models:Surface}">
|
<DataTemplate DataType="{x:Type models:Surface}">
|
||||||
<Grid>
|
<Grid>
|
||||||
@ -193,7 +197,8 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="40" />
|
<ColumnDefinition Width="40" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Text="{Binding Name}" ToolTip="{Binding Name}" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
<TextBlock Text="{Binding Name}" ToolTip="{Binding Name}"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||||
<Button Grid.Column="1"
|
<Button Grid.Column="1"
|
||||||
Command="{s:Action DeleteSurfaceConfiguration}"
|
Command="{s:Action DeleteSurfaceConfiguration}"
|
||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
@ -220,8 +225,8 @@
|
|||||||
</materialDesign:DialogHost>
|
</materialDesign:DialogHost>
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
|
|
||||||
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
|
<TextBlock Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0,5,0,0">
|
||||||
Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0,5,0,0">
|
<materialDesign:PackIcon Kind="Keyboard" Margin="0 0 0 -3"/>
|
||||||
<Run Text="Hold" />
|
<Run Text="Hold" />
|
||||||
<Run FontWeight="Bold" Text="shift" />
|
<Run FontWeight="Bold" Text="shift" />
|
||||||
<Run Text="or click and drag to select multiple devices at once. To move around the surface hold down" />
|
<Run Text="or click and drag to select multiple devices at once. To move around the surface hold down" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user