mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Refactored layout loading, fixing LED images
Core - Make a better effort at removing orphaned devices from device providers that failed to load
This commit is contained in:
1 parent
38f18613c1
commit
43e396bf6d
10 files changed
+111
-124
No files matched your search
@@ -52,7 +52,7 @@
|
||||
<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" IsChecked="{CompiledBinding Device.DisableDefaultLayout}" />
|
||||
<CheckBox HorizontalAlignment="Right" Margin="0,0,-10,0" IsChecked="{CompiledBinding Device.DisableDefaultLayout}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Border Classes="card-separator" />
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
|
||||
Device = device;
|
||||
DisplayName = "Layout";
|
||||
DefaultLayoutPath = Device.DeviceProvider.LoadLayout(Device).FilePath;
|
||||
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
Device.PropertyChanged += DeviceOnPropertyChanged;
|
||||
@@ -42,23 +42,21 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
|
||||
public string DefaultLayoutPath { get; }
|
||||
|
||||
public string? ImagePath => Device.Layout?.Image?.LocalPath;
|
||||
|
||||
|
||||
public string? CustomLayoutPath => Device.CustomLayoutPath;
|
||||
|
||||
|
||||
public bool HasCustomLayout => Device.CustomLayoutPath != null;
|
||||
|
||||
|
||||
public void ClearCustomLayout()
|
||||
{
|
||||
Device.CustomLayoutPath = null;
|
||||
_notificationService.CreateNotification()
|
||||
.WithMessage("Cleared imported layout.")
|
||||
.WithSeverity(NotificationSeverity.Informational);
|
||||
|
||||
_deviceService.SaveDevice(Device);
|
||||
}
|
||||
|
||||
public async Task BrowseCustomLayout()
|
||||
@@ -75,8 +73,6 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
|
||||
.WithTitle("Imported layout")
|
||||
.WithMessage($"File loaded from {files[0]}")
|
||||
.WithSeverity(NotificationSeverity.Informational);
|
||||
|
||||
_deviceService.SaveDevice(Device);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +150,12 @@ public class DeviceLayoutTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
if (e.PropertyName is nameof(Device.CustomLayoutPath) or nameof(Device.DisableDefaultLayout))
|
||||
{
|
||||
Task.Run(() => _deviceService.ApplyDeviceLayout(Device, Device.GetBestDeviceLayout()));
|
||||
Task.Run(() =>
|
||||
{
|
||||
_deviceService.ApplyDeviceLayout(Device, Device.GetBestDeviceLayout());
|
||||
_deviceService.SaveDevice(Device);
|
||||
});
|
||||
|
||||
this.RaisePropertyChanged(nameof(CustomLayoutPath));
|
||||
this.RaisePropertyChanged(nameof(HasCustomLayout));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user