From 7954012e31e8d82f003b5d552556e0c8912ee9bc Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 9 Nov 2021 22:16:57 +0100 Subject: [PATCH] Settings - Added most of the plugins tab --- .../ViewModels/PluginSettingsViewModel.cs | 15 +-- .../Plugins/Views/PluginSettingsView.axaml | 115 +++++++++++++++++- .../Styles/TextBlock.axaml | 3 + 3 files changed, 123 insertions(+), 10 deletions(-) diff --git a/src/Artemis.UI.Avalonia/Screens/Plugins/ViewModels/PluginSettingsViewModel.cs b/src/Artemis.UI.Avalonia/Screens/Plugins/ViewModels/PluginSettingsViewModel.cs index 9263ba867..3dbad61ee 100644 --- a/src/Artemis.UI.Avalonia/Screens/Plugins/ViewModels/PluginSettingsViewModel.cs +++ b/src/Artemis.UI.Avalonia/Screens/Plugins/ViewModels/PluginSettingsViewModel.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; +using System.Reactive; +using System.Reactive.Linq; using System.Threading.Tasks; using Artemis.Core; using Artemis.Core.Services; @@ -49,8 +51,12 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels _pluginManagementService.PluginDisabled += PluginManagementServiceOnPluginToggled; _pluginManagementService.PluginEnabled += PluginManagementServiceOnPluginToggled; + + OpenSettings = ReactiveCommand.Create(ExecuteOpenSettings, this.WhenAnyValue(x => x.IsEnabled).Select(isEnabled => isEnabled && Plugin.ConfigurationDialog != null)); } + public ReactiveCommand OpenSettings { get; } + public ObservableCollection PluginFeatures { get; } public Plugin Plugin @@ -66,8 +72,7 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels } public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name; - public bool CanOpenSettings => IsEnabled && Plugin.ConfigurationDialog != null; - + public bool IsEnabled { get => Plugin.IsEnabled; @@ -96,7 +101,7 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels set => this.RaiseAndSetIfChanged(ref _canRemovePrerequisites, value); } - public void OpenSettings() + private void ExecuteOpenSettings() { if (Plugin.ConfigurationDialog == null) return; @@ -163,7 +168,6 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels { await PluginPrerequisitesUninstallDialogViewModel.Show(_windowService, subjects, forPluginRemoval ? "Skip, remove plugin" : "Cancel"); this.RaisePropertyChanged(nameof(IsEnabled)); - this.RaisePropertyChanged(nameof(CanOpenSettings)); } } @@ -242,7 +246,6 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels private void PluginManagementServiceOnPluginToggled(object? sender, PluginEventArgs e) { this.RaisePropertyChanged(nameof(IsEnabled)); - this.RaisePropertyChanged(nameof(CanOpenSettings)); } private async Task UpdateEnabled(bool enable) @@ -306,14 +309,12 @@ namespace Artemis.UI.Avalonia.Screens.Plugins.ViewModels } this.RaisePropertyChanged(nameof(IsEnabled)); - this.RaisePropertyChanged(nameof(CanOpenSettings)); } private void CancelEnable() { Enabling = false; this.RaisePropertyChanged(nameof(IsEnabled)); - this.RaisePropertyChanged(nameof(CanOpenSettings)); } private void CheckPrerequisites() diff --git a/src/Artemis.UI.Avalonia/Screens/Plugins/Views/PluginSettingsView.axaml b/src/Artemis.UI.Avalonia/Screens/Plugins/Views/PluginSettingsView.axaml index f66ae98a1..279feab3c 100644 --- a/src/Artemis.UI.Avalonia/Screens/Plugins/Views/PluginSettingsView.axaml +++ b/src/Artemis.UI.Avalonia/Screens/Plugins/Views/PluginSettingsView.axaml @@ -2,7 +2,116 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" + xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" + mc:Ignorable="d" d:DesignWidth="900" d:DesignHeight="450" x:Class="Artemis.UI.Avalonia.Screens.Plugins.Views.PluginSettingsView"> - Welcome to Avalonia! - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plugin enabled + + + + + + + + + + Plugin features + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI.Avalonia/Styles/TextBlock.axaml b/src/Artemis.UI.Avalonia/Styles/TextBlock.axaml index facc8aa6f..4a2a605e2 100644 --- a/src/Artemis.UI.Avalonia/Styles/TextBlock.axaml +++ b/src/Artemis.UI.Avalonia/Styles/TextBlock.axaml @@ -39,6 +39,9 @@ +