mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Code style - Use file scoped namespaces
Code style - Ran code cleanup
This commit is contained in:
1 parent
e68e16df4d
commit
f6090dc296
691 files changed
+37301
-38119
No files matched your search
@@ -1,18 +1,17 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public class SettingsView : ReactiveUserControl<SettingsViewModel>
|
||||
{
|
||||
public SettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class SettingsView : ReactiveUserControl<SettingsViewModel>
|
||||
{
|
||||
public SettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -2,25 +2,24 @@
|
||||
using Artemis.UI.Shared;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public class SettingsViewModel : MainScreenViewModel
|
||||
{
|
||||
public SettingsViewModel(IScreen hostScreen,
|
||||
GeneralTabViewModel generalTabViewModel,
|
||||
PluginsTabViewModel pluginsTabViewModel,
|
||||
DevicesTabViewModel devicesTabViewModel,
|
||||
AboutTabViewModel aboutTabViewModel) : base(hostScreen, "settings")
|
||||
{
|
||||
SettingTabs = new ObservableCollection<ActivatableViewModelBase>
|
||||
{
|
||||
generalTabViewModel,
|
||||
pluginsTabViewModel,
|
||||
devicesTabViewModel,
|
||||
aboutTabViewModel
|
||||
};
|
||||
}
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
public ObservableCollection<ActivatableViewModelBase> SettingTabs { get; }
|
||||
public class SettingsViewModel : MainScreenViewModel
|
||||
{
|
||||
public SettingsViewModel(IScreen hostScreen,
|
||||
GeneralTabViewModel generalTabViewModel,
|
||||
PluginsTabViewModel pluginsTabViewModel,
|
||||
DevicesTabViewModel devicesTabViewModel,
|
||||
AboutTabViewModel aboutTabViewModel) : base(hostScreen, "settings")
|
||||
{
|
||||
SettingTabs = new ObservableCollection<ActivatableViewModelBase>
|
||||
{
|
||||
generalTabViewModel,
|
||||
pluginsTabViewModel,
|
||||
devicesTabViewModel,
|
||||
aboutTabViewModel
|
||||
};
|
||||
}
|
||||
|
||||
public ObservableCollection<ActivatableViewModelBase> SettingTabs { get; }
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public partial class AboutTabView : ReactiveUserControl<AboutTabViewModel>
|
||||
{
|
||||
public AboutTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class AboutTabView : ReactiveUserControl<AboutTabViewModel>
|
||||
{
|
||||
public AboutTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -8,69 +8,68 @@ using Avalonia.Media.Imaging;
|
||||
using Flurl.Http;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
public class AboutTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public class AboutTabViewModel : ActivatableViewModelBase
|
||||
private Bitmap? _darthAffeProfileImage;
|
||||
private Bitmap? _drMeteorProfileImage;
|
||||
private Bitmap? _kaiProfileImage;
|
||||
private Bitmap? _robertProfileImage;
|
||||
private string? _version;
|
||||
|
||||
public AboutTabViewModel()
|
||||
{
|
||||
private Bitmap? _darthAffeProfileImage;
|
||||
private Bitmap? _drMeteorProfileImage;
|
||||
private Bitmap? _kaiProfileImage;
|
||||
private Bitmap? _robertProfileImage;
|
||||
private string? _version;
|
||||
DisplayName = "About";
|
||||
this.WhenActivated((CompositeDisposable _) => Task.Run(Activate));
|
||||
}
|
||||
|
||||
public AboutTabViewModel()
|
||||
public string? Version
|
||||
{
|
||||
get => _version;
|
||||
set => RaiseAndSetIfChanged(ref _version, value);
|
||||
}
|
||||
|
||||
public Bitmap? RobertProfileImage
|
||||
{
|
||||
get => _robertProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _robertProfileImage, value);
|
||||
}
|
||||
|
||||
public Bitmap? DarthAffeProfileImage
|
||||
{
|
||||
get => _darthAffeProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _darthAffeProfileImage, value);
|
||||
}
|
||||
|
||||
public Bitmap? DrMeteorProfileImage
|
||||
{
|
||||
get => _drMeteorProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _drMeteorProfileImage, value);
|
||||
}
|
||||
|
||||
public Bitmap? KaiProfileImage
|
||||
{
|
||||
get => _kaiProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _kaiProfileImage, value);
|
||||
}
|
||||
|
||||
private async Task Activate()
|
||||
{
|
||||
AssemblyInformationalVersionAttribute? versionAttribute = typeof(AboutTabViewModel).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
Version = $"Version {versionAttribute?.InformationalVersion} build {Constants.BuildInfo.BuildNumberDisplay}";
|
||||
|
||||
try
|
||||
{
|
||||
DisplayName = "About";
|
||||
this.WhenActivated((CompositeDisposable _) => Task.Run(Activate));
|
||||
RobertProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/8858506".GetStreamAsync());
|
||||
RobertProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/8858506".GetStreamAsync());
|
||||
DarthAffeProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/1094841".GetStreamAsync());
|
||||
DrMeteorProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/29486064".GetStreamAsync());
|
||||
KaiProfileImage = new Bitmap(await "https://i.imgur.com/8mPWY1j.png".GetStreamAsync());
|
||||
}
|
||||
|
||||
public string? Version
|
||||
catch (Exception)
|
||||
{
|
||||
get => _version;
|
||||
set => RaiseAndSetIfChanged(ref _version, value);
|
||||
}
|
||||
|
||||
public Bitmap? RobertProfileImage
|
||||
{
|
||||
get => _robertProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _robertProfileImage, value);
|
||||
}
|
||||
|
||||
public Bitmap? DarthAffeProfileImage
|
||||
{
|
||||
get => _darthAffeProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _darthAffeProfileImage, value);
|
||||
}
|
||||
|
||||
public Bitmap? DrMeteorProfileImage
|
||||
{
|
||||
get => _drMeteorProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _drMeteorProfileImage, value);
|
||||
}
|
||||
|
||||
public Bitmap? KaiProfileImage
|
||||
{
|
||||
get => _kaiProfileImage;
|
||||
set => RaiseAndSetIfChanged(ref _kaiProfileImage, value);
|
||||
}
|
||||
|
||||
private async Task Activate()
|
||||
{
|
||||
AssemblyInformationalVersionAttribute? versionAttribute = typeof(AboutTabViewModel).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
Version = $"Version {versionAttribute?.InformationalVersion} build {Constants.BuildInfo.BuildNumberDisplay}";
|
||||
|
||||
try
|
||||
{
|
||||
RobertProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/8858506".GetStreamAsync());
|
||||
RobertProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/8858506".GetStreamAsync());
|
||||
DarthAffeProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/1094841".GetStreamAsync());
|
||||
DrMeteorProfileImage = new Bitmap(await "https://avatars.githubusercontent.com/u/29486064".GetStreamAsync());
|
||||
KaiProfileImage = new Bitmap(await "https://i.imgur.com/8mPWY1j.png".GetStreamAsync());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored, unluckyyyy
|
||||
}
|
||||
// ignored, unluckyyyy
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public class DevicesTabView : ReactiveUserControl<DevicesTabViewModel>
|
||||
{
|
||||
public DevicesTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class DevicesTabView : ReactiveUserControl<DevicesTabViewModel>
|
||||
{
|
||||
public DevicesTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -14,82 +14,78 @@ using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
public class DevicesTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public class DevicesTabViewModel : ActivatableViewModelBase
|
||||
private readonly IDeviceVmFactory _deviceVmFactory;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly IWindowService _windowService;
|
||||
private bool _confirmedDisable;
|
||||
|
||||
public DevicesTabViewModel(IRgbService rgbService, IWindowService windowService, IDeviceVmFactory deviceVmFactory)
|
||||
{
|
||||
private readonly IDeviceVmFactory _deviceVmFactory;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly IWindowService _windowService;
|
||||
private bool _confirmedDisable;
|
||||
DisplayName = "Devices";
|
||||
|
||||
public DevicesTabViewModel(IRgbService rgbService, IWindowService windowService, IDeviceVmFactory deviceVmFactory)
|
||||
_rgbService = rgbService;
|
||||
_windowService = windowService;
|
||||
_deviceVmFactory = deviceVmFactory;
|
||||
|
||||
Devices = new ObservableCollection<DeviceSettingsViewModel>();
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
DisplayName = "Devices";
|
||||
GetDevices();
|
||||
|
||||
_rgbService = rgbService;
|
||||
_windowService = windowService;
|
||||
_deviceVmFactory = deviceVmFactory;
|
||||
Observable.FromEventPattern<DeviceEventArgs>(x => rgbService.DeviceAdded += x, x => rgbService.DeviceAdded -= x)
|
||||
.Subscribe(d => AddDevice(d.EventArgs.Device))
|
||||
.DisposeWith(disposables);
|
||||
Observable.FromEventPattern<DeviceEventArgs>(x => rgbService.DeviceRemoved += x, x => rgbService.DeviceRemoved -= x)
|
||||
.Subscribe(d => RemoveDevice(d.EventArgs.Device))
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
Devices = new ObservableCollection<DeviceSettingsViewModel>();
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
GetDevices();
|
||||
public ObservableCollection<DeviceSettingsViewModel> Devices { get; }
|
||||
|
||||
Observable.FromEventPattern<DeviceEventArgs>(x => rgbService.DeviceAdded += x, x => rgbService.DeviceAdded -= x)
|
||||
.Subscribe(d => AddDevice(d.EventArgs.Device))
|
||||
.DisposeWith(disposables);
|
||||
Observable.FromEventPattern<DeviceEventArgs>(x => rgbService.DeviceRemoved += x, x => rgbService.DeviceRemoved -= x)
|
||||
.Subscribe(d => RemoveDevice(d.EventArgs.Device))
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
public async Task<bool> ShowDeviceDisableDialog()
|
||||
{
|
||||
if (_confirmedDisable)
|
||||
return true;
|
||||
|
||||
private void GetDevices()
|
||||
{
|
||||
Devices.Clear();
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Devices.AddRange(_rgbService.Devices.Select(d => _deviceVmFactory.DeviceSettingsViewModel(d, this)));
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
bool confirmed = await _windowService.ShowConfirmContentDialog(
|
||||
"Disabling device",
|
||||
"Disabling a device will cause it to stop updating. " +
|
||||
"\r\nSome SDKs will even go back to using manufacturer lighting (Artemis restart may be required)."
|
||||
);
|
||||
if (confirmed)
|
||||
_confirmedDisable = true;
|
||||
|
||||
public ObservableCollection<DeviceSettingsViewModel> Devices { get; }
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public async Task<bool> ShowDeviceDisableDialog()
|
||||
{
|
||||
if (_confirmedDisable)
|
||||
return true;
|
||||
private void GetDevices()
|
||||
{
|
||||
Devices.Clear();
|
||||
Dispatcher.UIThread.InvokeAsync(() => { Devices.AddRange(_rgbService.Devices.Select(d => _deviceVmFactory.DeviceSettingsViewModel(d, this))); }, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
bool confirmed = await _windowService.ShowConfirmContentDialog(
|
||||
"Disabling device",
|
||||
"Disabling a device will cause it to stop updating. " +
|
||||
"\r\nSome SDKs will even go back to using manufacturer lighting (Artemis restart may be required)."
|
||||
);
|
||||
if (confirmed)
|
||||
_confirmedDisable = true;
|
||||
private void AddDevice(ArtemisDevice device)
|
||||
{
|
||||
// If the device was only enabled, don't add it
|
||||
if (Devices.Any(d => d.Device == device))
|
||||
return;
|
||||
|
||||
return confirmed;
|
||||
}
|
||||
Devices.Add(_deviceVmFactory.DeviceSettingsViewModel(device, this));
|
||||
}
|
||||
|
||||
private void AddDevice(ArtemisDevice device)
|
||||
{
|
||||
// If the device was only enabled, don't add it
|
||||
if (Devices.Any(d => d.Device == device))
|
||||
return;
|
||||
private void RemoveDevice(ArtemisDevice device)
|
||||
{
|
||||
// If the device was only disabled don't remove it
|
||||
if (_rgbService.Devices.Contains(device))
|
||||
return;
|
||||
|
||||
Devices.Add(_deviceVmFactory.DeviceSettingsViewModel(device, this));
|
||||
}
|
||||
|
||||
private void RemoveDevice(ArtemisDevice device)
|
||||
{
|
||||
// If the device was only disabled don't remove it
|
||||
if (_rgbService.Devices.Contains(device))
|
||||
return;
|
||||
|
||||
DeviceSettingsViewModel? viewModel = Devices.FirstOrDefault(i => i.Device == device);
|
||||
if (viewModel != null)
|
||||
Devices.Remove(viewModel);
|
||||
}
|
||||
DeviceSettingsViewModel? viewModel = Devices.FirstOrDefault(i => i.Device == device);
|
||||
if (viewModel != null)
|
||||
Devices.Remove(viewModel);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public partial class GeneralTabView : ReactiveUserControl<GeneralTabViewModel>
|
||||
{
|
||||
public GeneralTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class GeneralTabView : ReactiveUserControl<GeneralTabViewModel>
|
||||
{
|
||||
public GeneralTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
@@ -22,199 +21,198 @@ using Ninject;
|
||||
using ReactiveUI;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
public class GeneralTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public class GeneralTabViewModel : ActivatableViewModelBase
|
||||
private readonly IAutoRunProvider? _autoRunProvider;
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly PluginSetting<LayerBrushReference> _defaultLayerBrushDescriptor;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IUpdateService _updateService;
|
||||
private readonly IWindowService _windowService;
|
||||
private bool _startupWizardOpen;
|
||||
|
||||
public GeneralTabViewModel(IKernel kernel,
|
||||
ISettingsService settingsService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
IDebugService debugService,
|
||||
IWindowService windowService,
|
||||
IUpdateService updateService)
|
||||
{
|
||||
private readonly PluginSetting<LayerBrushReference> _defaultLayerBrushDescriptor;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly IUpdateService _updateService;
|
||||
private readonly IAutoRunProvider? _autoRunProvider;
|
||||
private bool _startupWizardOpen;
|
||||
DisplayName = "General";
|
||||
_settingsService = settingsService;
|
||||
_debugService = debugService;
|
||||
_windowService = windowService;
|
||||
_updateService = updateService;
|
||||
_autoRunProvider = kernel.TryGet<IAutoRunProvider>();
|
||||
|
||||
public GeneralTabViewModel(IKernel kernel,
|
||||
ISettingsService settingsService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
IDebugService debugService,
|
||||
IWindowService windowService,
|
||||
IUpdateService updateService)
|
||||
List<LayerBrushProvider> layerBrushProviders = pluginManagementService.GetFeaturesOfType<LayerBrushProvider>();
|
||||
List<IGraphicsContextProvider> graphicsContextProviders = kernel.Get<List<IGraphicsContextProvider>>();
|
||||
LayerBrushDescriptors = new ObservableCollection<LayerBrushDescriptor>(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors));
|
||||
GraphicsContexts = new ObservableCollection<string> {"Software"};
|
||||
GraphicsContexts.AddRange(graphicsContextProviders.Select(p => p.GraphicsContextName));
|
||||
|
||||
_defaultLayerBrushDescriptor = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
|
||||
{
|
||||
DisplayName = "General";
|
||||
_settingsService = settingsService;
|
||||
_debugService = debugService;
|
||||
_windowService = windowService;
|
||||
_updateService = updateService;
|
||||
_autoRunProvider = kernel.TryGet<IAutoRunProvider>();
|
||||
LayerBrushProviderId = "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba",
|
||||
BrushType = "SolidBrush"
|
||||
});
|
||||
|
||||
List<LayerBrushProvider> layerBrushProviders = pluginManagementService.GetFeaturesOfType<LayerBrushProvider>();
|
||||
List<IGraphicsContextProvider> graphicsContextProviders = kernel.Get<List<IGraphicsContextProvider>>();
|
||||
LayerBrushDescriptors = new ObservableCollection<LayerBrushDescriptor>(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors));
|
||||
GraphicsContexts = new ObservableCollection<string> {"Software"};
|
||||
GraphicsContexts.AddRange(graphicsContextProviders.Select(p => p.GraphicsContextName));
|
||||
ShowLogs = ReactiveCommand.Create(ExecuteShowLogs);
|
||||
CheckForUpdate = ReactiveCommand.CreateFromTask(ExecuteCheckForUpdate);
|
||||
ShowSetupWizard = ReactiveCommand.CreateFromTask(ExecuteShowSetupWizard);
|
||||
ShowDebugger = ReactiveCommand.Create(ExecuteShowDebugger);
|
||||
ShowDataFolder = ReactiveCommand.Create(ExecuteShowDataFolder);
|
||||
|
||||
_defaultLayerBrushDescriptor = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
UIAutoRun.SettingChanged += UIAutoRunOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged += UIAutoRunDelayOnSettingChanged;
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(ApplyAutoRun);
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
LayerBrushProviderId = "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba",
|
||||
BrushType = "SolidBrush"
|
||||
});
|
||||
UIAutoRun.SettingChanged -= UIAutoRunOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged -= UIAutoRunDelayOnSettingChanged;
|
||||
|
||||
ShowLogs = ReactiveCommand.Create(ExecuteShowLogs);
|
||||
CheckForUpdate = ReactiveCommand.CreateFromTask(ExecuteCheckForUpdate);
|
||||
ShowSetupWizard = ReactiveCommand.CreateFromTask(ExecuteShowSetupWizard);
|
||||
ShowDebugger = ReactiveCommand.Create(ExecuteShowDebugger);
|
||||
ShowDataFolder = ReactiveCommand.Create(ExecuteShowDataFolder);
|
||||
_settingsService.SaveAllSettings();
|
||||
}).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
UIAutoRun.SettingChanged += UIAutoRunOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged += UIAutoRunDelayOnSettingChanged;
|
||||
public ReactiveCommand<Unit, Unit> ShowLogs { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckForUpdate { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowSetupWizard { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowDebugger { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowDataFolder { get; }
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(ApplyAutoRun);
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
UIAutoRun.SettingChanged -= UIAutoRunOnSettingChanged;
|
||||
UIAutoRunDelay.SettingChanged -= UIAutoRunDelayOnSettingChanged;
|
||||
|
||||
_settingsService.SaveAllSettings();
|
||||
}).DisposeWith(d);
|
||||
});
|
||||
public bool IsAutoRunSupported => _autoRunProvider != null;
|
||||
public bool IsUpdatingSupported => _updateService.UpdatingSupported;
|
||||
|
||||
public ObservableCollection<LayerBrushDescriptor> LayerBrushDescriptors { get; }
|
||||
public ObservableCollection<string> GraphicsContexts { get; }
|
||||
|
||||
public ObservableCollection<RenderSettingViewModel> RenderScales { get; } = new()
|
||||
{
|
||||
new RenderSettingViewModel("25%", 0.25),
|
||||
new RenderSettingViewModel("50%", 0.5),
|
||||
new RenderSettingViewModel("100%", 1)
|
||||
};
|
||||
|
||||
public ObservableCollection<RenderSettingViewModel> TargetFrameRates { get; } = new()
|
||||
{
|
||||
new RenderSettingViewModel("10 FPS", 10),
|
||||
new RenderSettingViewModel("20 FPS", 20),
|
||||
new RenderSettingViewModel("30 FPS", 30),
|
||||
new RenderSettingViewModel("45 FPS", 45),
|
||||
new RenderSettingViewModel("60 FPS (lol)", 60),
|
||||
new RenderSettingViewModel("144 FPS (omegalol)", 144)
|
||||
};
|
||||
|
||||
public LayerBrushDescriptor? SelectedLayerBrushDescriptor
|
||||
{
|
||||
get => LayerBrushDescriptors.FirstOrDefault(d => d.MatchesLayerBrushReference(_defaultLayerBrushDescriptor.Value));
|
||||
set
|
||||
{
|
||||
if (value != null) _defaultLayerBrushDescriptor.Value = new LayerBrushReference(value);
|
||||
}
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> ShowLogs { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckForUpdate { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowSetupWizard { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowDebugger { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowDataFolder { get; }
|
||||
|
||||
public bool IsAutoRunSupported => _autoRunProvider != null;
|
||||
public bool IsUpdatingSupported => _updateService.UpdatingSupported;
|
||||
|
||||
public ObservableCollection<LayerBrushDescriptor> LayerBrushDescriptors { get; }
|
||||
public ObservableCollection<string> GraphicsContexts { get; }
|
||||
|
||||
public ObservableCollection<RenderSettingViewModel> RenderScales { get; } = new()
|
||||
public RenderSettingViewModel? SelectedRenderScale
|
||||
{
|
||||
get => RenderScales.FirstOrDefault(s => Math.Abs(s.Value - CoreRenderScale.Value) < 0.01);
|
||||
set
|
||||
{
|
||||
new RenderSettingViewModel("25%", 0.25),
|
||||
new RenderSettingViewModel("50%", 0.5),
|
||||
new RenderSettingViewModel("100%", 1)
|
||||
};
|
||||
|
||||
public ObservableCollection<RenderSettingViewModel> TargetFrameRates { get; } = new()
|
||||
{
|
||||
new RenderSettingViewModel("10 FPS", 10),
|
||||
new RenderSettingViewModel("20 FPS", 20),
|
||||
new RenderSettingViewModel("30 FPS", 30),
|
||||
new RenderSettingViewModel("45 FPS", 45),
|
||||
new RenderSettingViewModel("60 FPS (lol)", 60),
|
||||
new RenderSettingViewModel("144 FPS (omegalol)", 144)
|
||||
};
|
||||
|
||||
public LayerBrushDescriptor? SelectedLayerBrushDescriptor
|
||||
{
|
||||
get => LayerBrushDescriptors.FirstOrDefault(d => d.MatchesLayerBrushReference(_defaultLayerBrushDescriptor.Value));
|
||||
set
|
||||
{
|
||||
if (value != null) _defaultLayerBrushDescriptor.Value = new LayerBrushReference(value);
|
||||
}
|
||||
if (value != null)
|
||||
CoreRenderScale.Value = value.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public RenderSettingViewModel? SelectedRenderScale
|
||||
public RenderSettingViewModel? SelectedTargetFrameRate
|
||||
{
|
||||
get => TargetFrameRates.FirstOrDefault(s => Math.Abs(s.Value - CoreTargetFrameRate.Value) < 0.01);
|
||||
set
|
||||
{
|
||||
get => RenderScales.FirstOrDefault(s => Math.Abs(s.Value - CoreRenderScale.Value) < 0.01);
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
CoreRenderScale.Value = value.Value;
|
||||
}
|
||||
if (value != null)
|
||||
CoreTargetFrameRate.Value = (int) value.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public RenderSettingViewModel? SelectedTargetFrameRate
|
||||
public PluginSetting<bool> UIAutoRun => _settingsService.GetSetting("UI.AutoRun", false);
|
||||
public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15);
|
||||
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
|
||||
public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.CheckForUpdates", true);
|
||||
public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.AutoUpdate", false);
|
||||
public PluginSetting<bool> ProfileEditorShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<LogEventLevel> CoreLoggingLevel => _settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Information);
|
||||
public PluginSetting<string> CorePreferredGraphicsContext => _settingsService.GetSetting("Core.PreferredGraphicsContext", "Software");
|
||||
public PluginSetting<double> CoreRenderScale => _settingsService.GetSetting("Core.RenderScale", 0.25);
|
||||
public PluginSetting<int> CoreTargetFrameRate => _settingsService.GetSetting("Core.TargetFrameRate", 30);
|
||||
public PluginSetting<int> WebServerPort => _settingsService.GetSetting("WebServer.Port", 9696);
|
||||
|
||||
private void ExecuteShowLogs()
|
||||
{
|
||||
Utilities.OpenFolder(Constants.LogsFolder);
|
||||
}
|
||||
|
||||
private async Task ExecuteCheckForUpdate(CancellationToken cancellationToken)
|
||||
{
|
||||
await _updateService.ManualUpdate();
|
||||
}
|
||||
|
||||
private async Task ExecuteShowSetupWizard()
|
||||
{
|
||||
_startupWizardOpen = true;
|
||||
await _windowService.ShowDialogAsync<StartupWizardViewModel, bool>();
|
||||
_startupWizardOpen = false;
|
||||
}
|
||||
|
||||
private void ExecuteShowDebugger()
|
||||
{
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
|
||||
private void ExecuteShowDataFolder()
|
||||
{
|
||||
Utilities.OpenFolder(Constants.DataFolder);
|
||||
}
|
||||
|
||||
private async Task ApplyAutoRun()
|
||||
{
|
||||
if (_autoRunProvider == null || _startupWizardOpen)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
get => TargetFrameRates.FirstOrDefault(s => Math.Abs(s.Value - CoreTargetFrameRate.Value) < 0.01);
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
CoreTargetFrameRate.Value = (int) value.Value;
|
||||
}
|
||||
if (UIAutoRun.Value)
|
||||
await _autoRunProvider.EnableAutoRun(false, UIAutoRunDelay.Value);
|
||||
else
|
||||
await _autoRunProvider.DisableAutoRun();
|
||||
}
|
||||
|
||||
public PluginSetting<bool> UIAutoRun => _settingsService.GetSetting("UI.AutoRun", false);
|
||||
public PluginSetting<int> UIAutoRunDelay => _settingsService.GetSetting("UI.AutoRunDelay", 15);
|
||||
public PluginSetting<bool> UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true);
|
||||
public PluginSetting<bool> UICheckForUpdates => _settingsService.GetSetting("UI.CheckForUpdates", true);
|
||||
public PluginSetting<bool> UIAutoUpdate => _settingsService.GetSetting("UI.AutoUpdate", false);
|
||||
public PluginSetting<bool> ProfileEditorShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<LogEventLevel> CoreLoggingLevel => _settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Information);
|
||||
public PluginSetting<string> CorePreferredGraphicsContext => _settingsService.GetSetting("Core.PreferredGraphicsContext", "Software");
|
||||
public PluginSetting<double> CoreRenderScale => _settingsService.GetSetting("Core.RenderScale", 0.25);
|
||||
public PluginSetting<int> CoreTargetFrameRate => _settingsService.GetSetting("Core.TargetFrameRate", 30);
|
||||
public PluginSetting<int> WebServerPort => _settingsService.GetSetting("WebServer.Port", 9696);
|
||||
|
||||
private void ExecuteShowLogs()
|
||||
catch (Exception exception)
|
||||
{
|
||||
Utilities.OpenFolder(Constants.LogsFolder);
|
||||
_windowService.ShowExceptionDialog("Failed to apply auto-run", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ExecuteCheckForUpdate(CancellationToken cancellationToken)
|
||||
private async void UIAutoRunOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
await ApplyAutoRun();
|
||||
}
|
||||
|
||||
private async void UIAutoRunDelayOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (_autoRunProvider == null || !UIAutoRun.Value || _startupWizardOpen)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await _updateService.ManualUpdate();
|
||||
await _autoRunProvider.EnableAutoRun(true, UIAutoRunDelay.Value);
|
||||
}
|
||||
|
||||
private async Task ExecuteShowSetupWizard()
|
||||
catch (Exception exception)
|
||||
{
|
||||
_startupWizardOpen = true;
|
||||
await _windowService.ShowDialogAsync<StartupWizardViewModel, bool>();
|
||||
_startupWizardOpen = false;
|
||||
}
|
||||
|
||||
private void ExecuteShowDebugger()
|
||||
{
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
|
||||
private void ExecuteShowDataFolder()
|
||||
{
|
||||
Utilities.OpenFolder(Constants.DataFolder);
|
||||
}
|
||||
|
||||
private async Task ApplyAutoRun()
|
||||
{
|
||||
if (_autoRunProvider == null || _startupWizardOpen)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (UIAutoRun.Value)
|
||||
await _autoRunProvider.EnableAutoRun(false, UIAutoRunDelay.Value);
|
||||
else
|
||||
await _autoRunProvider.DisableAutoRun();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_windowService.ShowExceptionDialog("Failed to apply auto-run", exception);
|
||||
}
|
||||
}
|
||||
|
||||
private async void UIAutoRunOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
await ApplyAutoRun();
|
||||
}
|
||||
|
||||
private async void UIAutoRunDelayOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (_autoRunProvider == null || !UIAutoRun.Value || _startupWizardOpen)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await _autoRunProvider.EnableAutoRun(true, UIAutoRunDelay.Value);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_windowService.ShowExceptionDialog("Failed to apply auto-run", exception);
|
||||
}
|
||||
_windowService.ShowExceptionDialog("Failed to apply auto-run", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public partial class PluginsTabView : ReactiveUserControl<PluginsTabViewModel>
|
||||
{
|
||||
public PluginsTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public class PluginsTabView : ReactiveUserControl<PluginsTabViewModel>
|
||||
{
|
||||
public PluginsTabView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Plugins;
|
||||
using Artemis.UI.Shared;
|
||||
@@ -18,106 +17,105 @@ using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
namespace Artemis.UI.Screens.Settings;
|
||||
|
||||
public class PluginsTabViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public class PluginsTabViewModel : ActivatableViewModelBase
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IWindowService _windowService;
|
||||
private string? _searchPluginInput;
|
||||
|
||||
public PluginsTabViewModel(IPluginManagementService pluginManagementService, INotificationService notificationService, IWindowService windowService, ISettingsVmFactory settingsVmFactory)
|
||||
{
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IWindowService _windowService;
|
||||
private string? _searchPluginInput;
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_notificationService = notificationService;
|
||||
_windowService = windowService;
|
||||
|
||||
public PluginsTabViewModel(IPluginManagementService pluginManagementService, INotificationService notificationService, IWindowService windowService, ISettingsVmFactory settingsVmFactory)
|
||||
DisplayName = "Plugins";
|
||||
|
||||
SourceList<Plugin> plugins = new();
|
||||
IObservable<Func<Plugin, bool>> pluginFilter = this.WhenAnyValue(vm => vm.SearchPluginInput).Throttle(TimeSpan.FromMilliseconds(100)).Select(CreatePredicate);
|
||||
|
||||
plugins.Connect()
|
||||
.Filter(pluginFilter)
|
||||
.Sort(SortExpressionComparer<Plugin>.Ascending(p => p.Info.Name))
|
||||
.Transform(settingsVmFactory.PluginSettingsViewModel)
|
||||
.ObserveOn(AvaloniaScheduler.Instance)
|
||||
.Bind(out ReadOnlyObservableCollection<PluginSettingsViewModel> pluginViewModels)
|
||||
.Subscribe();
|
||||
Plugins = pluginViewModels;
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_notificationService = notificationService;
|
||||
_windowService = windowService;
|
||||
Dispatcher.UIThread.Post(() => plugins.AddRange(_pluginManagementService.GetAllPlugins()), DispatcherPriority.Background);
|
||||
Observable.FromEventPattern<PluginEventArgs>(x => _pluginManagementService.PluginLoaded += x, x => _pluginManagementService.PluginLoaded -= x)
|
||||
.Subscribe(a => plugins.Add(a.EventArgs.Plugin))
|
||||
.DisposeWith(d);
|
||||
Observable.FromEventPattern<PluginEventArgs>(x => _pluginManagementService.PluginUnloaded += x, x => _pluginManagementService.PluginUnloaded -= x)
|
||||
.Subscribe(a => plugins.Remove(a.EventArgs.Plugin))
|
||||
.DisposeWith(d);
|
||||
Disposable.Create(() => plugins.Clear()).DisposeWith(d);
|
||||
});
|
||||
ImportPlugin = ReactiveCommand.CreateFromTask(ExecuteImportPlugin);
|
||||
}
|
||||
|
||||
DisplayName = "Plugins";
|
||||
public ReadOnlyObservableCollection<PluginSettingsViewModel> Plugins { get; }
|
||||
public ReactiveCommand<Unit, Unit> ImportPlugin { get; }
|
||||
|
||||
SourceList<Plugin> plugins = new();
|
||||
IObservable<Func<Plugin, bool>> pluginFilter = this.WhenAnyValue(vm => vm.SearchPluginInput).Throttle(TimeSpan.FromMilliseconds(100)).Select(CreatePredicate);
|
||||
public string? SearchPluginInput
|
||||
{
|
||||
get => _searchPluginInput;
|
||||
set => RaiseAndSetIfChanged(ref _searchPluginInput, value);
|
||||
}
|
||||
|
||||
plugins.Connect()
|
||||
.Filter(pluginFilter)
|
||||
.Sort(SortExpressionComparer<Plugin>.Ascending(p => p.Info.Name))
|
||||
.Transform(settingsVmFactory.PluginSettingsViewModel)
|
||||
.ObserveOn(AvaloniaScheduler.Instance)
|
||||
.Bind(out ReadOnlyObservableCollection<PluginSettingsViewModel> pluginViewModels)
|
||||
.Subscribe();
|
||||
Plugins = pluginViewModels;
|
||||
public void OpenUrl(string url)
|
||||
{
|
||||
Utilities.OpenUrl(url);
|
||||
}
|
||||
|
||||
this.WhenActivated(d =>
|
||||
private async Task ExecuteImportPlugin()
|
||||
{
|
||||
string[]? files = await _windowService.CreateOpenFileDialog().WithTitle("Import Artemis plugin").HavingFilter(f => f.WithExtension("zip").WithName("ZIP files")).ShowAsync();
|
||||
if (files == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Plugin? plugin = _pluginManagementService.ImportPlugin(files[0]);
|
||||
if (plugin == null)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => plugins.AddRange(_pluginManagementService.GetAllPlugins()), DispatcherPriority.Background);
|
||||
Observable.FromEventPattern<PluginEventArgs>(x => _pluginManagementService.PluginLoaded += x, x => _pluginManagementService.PluginLoaded -= x)
|
||||
.Subscribe(a => plugins.Add(a.EventArgs.Plugin))
|
||||
.DisposeWith(d);
|
||||
Observable.FromEventPattern<PluginEventArgs>(x => _pluginManagementService.PluginUnloaded += x, x => _pluginManagementService.PluginUnloaded -= x)
|
||||
.Subscribe(a => plugins.Remove(a.EventArgs.Plugin))
|
||||
.DisposeWith(d);
|
||||
Disposable.Create(() => plugins.Clear()).DisposeWith(d);
|
||||
});
|
||||
ImportPlugin = ReactiveCommand.CreateFromTask(ExecuteImportPlugin);
|
||||
}
|
||||
|
||||
public ReadOnlyObservableCollection<PluginSettingsViewModel> Plugins { get; }
|
||||
public ReactiveCommand<Unit, Unit> ImportPlugin { get; }
|
||||
|
||||
public string? SearchPluginInput
|
||||
{
|
||||
get => _searchPluginInput;
|
||||
set => RaiseAndSetIfChanged(ref _searchPluginInput, value);
|
||||
}
|
||||
|
||||
public void OpenUrl(string url)
|
||||
{
|
||||
Utilities.OpenUrl(url);
|
||||
}
|
||||
|
||||
private async Task ExecuteImportPlugin()
|
||||
{
|
||||
string[]? files = await _windowService.CreateOpenFileDialog().WithTitle("Import Artemis plugin").HavingFilter(f => f.WithExtension("zip").WithName("ZIP files")).ShowAsync();
|
||||
if (files == null)
|
||||
await _windowService.ShowConfirmContentDialog("Failed to import plugin", "Make sure it is compatible with the current platform.", "Close", null);
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Plugin? plugin = _pluginManagementService.ImportPlugin(files[0]);
|
||||
if (plugin == null)
|
||||
{
|
||||
await _windowService.ShowConfirmContentDialog("Failed to import plugin", "Make sure it is compatible with the current platform.", "Close", null);
|
||||
return;
|
||||
}
|
||||
|
||||
SearchPluginInput = plugin.Info.Name;
|
||||
|
||||
// Wait for the VM to be created asynchronously (it would be better to respond to some event here)
|
||||
await Task.Delay(200);
|
||||
// Enable it via the VM to enable the prerequisite dialog
|
||||
PluginSettingsViewModel? settingsViewModel = Plugins.FirstOrDefault(i => i.PluginViewModel.Plugin == plugin);
|
||||
if (settingsViewModel != null && !settingsViewModel.PluginViewModel.IsEnabled)
|
||||
await settingsViewModel.PluginViewModel.UpdateEnabled(true);
|
||||
|
||||
_notificationService.CreateNotification()
|
||||
.WithTitle("Plugin imported")
|
||||
.WithMessage($"Added the '{plugin.Info.Name}' plugin")
|
||||
.WithSeverity(NotificationSeverity.Success)
|
||||
.Show();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _windowService.ShowConfirmContentDialog("Failed to import plugin", "Make sure the selected ZIP file is a valid Artemis plugin.\r\n" + e.Message, "Close", null);
|
||||
}
|
||||
|
||||
SearchPluginInput = plugin.Info.Name;
|
||||
|
||||
// Wait for the VM to be created asynchronously (it would be better to respond to some event here)
|
||||
await Task.Delay(200);
|
||||
// Enable it via the VM to enable the prerequisite dialog
|
||||
PluginSettingsViewModel? settingsViewModel = Plugins.FirstOrDefault(i => i.PluginViewModel.Plugin == plugin);
|
||||
if (settingsViewModel != null && !settingsViewModel.PluginViewModel.IsEnabled)
|
||||
await settingsViewModel.PluginViewModel.UpdateEnabled(true);
|
||||
|
||||
_notificationService.CreateNotification()
|
||||
.WithTitle("Plugin imported")
|
||||
.WithMessage($"Added the '{plugin.Info.Name}' plugin")
|
||||
.WithSeverity(NotificationSeverity.Success)
|
||||
.Show();
|
||||
}
|
||||
|
||||
private Func<Plugin, bool> CreatePredicate(string? text)
|
||||
catch (Exception e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return _ => true;
|
||||
|
||||
return data => data.Info.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase) ||
|
||||
(data.Info.Description != null && data.Info.Description.Contains(text, StringComparison.InvariantCultureIgnoreCase));
|
||||
await _windowService.ShowConfirmContentDialog("Failed to import plugin", "Make sure the selected ZIP file is a valid Artemis plugin.\r\n" + e.Message, "Close", null);
|
||||
}
|
||||
}
|
||||
|
||||
private Func<Plugin, bool> CreatePredicate(string? text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return _ => true;
|
||||
|
||||
return data => data.Info.Name.Contains(text, StringComparison.InvariantCultureIgnoreCase) ||
|
||||
(data.Info.Description != null && data.Info.Description.Contains(text, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user