mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Updating - Added UI for updating (actual update not yet implemented)
Shared UI - Added message service for easy access to the snackbar 🍟
This commit is contained in:
1 parent
45fef11a67
commit
883fccef7b
21 files changed
+777
-54
No files matched your search
@@ -8,16 +8,15 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs
|
||||
{
|
||||
public class ProfileExportViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly ISnackbarMessageQueue _mainMessageQueue;
|
||||
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IMessageService _messageService;
|
||||
|
||||
public ProfileExportViewModel(ProfileDescriptor profileDescriptor, IProfileService profileService, ISnackbarMessageQueue mainMessageQueue)
|
||||
public ProfileExportViewModel(ProfileDescriptor profileDescriptor, IProfileService profileService, IMessageService messageService)
|
||||
{
|
||||
ProfileDescriptor = profileDescriptor;
|
||||
|
||||
_profileService = profileService;
|
||||
_mainMessageQueue = mainMessageQueue;
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
public ProfileDescriptor ProfileDescriptor { get; }
|
||||
@@ -26,7 +25,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs
|
||||
{
|
||||
string encoded = _profileService.ExportProfile(ProfileDescriptor);
|
||||
Clipboard.SetText(encoded);
|
||||
_mainMessageQueue.Enqueue("Profile contents exported to clipboard.");
|
||||
_messageService.ShowMessage("Profile contents exported to clipboard.");
|
||||
|
||||
Session.Close();
|
||||
}
|
||||
|
||||
@@ -11,15 +11,16 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs
|
||||
{
|
||||
private readonly ISnackbarMessageQueue _mainMessageQueue;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IMessageService _messageService;
|
||||
private string _profileJson;
|
||||
|
||||
public ProfileImportViewModel(ProfileModule profileModule, IProfileService profileService, ISnackbarMessageQueue mainMessageQueue)
|
||||
public ProfileImportViewModel(ProfileModule profileModule, IProfileService profileService, IMessageService messageService)
|
||||
{
|
||||
ProfileModule = profileModule;
|
||||
Document = new TextDocument();
|
||||
|
||||
_profileService = profileService;
|
||||
_mainMessageQueue = mainMessageQueue;
|
||||
_messageService = messageService;
|
||||
}
|
||||
|
||||
public ProfileModule ProfileModule { get; }
|
||||
@@ -34,7 +35,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs
|
||||
public void Accept()
|
||||
{
|
||||
ProfileDescriptor descriptor = _profileService.ImportProfile(Document.Text, ProfileModule);
|
||||
_mainMessageQueue.Enqueue("Profile imported.");
|
||||
_messageService.ShowMessage("Profile imported.");
|
||||
Session.Close(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
public class ProfileEditorViewModel : Screen
|
||||
{
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
|
||||
private PluginSetting<GridLength> _bottomPanelsHeight;
|
||||
private PluginSetting<GridLength> _dataModelConditionsHeight;
|
||||
private DisplayConditionsViewModel _displayConditionsViewModel;
|
||||
@@ -47,13 +47,13 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
IDialogService dialogService,
|
||||
ISettingsService settingsService,
|
||||
IModuleService moduleService,
|
||||
ISnackbarMessageQueue snackbarMessageQueue)
|
||||
IMessageService messageService)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_profileService = profileService;
|
||||
_settingsService = settingsService;
|
||||
_moduleService = moduleService;
|
||||
_snackbarMessageQueue = snackbarMessageQueue;
|
||||
_messageService = messageService;
|
||||
|
||||
DisplayName = "PROFILE EDITOR";
|
||||
Module = module;
|
||||
@@ -242,7 +242,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
|
||||
if (!_profileEditorService.UndoUpdateProfile())
|
||||
{
|
||||
_snackbarMessageQueue.Enqueue("Nothing to undo");
|
||||
_messageService.ShowMessage("Nothing to undo");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
focusedElement?.Focus();
|
||||
});
|
||||
|
||||
_snackbarMessageQueue.Enqueue("Undid profile update", "REDO", Redo);
|
||||
_messageService.ShowMessage("Undid profile update", "REDO", Redo);
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
@@ -269,7 +269,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
|
||||
if (!_profileEditorService.RedoUpdateProfile())
|
||||
{
|
||||
_snackbarMessageQueue.Enqueue("Nothing to redo");
|
||||
_messageService.ShowMessage("Nothing to redo");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
focusedElement?.Focus();
|
||||
});
|
||||
|
||||
_snackbarMessageQueue.Enqueue("Redid profile update", "UNDO", Undo);
|
||||
_messageService.ShowMessage("Redid profile update", "UNDO", Undo);
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
|
||||
@@ -14,6 +14,7 @@ using Artemis.UI.Screens.Sidebar;
|
||||
using Artemis.UI.Screens.StartupWizard;
|
||||
using Artemis.UI.Services;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Utilities;
|
||||
using MaterialDesignExtensions.Controls;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
@@ -25,6 +26,7 @@ namespace Artemis.UI.Screens
|
||||
public sealed class RootViewModel : Conductor<IScreen>, IDisposable
|
||||
{
|
||||
private readonly IRegistrationService _builtInRegistrationService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
@@ -34,7 +36,6 @@ namespace Artemis.UI.Screens
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly Timer _frameTimeUpdateTimer;
|
||||
private readonly SidebarViewModel _sidebarViewModel;
|
||||
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
|
||||
private readonly ThemeWatcher _themeWatcher;
|
||||
private readonly PluginSetting<WindowSize> _windowSize;
|
||||
private bool _activeItemReady;
|
||||
@@ -52,7 +53,7 @@ namespace Artemis.UI.Screens
|
||||
IWindowManager windowManager,
|
||||
IDebugService debugService,
|
||||
IRegistrationService builtInRegistrationService,
|
||||
ISnackbarMessageQueue snackbarMessageQueue,
|
||||
IMessageService messageService,
|
||||
SidebarViewModel sidebarViewModel)
|
||||
{
|
||||
_kernel = kernel;
|
||||
@@ -62,7 +63,7 @@ namespace Artemis.UI.Screens
|
||||
_windowManager = windowManager;
|
||||
_debugService = debugService;
|
||||
_builtInRegistrationService = builtInRegistrationService;
|
||||
_snackbarMessageQueue = snackbarMessageQueue;
|
||||
_messageService = messageService;
|
||||
_sidebarViewModel = sidebarViewModel;
|
||||
_frameTimeUpdateTimer = new Timer(500);
|
||||
|
||||
@@ -79,7 +80,7 @@ namespace Artemis.UI.Screens
|
||||
PinSidebar = _settingsService.GetSetting("UI.PinSidebar", false);
|
||||
|
||||
AssemblyInformationalVersionAttribute versionAttribute = typeof(RootViewModel).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||
WindowTitle = $"Artemis {versionAttribute?.InformationalVersion}";
|
||||
WindowTitle = $"Artemis {versionAttribute?.InformationalVersion} build {Constants.BuildInfo.BuildNumber}";
|
||||
}
|
||||
|
||||
public PluginSetting<bool> PinSidebar { get; }
|
||||
@@ -275,7 +276,7 @@ namespace Artemis.UI.Screens
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
MainMessageQueue = _snackbarMessageQueue;
|
||||
MainMessageQueue = _messageService.MainMessageQueue;
|
||||
UpdateFrameTime();
|
||||
|
||||
_builtInRegistrationService.RegisterBuiltInDataModelDisplays();
|
||||
@@ -295,7 +296,7 @@ namespace Artemis.UI.Screens
|
||||
PluginSetting<bool> setupWizardCompleted = _settingsService.GetSetting("UI.SetupWizardCompleted", false);
|
||||
if (!setupWizardCompleted.Value)
|
||||
ShowSetupWizard();
|
||||
|
||||
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,76 @@
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Update settings -->
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="0 15">Updating</TextBlock>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
<StackPanel Margin="15">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Check for updates</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" TextWrapping="Wrap">
|
||||
If enabled, we'll check for updates on startup and periodically while running.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding CheckForUpdates}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Automatically install updates</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" TextWrapping="Wrap">
|
||||
If enabled updates are installed automatically without asking first.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding AutoInstallUpdates}" IsEnabled="{Binding CheckForUpdates}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Update</TextBlock>
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}">
|
||||
Use the button on the right to check for updates now.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action OfferUpdatesIfFound}" Width="150">
|
||||
CHECK NOW
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Profile editor settings -->
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="0 15">Profile editor</TextBlock>
|
||||
<materialDesign:Card materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Margin="0,0,5,0">
|
||||
|
||||
@@ -8,9 +8,11 @@ using Artemis.Core;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.StartupWizard;
|
||||
using Artemis.UI.Services;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject;
|
||||
using Serilog.Events;
|
||||
using Stylet;
|
||||
@@ -24,18 +26,23 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
private readonly IWindowManager _windowManager;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IUpdateService _updateService;
|
||||
private readonly IMessageService _messageService;
|
||||
private List<Tuple<string, double>> _renderScales;
|
||||
private List<int> _sampleSizes;
|
||||
private List<Tuple<string, int>> _targetFrameRates;
|
||||
private readonly PluginSetting<LayerBrushReference> _defaultLayerBrushDescriptor;
|
||||
private bool _canOfferUpdatesIfFound = true;
|
||||
|
||||
public GeneralSettingsTabViewModel(
|
||||
IKernel kernel,
|
||||
IWindowManager windowManager,
|
||||
IDialogService dialogService,
|
||||
IKernel kernel,
|
||||
IWindowManager windowManager,
|
||||
IDialogService dialogService,
|
||||
IDebugService debugService,
|
||||
ISettingsService settingsService,
|
||||
IPluginManagementService pluginManagementService)
|
||||
ISettingsService settingsService,
|
||||
IUpdateService updateService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
IMessageService messageService)
|
||||
{
|
||||
DisplayName = "GENERAL";
|
||||
|
||||
@@ -44,6 +51,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
_dialogService = dialogService;
|
||||
_debugService = debugService;
|
||||
_settingsService = settingsService;
|
||||
_updateService = updateService;
|
||||
_messageService = messageService;
|
||||
|
||||
LogLevels = new BindableCollection<ValueDescription>(EnumUtilities.GetAllValuesAndDescriptions(typeof(LogEventLevel)));
|
||||
ColorSchemes = new BindableCollection<ValueDescription>(EnumUtilities.GetAllValuesAndDescriptions(typeof(ApplicationColorScheme)));
|
||||
@@ -124,6 +133,31 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckForUpdates
|
||||
{
|
||||
get => _settingsService.GetSetting("UI.CheckForUpdates", true).Value;
|
||||
set
|
||||
{
|
||||
_settingsService.GetSetting("UI.CheckForUpdates", true).Value = value;
|
||||
_settingsService.GetSetting("UI.CheckForUpdates", true).Save();
|
||||
NotifyOfPropertyChange(nameof(CheckForUpdates));
|
||||
|
||||
if (!value)
|
||||
AutoInstallUpdates = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutoInstallUpdates
|
||||
{
|
||||
get => _settingsService.GetSetting("UI.AutoInstallUpdates", false).Value;
|
||||
set
|
||||
{
|
||||
_settingsService.GetSetting("UI.AutoInstallUpdates", false).Value = value;
|
||||
_settingsService.GetSetting("UI.AutoInstallUpdates", false).Save();
|
||||
NotifyOfPropertyChange(nameof(AutoInstallUpdates));
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowDataModelValues
|
||||
{
|
||||
get => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false).Value;
|
||||
@@ -196,6 +230,12 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanOfferUpdatesIfFound
|
||||
{
|
||||
get => _canOfferUpdatesIfFound;
|
||||
set => SetAndNotify(ref _canOfferUpdatesIfFound, value);
|
||||
}
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
_debugService.ShowDebugger();
|
||||
@@ -230,6 +270,20 @@ namespace Artemis.UI.Screens.Settings.Tabs.General
|
||||
}
|
||||
}
|
||||
|
||||
public async void OfferUpdatesIfFound()
|
||||
{
|
||||
if (!CanOfferUpdatesIfFound)
|
||||
return;
|
||||
|
||||
CanOfferUpdatesIfFound = false;
|
||||
bool updateFound = await _updateService.OfferUpdatesIfFound();
|
||||
if (!updateFound)
|
||||
_messageService.ShowMessage("You are already running the latest Artemis build. (☞゚ヮ゚)☞");
|
||||
else
|
||||
_messageService.ShowMessage("You are already running the latest Artemis build. (☞゚ヮ゚)☞");
|
||||
CanOfferUpdatesIfFound = true;
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
Task.Run(ApplyAutorun);
|
||||
|
||||
@@ -20,17 +20,17 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
|
||||
private IMessageService _messageService;
|
||||
private bool _enabling;
|
||||
|
||||
|
||||
public PluginFeatureViewModel(PluginFeature feature,
|
||||
IDialogService dialogService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
ISnackbarMessageQueue snackbarMessageQueue)
|
||||
IMessageService messageService)
|
||||
{
|
||||
_dialogService = dialogService;
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_snackbarMessageQueue = snackbarMessageQueue;
|
||||
_messageService = messageService;
|
||||
|
||||
Feature = feature;
|
||||
Icon = GetIconKind();
|
||||
@@ -109,7 +109,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_snackbarMessageQueue.Enqueue($"Failed to enable {Name}\r\n{e.Message}", "VIEW LOGS", ShowLogsFolder);
|
||||
_messageService.ShowMessage($"Failed to enable {Name}\r\n{e.Message}", "VIEW LOGS", ShowLogsFolder);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly ISettingsVmFactory _settingsVmFactory;
|
||||
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private bool _enabling;
|
||||
private Plugin _plugin;
|
||||
@@ -29,7 +29,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
IWindowManager windowManager,
|
||||
IDialogService dialogService,
|
||||
IPluginManagementService pluginManagementService,
|
||||
ISnackbarMessageQueue snackbarMessageQueue)
|
||||
IMessageService messageService)
|
||||
{
|
||||
Plugin = plugin;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
_windowManager = windowManager;
|
||||
_dialogService = dialogService;
|
||||
_pluginManagementService = pluginManagementService;
|
||||
_snackbarMessageQueue = snackbarMessageQueue;
|
||||
_messageService = messageService;
|
||||
|
||||
Icon = PluginUtilities.GetPluginIcon(Plugin, Plugin.Info.Icon);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_snackbarMessageQueue.Enqueue($"Failed to enable plugin {Plugin.Info.Name}\r\n{e.Message}", "VIEW LOGS", ShowLogsFolder);
|
||||
_messageService.ShowMessage($"Failed to enable plugin {Plugin.Info.Name}\r\n{e.Message}", "VIEW LOGS", ShowLogsFolder);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -13,17 +13,17 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
public class SurfaceDeviceDetectInputViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly IInputService _inputService;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly ListLedGroup _ledGroup;
|
||||
private readonly ISnackbarMessageQueue _mainMessageQueue;
|
||||
|
||||
public SurfaceDeviceDetectInputViewModel(ArtemisDevice device, IInputService inputService, ISnackbarMessageQueue mainMessageQueue)
|
||||
public SurfaceDeviceDetectInputViewModel(ArtemisDevice device, IInputService inputService, IMessageService messageService)
|
||||
{
|
||||
Device = device;
|
||||
Title = $"{Device.RgbDevice.DeviceInfo.DeviceName} - Detect input";
|
||||
IsMouse = Device.RgbDevice.DeviceInfo.DeviceType == RGBDeviceType.Mouse;
|
||||
|
||||
_inputService = inputService;
|
||||
_mainMessageQueue = mainMessageQueue;
|
||||
_messageService = messageService;
|
||||
_inputService.IdentifyDevice(Device);
|
||||
_inputService.DeviceIdentified += InputServiceOnDeviceIdentified;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
private void InputServiceOnDeviceIdentified(object sender, EventArgs e)
|
||||
{
|
||||
Session?.Close(true);
|
||||
_mainMessageQueue.Enqueue($"{Device.RgbDevice.DeviceInfo.DeviceName} identified 😁");
|
||||
_messageService.ShowMessage($"{Device.RgbDevice.DeviceInfo.DeviceName} identified 😁");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
using Artemis.Core.Services;
|
||||
using System;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Splash;
|
||||
using Artemis.UI.Services;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Ninject;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens
|
||||
{
|
||||
public class TrayViewModel : Screen
|
||||
public class TrayViewModel : Screen, IMainWindowManager
|
||||
{
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
@@ -15,8 +18,16 @@ namespace Artemis.UI.Screens
|
||||
private readonly IWindowManager _windowManager;
|
||||
private bool _canShowRootViewModel;
|
||||
private SplashViewModel _splashViewModel;
|
||||
private RootViewModel _rootViewModel;
|
||||
|
||||
public TrayViewModel(IKernel kernel, IWindowManager windowManager, IEventAggregator eventAggregator, ICoreService coreService, IDebugService debugService, ISettingsService settingsService)
|
||||
public TrayViewModel(IKernel kernel,
|
||||
IWindowManager windowManager,
|
||||
IWindowService windowService,
|
||||
IUpdateService updateService,
|
||||
IEventAggregator eventAggregator,
|
||||
ICoreService coreService,
|
||||
IDebugService debugService,
|
||||
ISettingsService settingsService)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_windowManager = windowManager;
|
||||
@@ -24,13 +35,16 @@ namespace Artemis.UI.Screens
|
||||
_debugService = debugService;
|
||||
CanShowRootViewModel = true;
|
||||
|
||||
windowService.ConfigureMainWindowManager(this);
|
||||
bool autoRunning = Bootstrapper.StartupArguments.Contains("--autorun");
|
||||
bool showOnAutoRun = settingsService.GetSetting("UI.ShowOnStartup", true).Value;
|
||||
if (!autoRunning || showOnAutoRun)
|
||||
{
|
||||
ShowSplashScreen();
|
||||
coreService.Initialized += (sender, args) => TrayBringToForeground();
|
||||
coreService.Initialized += (_, _) => TrayBringToForeground();
|
||||
}
|
||||
|
||||
updateService.AutoUpdate();
|
||||
}
|
||||
|
||||
public bool CanShowRootViewModel
|
||||
@@ -53,10 +67,12 @@ namespace Artemis.UI.Screens
|
||||
{
|
||||
_splashViewModel?.RequestClose();
|
||||
_splashViewModel = null;
|
||||
RootViewModel rootViewModel = _kernel.Get<RootViewModel>();
|
||||
rootViewModel.Closed += RootViewModelOnClosed;
|
||||
_windowManager.ShowWindow(rootViewModel);
|
||||
_rootViewModel = _kernel.Get<RootViewModel>();
|
||||
_rootViewModel.Closed += RootViewModelOnClosed;
|
||||
_windowManager.ShowWindow(_rootViewModel);
|
||||
});
|
||||
|
||||
OnMainWindowOpened();
|
||||
}
|
||||
|
||||
public void TrayActivateSidebarItem(string sidebarItem)
|
||||
@@ -86,7 +102,53 @@ namespace Artemis.UI.Screens
|
||||
|
||||
private void RootViewModelOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
_rootViewModel.Closed -= RootViewModelOnClosed;
|
||||
_rootViewModel = null;
|
||||
|
||||
CanShowRootViewModel = true;
|
||||
OnMainWindowClosed();
|
||||
}
|
||||
|
||||
#region Implementation of IMainWindowManager
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsMainWindowOpen { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool OpenMainWindow()
|
||||
{
|
||||
if (CanShowRootViewModel)
|
||||
return false;
|
||||
|
||||
TrayBringToForeground();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool CloseMainWindow()
|
||||
{
|
||||
_rootViewModel.RequestClose();
|
||||
return _rootViewModel.ScreenState == ScreenState.Closed;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler MainWindowOpened;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler MainWindowClosed;
|
||||
|
||||
protected virtual void OnMainWindowOpened()
|
||||
{
|
||||
IsMainWindowOpen = true;
|
||||
MainWindowOpened?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnMainWindowClosed()
|
||||
{
|
||||
IsMainWindowOpen = false;
|
||||
MainWindowClosed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user