1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Merge branch 'development' into feature/workshop

This commit is contained in:
Robert 2023-08-21 20:15:46 +02:00
commit a51ab70298
11 changed files with 53 additions and 43 deletions

View File

@ -11,19 +11,10 @@ namespace Artemis.Core.DeviceProviders;
/// </summary>
public abstract class DeviceProvider : PluginFeature
{
/// <summary>
/// Creates a new instance of the <see cref="DeviceProvider" /> class
/// </summary>
/// <param name="rgbDeviceProvider"></param>
protected DeviceProvider(IRGBDeviceProvider rgbDeviceProvider)
{
RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider));
}
/// <summary>
/// The RGB.NET device provider backing this Artemis device provider
/// </summary>
public IRGBDeviceProvider RgbDeviceProvider { get; }
public abstract IRGBDeviceProvider RgbDeviceProvider { get; }
/// <summary>
/// A boolean indicating whether this device provider detects the physical layout of connected keyboards.

View File

@ -17,7 +17,7 @@
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaBehavioursVersion)" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="$(FluentAvaloniaVersion)" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.1" />

View File

@ -1,4 +1,4 @@
<Styles xmlns="https://github.com/avaloniaui"
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
@ -102,4 +102,8 @@
<Style Selector="Run.info">
<Setter Property="Foreground" Value="{DynamicResource AccentButtonBackground}"></Setter>
</Style>
<Style Selector="SelectableTextBlock">
<Setter Property="SelectionBrush" Value="{DynamicResource TextControlSelectionHighlightColor}" />
</Style>
</Styles>

View File

@ -25,8 +25,8 @@
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaBehavioursVersion)" />
<PackageReference Include="Avalonia.Skia.Lottie" Version="11.0.0" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaVersion)" />
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="$(FluentAvaloniaVersion)" />

View File

@ -66,13 +66,11 @@ public class DeviceGeneralTabViewModel : ActivatableViewModelBase
this.WhenActivated(d =>
{
Device.PropertyChanged += DeviceOnPropertyChanged;
_coreService.FrameRendering += OnFrameRendering;
Disposable.Create(() =>
{
_coreService.FrameRendering -= OnFrameRendering;
Device.PropertyChanged -= DeviceOnPropertyChanged;
Apply();
}).DisposeWith(d);
});
@ -244,10 +242,4 @@ public class DeviceGeneralTabViewModel : ActivatableViewModelBase
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));
}
}

View File

@ -21,6 +21,7 @@
<Button
Classes="icon-button"
HorizontalAlignment="Right"
IsEnabled="{CompiledBinding !!DefaultLayoutPath}"
ToolTip.Tip="Copy layout file path to clipboard"
Click="LayoutPathButton_OnClick">
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
@ -31,12 +32,13 @@
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Row="1" Grid.Column="0">
<TextBlock Text="Image file path" />
<TextBlock Classes="subtitle" FontSize="12" TextWrapping="Wrap" Text="{CompiledBinding Device.Layout.Image.LocalPath}" />
<TextBlock Classes="subtitle" FontSize="12" TextWrapping="Wrap" Text="{CompiledBinding ImagePath, TargetNullValue=None}" />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
<Button
Classes="icon-button"
HorizontalAlignment="Right"
IsEnabled="{CompiledBinding !!ImagePath}"
ToolTip.Tip="Copy image file path to clipboard"
Click="ImagePathButton_OnClick">
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
@ -50,14 +52,14 @@
<TextBlock Classes="subtitle" FontSize="12" Text="With this checked, Artemis will not load a layout for this device unless you specifically provide one." />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
<CheckBox HorizontalAlignment="Right" Margin="0,0,-10,0" />
<CheckBox HorizontalAlignment="Right" Margin="0,0,-10,0" IsChecked="{CompiledBinding Device.DisableDefaultLayout}" />
</StackPanel>
</Grid>
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Row="1" Grid.Column="0">
<TextBlock Text="Custom layout path" />
<TextBlock Classes="subtitle" FontSize="12" Text="{CompiledBinding CustomLayoutPath}" />
<TextBlock Classes="subtitle" FontSize="12" Text="{CompiledBinding CustomLayoutPath, TargetNullValue=None}"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
<Button Content="Clear" Command="{CompiledBinding ClearCustomLayout}" IsEnabled="{CompiledBinding HasCustomLayout}" />

