Update service - Removed option to install updates without asking

Modules - Decrease CPU usage for activation requirements check by using a centralized service
Devices - Reload provider when unloading a layout
This commit is contained in:
Robert committed 2021-06-10 17:41:54 +02:00
1 parent 38c04913e2
commit fe933f60e8
17 files changed
+195 -135

No files matched your search

@@ -25,9 +25,11 @@ namespace Artemis.UI.Screens.Settings.Device
private readonly ICoreService _coreService;
private readonly IDeviceService _deviceService;
private readonly IDialogService _dialogService;
private readonly IDeviceDebugVmFactory _factory;
private readonly IRgbService _rgbService;
private SnackbarMessageQueue _deviceMessageQueue;
private BindableCollection<ArtemisLed> _selectedLeds;
private ArtemisDevice _device;
public DeviceDialogViewModel(ArtemisDevice device,
ICoreService coreService,
@@ -40,22 +42,46 @@ namespace Artemis.UI.Screens.Settings.Device
_deviceService = deviceService;
_rgbService = rgbService;
_dialogService = dialogService;
_factory = factory;
Device = device;
PanZoomViewModel = new PanZoomViewModel();
SelectedLeds = new BindableCollection<ArtemisLed>();
Items.Add(factory.DevicePropertiesTabViewModel(device));
if (device.DeviceType == RGBDeviceType.Keyboard)
Items.Add(factory.InputMappingsTabViewModel(device));
Items.Add(factory.DeviceInfoTabViewModel(device));
Items.Add(factory.DeviceLedsTabViewModel(device));
ActiveItem = Items.First();
DisplayName = $"{device.RgbDevice.DeviceInfo.Model} | Artemis";
Initialize(device);
}
private void Initialize(ArtemisDevice device)
{
if (SelectedLeds.Any())
SelectedLeds.Clear();
if (Device != null)
Device.DeviceUpdated -= DeviceOnDeviceUpdated;
Device = device;
Device.DeviceUpdated += DeviceOnDeviceUpdated;
int activeTabIndex = 0;
if (Items.Any())
{
activeTabIndex = Items.IndexOf(ActiveItem);
Items.Clear();
}
Items.Add(_factory.DevicePropertiesTabViewModel(Device));
if (Device.DeviceType == RGBDeviceType.Keyboard)
Items.Add(_factory.InputMappingsTabViewModel(Device));
Items.Add(_factory.DeviceInfoTabViewModel(Device));
Items.Add(_factory.DeviceLedsTabViewModel(Device));
ActiveItem = Items[activeTabIndex];
DisplayName = $"{Device.RgbDevice.DeviceInfo.Model} | Artemis";
}
public ArtemisDevice Device
{
get => _device;
set => SetAndNotify(ref _device, value);
}
public ArtemisDevice Device { get; }
public PanZoomViewModel PanZoomViewModel { get; }
public SnackbarMessageQueue DeviceMessageQueue
@@ -84,14 +110,21 @@ namespace Artemis.UI.Screens.Settings.Device
protected override void OnInitialActivate()
{
_coreService.FrameRendering += CoreServiceOnFrameRendering;
_rgbService.DeviceAdded += RgbServiceOnDeviceAdded;
DeviceMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(5));
Device.DeviceUpdated += DeviceOnDeviceUpdated;
base.OnInitialActivate();
}
private void RgbServiceOnDeviceAdded(object sender, DeviceEventArgs e)
{
if (e.Device != Device && e.Device.Identifier == Device.Identifier)
Execute.OnUIThread(() => Initialize(e.Device));
}
protected override void OnClose()
{
_coreService.FrameRendering -= CoreServiceOnFrameRendering;
_rgbService.DeviceAdded -= RgbServiceOnDeviceAdded;
Device.DeviceUpdated -= DeviceOnDeviceUpdated;
base.OnClose();
}
@@ -202,12 +202,12 @@
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>
<CheckBox Margin="0 0 0 5" Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding UseDefaultLayout}">
<CheckBox Margin="0 0 0 5" Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding Device.DisableDefaultLayout, Delay=300}">
<CheckBox.Content>
<TextBlock Margin="0 -5 0 0">
Use default layout if needed
Don't load default layout
<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." />
ToolTip="With this enabled Artemis will not load a layout for this device unless you specifically provide one." />
</TextBlock>
</CheckBox.Content>
</CheckBox>
@@ -101,7 +101,7 @@ 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
@@ -134,16 +134,6 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
set => SetCategory(DeviceCategory.Peripherals, value);
}
public bool UseDefaultLayout
{
get => !Device.DisableDefaultLayout;
set
{
Device.DisableDefaultLayout = !value;
NotifyOfPropertyChange(nameof(UseDefaultLayout));
}
}
public void ApplyScaling()
{
Device.RedScale = RedScale / 100f;
@@ -266,7 +256,9 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
private void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Device.CustomLayoutPath) || e.PropertyName == nameof(Device.DisableDefaultLayout))
_rgbService.ApplyBestDeviceLayout(Device);
{
Task.Run(() => _rgbService.ApplyBestDeviceLayout(Device));
}
}
private void OnFrameRendering(object sender, FrameRenderingEventArgs e)