View File

@ -16,12 +16,18 @@ public partial class DeviceLayoutTabView : ReactiveUserControl<DeviceLayoutTabVi
private void LayoutPathButton_OnClick(object? sender, RoutedEventArgs e)
{
if (ViewModel?.DefaultLayoutPath is null)
return;
TopLevel.GetTopLevel(this).Clipboard.SetTextAsync(ViewModel.DefaultLayoutPath);
ViewModel.ShowCopiedNotification();
}
private void ImagePathButton_OnClick(object? sender, RoutedEventArgs e)
{
if (ViewModel?.Device?.Layout?.Image?.LocalPath is null)
return;
TopLevel.GetTopLevel(this).Clipboard.SetTextAsync(ViewModel.Device.Layout.Image.LocalPath);
ViewModel.ShowCopiedNotification();
}

View File

@ -22,42 +22,52 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
{
private readonly IWindowService _windowService;
private readonly INotificationService _notificationService;
private readonly ICoreService _coreService;
private readonly IRgbService _rgbService;
public DeviceLayoutTabViewModel(
IWindowService windowService,
INotificationService notificationService,
ICoreService coreService,
IRgbService rgbService,
ArtemisDevice device)
{
_windowService = windowService;
_notificationService = notificationService;
_coreService = coreService;
_rgbService = rgbService;
Device = device;
DisplayName = "Layout";
DefaultLayoutPath = Device.DeviceProvider.LoadLayout(Device).FilePath;
this.WhenActivated(d =>
{
Device.PropertyChanged += DeviceOnPropertyChanged;
Disposable.Create(() =>
{
Device.PropertyChanged -= DeviceOnPropertyChanged;
}).DisposeWith(d);
});
}
public ArtemisDevice Device { get; }
public string DefaultLayoutPath { get; }
public string? ImagePath => Device.Layout?.Image?.LocalPath;
public string CustomLayoutPath => Device.CustomLayoutPath ?? "None";
public string CustomLayoutPath => Device.CustomLayoutPath;
public bool HasCustomLayout => Device.CustomLayoutPath != null;
private void RaiseCustomLayoutChanged()
{
this.RaisePropertyChanged(nameof(CustomLayoutPath));
this.RaisePropertyChanged(nameof(HasCustomLayout));
}
public void ClearCustomLayout()
{
Device.CustomLayoutPath = null;
_notificationService.CreateNotification()
.WithMessage("Cleared imported layout.")
.WithSeverity(NotificationSeverity.Informational);
RaiseCustomLayoutChanged();
}
public async Task BrowseCustomLayout()
@ -75,8 +85,6 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
.WithMessage($"File loaded from {files[0]}")
.WithSeverity(NotificationSeverity.Informational);
}
RaiseCustomLayoutChanged();
}
public async Task ExportLayout()
@ -148,4 +156,10 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
.WithSeverity(NotificationSeverity.Informational)
.Show();
}
private void DeviceOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(Device.CustomLayoutPath) or nameof(Device.DisableDefaultLayout))
Task.Run(() => _rgbService.ApplyBestDeviceLayout(Device));
}
}

View File

@ -35,11 +35,11 @@
</controls:HyperlinkButton>
</StackPanel>
<TextBlock Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Top"
Classes="subtitle"
Text="{CompiledBinding Version}" />
<SelectableTextBlock Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Top"
Classes="subtitle"
Text="{CompiledBinding Version}" />
<controls:HyperlinkButton Grid.Row="1"
Grid.Column="2"

View File

@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="$(AvaloniaBehavioursVersion)" />
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
<PackageReference Include="NoStringEvaluating" Version="2.5.2" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />

View File

@ -1,8 +1,9 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AvaloniaVersion>11.0.2</AvaloniaVersion>
<AvaloniaVersion>11.0.4</AvaloniaVersion>
<AvaloniaBehavioursVersion>11.0.2</AvaloniaBehavioursVersion>
<FluentAvaloniaVersion>2.0.1</FluentAvaloniaVersion>
<RGBDotNetVersion>2.0.0-prerelease.94</RGBDotNetVersion>
<RGBDotNetVersion>2.0.0-prerelease.101</RGBDotNetVersion>
<SkiaSharpVersion>2.88.3</SkiaSharpVersion>
</PropertyGroup>
</Project>