1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Plugins - Separated VMs into folders

Plugins - Added help pages
This commit is contained in:
Robert 2023-04-13 17:41:54 +02:00
parent 2f270c9c03
commit b59e898dd3
29 changed files with 350 additions and 43 deletions

View File

@ -48,17 +48,17 @@ public class ArtemisPluginException : Exception
/// <summary>
/// Creates a new instance of the <see cref="ArtemisPluginException" /> class
/// </summary>
public ArtemisPluginException(string message, string helpDocument) : base(message)
public ArtemisPluginException(string message, string helpPageId) : base(message)
{
HelpDocument = helpDocument;
HelpPageId = helpPageId;
}
/// <summary>
/// Creates a new instance of the <see cref="ArtemisPluginException" /> class
/// </summary>
public ArtemisPluginException(string message, Exception inner, string helpDocument) : base(message, inner)
public ArtemisPluginException(string message, Exception inner, string helpPageId) : base(message, inner)
{
HelpDocument = helpDocument;
HelpPageId = helpPageId;
}
/// <summary>
@ -67,8 +67,8 @@ public class ArtemisPluginException : Exception
public Plugin? Plugin { get; }
/// <summary>
/// Gets or sets the help document related to this exception.
/// Gets the ID of the help page to display for this exception.
/// </summary>
public string? HelpDocument { get; }
public string? HelpPageId { get; }
}

View File

@ -0,0 +1,22 @@
namespace Artemis.Core;
/// <summary>
/// Represents a plugin related help page
/// </summary>
public interface IPluginHelpPage
{
/// <summary>
/// Gets the plugin the help page belongs to.
/// </summary>
Plugin Plugin { get; }
/// <summary>
/// Gets the title of the help page.
/// </summary>
public string Title { get; }
/// <summary>
/// An ID used to quickly lead users to the help page in case of an error.
/// </summary>
public string Id { get; }
}

View File

@ -0,0 +1,41 @@
using System.IO;
namespace Artemis.Core;
/// <summary>
/// Represents a plugin related help page
/// </summary>
public class MarkdownPluginHelpPage : IPluginHelpPage
{
/// <summary>
/// Creates a new instance of the <see cref="MarkdownPluginHelpPage" /> class.
/// </summary>
/// <param name="plugin">The plugin to display the markdown for.</param>
/// <param name="markdownFile">A file path relative to the plugin or absolute, pointing to the markdown to display</param>
/// <param name="id">The ID of the help page, used to quickly lead users to it in case of errors.</param>
/// <exception cref="FileNotFoundException"></exception>
public MarkdownPluginHelpPage(Plugin plugin, string title, string id, string markdownFile)
{
Plugin = plugin;
Title = title;
Id = id;
MarkdownFile = Path.IsPathRooted(markdownFile) ? markdownFile : Plugin.ResolveRelativePath(markdownFile);
if (!File.Exists(MarkdownFile))
throw new FileNotFoundException($"Could not find markdown file at \"{MarkdownFile}\"");
}
/// <inheritdoc />
public Plugin Plugin { get; }
/// <inheritdoc />
public string Title { get; }
/// <inheritdoc />
public string Id { get; }
/// <summary>
/// Gets the absolute path to the markdown that is to be displayed.
/// </summary>
public string MarkdownFile { get; }
}

View File

@ -36,6 +36,7 @@ public class Plugin : CorePropertyChanged, IDisposable
Features = new ReadOnlyCollection<PluginFeatureInfo>(_features);
Profilers = new ReadOnlyCollection<Profiler>(_profilers);
HelpPages = new List<IPluginHelpPage>();
}
/// <summary>
@ -58,6 +59,8 @@ public class Plugin : CorePropertyChanged, IDisposable
/// </summary>
public IPluginConfigurationDialog? ConfigurationDialog { get; set; }
public List<IPluginHelpPage> HelpPages { get; }
/// <summary>
/// Indicates whether the user enabled the plugin or not
/// </summary>

View File

@ -52,5 +52,25 @@
<DependentUpon>UpdatingTabView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\Plugins\Help\MarkdownPluginHelpPageView.axaml.cs">
<DependentUpon>MarkdownPluginHelpPageView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\Plugins\Help\PluginHelpWindowView.axaml.cs">
<DependentUpon>PluginHelpWindowView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\Plugins\Features\PluginFeatureView.axaml.cs">
<DependentUpon>PluginFeatureView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\Plugins\Prerequisites\PluginPrerequisiteActionView.axaml.cs">
<DependentUpon>PluginPrerequisiteActionView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\Plugins\Prerequisites\PluginPrerequisiteView.axaml.cs">
<DependentUpon>PluginPrerequisiteView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -7,6 +7,8 @@ using Artemis.Core.LayerEffects;
using Artemis.Core.ScriptingProviders;
using Artemis.UI.Screens.Device;
using Artemis.UI.Screens.Plugins;
using Artemis.UI.Screens.Plugins.Features;
using Artemis.UI.Screens.Plugins.Prerequisites;
using Artemis.UI.Screens.ProfileEditor;
using Artemis.UI.Screens.ProfileEditor.DisplayCondition.ConditionTypes;
using Artemis.UI.Screens.ProfileEditor.ProfileTree;

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:prerequisites="clr-namespace:Artemis.UI.Screens.Plugins.Prerequisites"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginPrerequisitesInstallDialogView"
x:DataType="plugins:PluginPrerequisitesInstallDialogViewModel">
@ -34,7 +35,7 @@
SelectedItem="{CompiledBinding ActivePrerequisite, Mode=OneWay}"
IsHitTestVisible="False">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type plugins:PluginPrerequisiteViewModel}">
<DataTemplate DataType="{x:Type prerequisites:PluginPrerequisiteViewModel}">
<Grid ColumnDefinitions="Auto,*" Margin="0 6">
<Border Grid.Row="0" Grid.Column="0" Classes="status-border" IsVisible="{CompiledBinding !IsMet}" Background="#ff3838">
<avalonia:MaterialIcon Kind="Close" />

View File

@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Screens.Plugins.Prerequisites;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Avalonia.Threading;

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:prerequisites="clr-namespace:Artemis.UI.Screens.Plugins.Prerequisites"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginPrerequisitesUninstallDialogView"
x:DataType="plugins:PluginPrerequisitesUninstallDialogViewModel">
@ -34,7 +35,7 @@
SelectedItem="{CompiledBinding ActivePrerequisite, Mode=OneWay}"
IsHitTestVisible="False">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type plugins:PluginPrerequisiteViewModel}">
<DataTemplate DataType="{x:Type prerequisites:PluginPrerequisiteViewModel}">
<StackPanel Margin="0 6" VerticalAlignment="Stretch">
<TextBlock FontWeight="Bold" Text="{CompiledBinding PluginPrerequisite.Name}" TextWrapping="Wrap" />
<TextBlock Text="{CompiledBinding PluginPrerequisite.Description}" TextWrapping="Wrap" />

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Screens.Plugins.Prerequisites;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Avalonia.Threading;

View File

@ -5,9 +5,10 @@
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:features="clr-namespace:Artemis.UI.Screens.Plugins.Features"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginFeatureView"
x:DataType="plugins:PluginFeatureViewModel">
x:Class="Artemis.UI.Screens.Plugins.Features.PluginFeatureView"
x:DataType="features:PluginFeatureViewModel">
<Grid ColumnDefinitions="30,*,Auto">
<Grid.ContextFlyout>
<MenuFlyout>

View File

@ -1,7 +1,6 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins;
namespace Artemis.UI.Screens.Plugins.Features;
public partial class PluginFeatureView : ReactiveUserControl<PluginFeatureViewModel>
{

View File

@ -18,7 +18,7 @@ using Avalonia.Threading;
using Material.Icons;
using ReactiveUI;
namespace Artemis.UI.Screens.Plugins;
namespace Artemis.UI.Screens.Plugins.Features;
public class PluginFeatureViewModel : ActivatableViewModelBase
{

View File

@ -0,0 +1,27 @@
<UserControl xmlns="https://github.com/avaloniaui"
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"
xmlns:avalonia="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:ctxt="clr-namespace:ColorTextBlock.Avalonia;assembly=ColorTextBlock.Avalonia"
xmlns:help="clr-namespace:Artemis.UI.Screens.Plugins.Help"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.Help.MarkdownPluginHelpPageView"
x:DataType="help:MarkdownPluginHelpPageViewModel">
<avalonia:MarkdownScrollViewer Markdown="{CompiledBinding MarkdownText}" MarkdownStyleName="FluentAvalonia">
<avalonia:MarkdownScrollViewer.Styles>
<Style Selector="ctxt|CHyperlink">
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorLight3}" />
</Style>
<Style Selector="ctxt|CHyperlink:pointerover">
<Setter Property="Foreground" Value="{DynamicResource SystemAccentColorLight1}" />
</Style>
<Style Selector="Grid.List">
<Style.Setters>
<Setter Property="Margin" Value="20,0,0,0"/>
</Style.Setters>
</Style>
</avalonia:MarkdownScrollViewer.Styles>
</avalonia:MarkdownScrollViewer>
</UserControl>

View File

@ -0,0 +1,17 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Plugins.Help;
public partial class MarkdownPluginHelpPageView : UserControl
{
public MarkdownPluginHelpPageView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}

View File

@ -0,0 +1,40 @@
using System.IO;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.UI.Shared;
using ReactiveUI;
namespace Artemis.UI.Screens.Plugins.Help;
public class MarkdownPluginHelpPageViewModel : ActivatableViewModelBase, IPluginHelpPage
{
private string? _markdownText;
private readonly MarkdownPluginHelpPage _helpPage;
public MarkdownPluginHelpPageViewModel(MarkdownPluginHelpPage helpPage)
{
_helpPage = helpPage;
this.WhenActivated(d => Load().DisposeWith(d));
}
public string? MarkdownText
{
get => _markdownText;
set => RaiseAndSetIfChanged(ref _markdownText, value);
}
/// <inheritdoc />
public Plugin Plugin => _helpPage.Plugin;
/// <inheritdoc />
public string Title => _helpPage.Title;
/// <inheritdoc />
public string Id => _helpPage.Id;
private async Task Load()
{
MarkdownText ??= await File.ReadAllTextAsync(_helpPage.MarkdownFile);
}
}

View File

@ -0,0 +1,31 @@
<Window xmlns="https://github.com/avaloniaui"
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"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
xmlns:help="clr-namespace:Artemis.UI.Screens.Plugins.Help"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.Help.PluginHelpWindowView"
x:DataType="help:PluginHelpWindowViewModel"
Icon="/Assets/Images/Logo/application.ico"
Title="{CompiledBinding DisplayName}"
Width="800"
Height="800"
WindowStartupLocation="CenterOwner">
<Grid ColumnDefinitions="240,*">
<ListBox Items="{CompiledBinding HelpPages}" SelectedItem="{CompiledBinding SelectedHelpPage}" Grid.Column="0" Margin="10">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="core:IPluginHelpPage">
<TextBlock Text="{CompiledBinding Title}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Border Classes="router-container" Grid.Column="1">
<ContentControl Content="{CompiledBinding SelectedHelpPage}" Margin="15"></ContentControl>
</Border>
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Classes="notification-container" Name="NotificationContainer" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
</Grid>
</Window>

View File

@ -0,0 +1,21 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Plugins.Help;
public partial class PluginHelpWindowView : Window
{
public PluginHelpWindowView()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}

View File

@ -0,0 +1,32 @@
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core;
using Artemis.UI.Shared;
namespace Artemis.UI.Screens.Plugins.Help;
public class PluginHelpWindowViewModel : ActivatableViewModelBase
{
private IPluginHelpPage? _selectedHelpPage;
public PluginHelpWindowViewModel(Plugin plugin, string? preselectId)
{
Plugin = plugin;
DisplayName = $"{Plugin.Info.Name} | Help";
// Populate help pages by wrapping MarkdownHelpPages into a MarkdownHelpPageViewModel
// other types are used directly, up to them to implement a VM directly as well
HelpPages = new ReadOnlyCollection<IPluginHelpPage>(plugin.HelpPages.Select(p => p is MarkdownPluginHelpPage m ? new MarkdownPluginHelpPageViewModel(m) : p).ToList());
_selectedHelpPage = preselectId != null ? HelpPages.FirstOrDefault(p => p.Id == preselectId) : HelpPages.FirstOrDefault();
}
public Plugin Plugin { get; }
public ReadOnlyCollection<IPluginHelpPage> HelpPages { get; }
public IPluginHelpPage? SelectedHelpPage
{
get => _selectedHelpPage;
set => RaiseAndSetIfChanged(ref _selectedHelpPage, value);
}
}

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.DryIoc.Factories;
using Artemis.UI.Screens.Plugins.Features;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using ReactiveUI;

View File

@ -3,10 +3,12 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginSettingsWindowView"
x:DataType="plugins:PluginSettingsWindowViewModel"
Icon="/Assets/Images/Logo/application.ico"
Title="{Binding DisplayName}"
Title="{CompiledBinding DisplayName}"
Width="800"
Height="800"
WindowStartupLocation="CenterOwner">

View File

@ -46,9 +46,9 @@
</Grid>
<Grid Grid.Row="1" ColumnDefinitions="*,Auto">
<StackPanel Orientation="Horizontal">
<SplitButton Content="Settings" Command="{CompiledBinding OpenSettings}">
<SplitButton.Flyout>
<StackPanel Orientation="Horizontal" Spacing="5">
<DropDownButton Content="Manage">
<DropDownButton.Flyout>
<MenuFlyout Placement="Bottom" Opening="FlyoutBase_OnOpening">
<MenuItem Header="Open plugin directory" Command="{CompiledBinding OpenPluginDirectory}">
<MenuItem.Icon>
@ -70,6 +70,7 @@
<avalonia:MaterialIcon Kind="Delete" />
</MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem Header="Clear plugin settings" Command="{CompiledBinding RemoveSettings}">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="DatabaseRemove" />
@ -81,19 +82,31 @@
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</SplitButton.Flyout>
</SplitButton>
</DropDownButton.Flyout>
</DropDownButton>
<controls:HyperlinkButton Classes="icon-button icon-button-large"
IsVisible="{CompiledBinding Plugin.ConfigurationDialog, Converter={x:Static ObjectConverters.IsNotNull}}"
Command="{CompiledBinding OpenSettings}"
ToolTip.Tip="Open settings">
<avalonia:MaterialIcon Kind="Cog" />
</controls:HyperlinkButton>
<controls:HyperlinkButton Classes="icon-button icon-button-large"
IsVisible="{CompiledBinding HasHelpPages}"
Command="{CompiledBinding OpenHelp}"
ToolTip.Tip="View help pages">
<avalonia:MaterialIcon Kind="Help" />
</controls:HyperlinkButton>
<controls:HyperlinkButton Classes="icon-button icon-button-large"
Margin="5 0"
IsVisible="{CompiledBinding Plugin.Info.Website, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
NavigateUri="{CompiledBinding Plugin.Info.Website}">
NavigateUri="{CompiledBinding Plugin.Info.Website}"
ToolTip.Tip="{CompiledBinding Plugin.Info.Website}">
<avalonia:MaterialIcon Kind="Web" />
</controls:HyperlinkButton>
<controls:HyperlinkButton Classes="icon-button icon-button-large"
Margin="5 0"
IsVisible="{CompiledBinding Plugin.Info.Repository, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
NavigateUri="{CompiledBinding Plugin.Info.Repository}">
NavigateUri="{CompiledBinding Plugin.Info.Repository}"
ToolTip.Tip="{CompiledBinding Plugin.Info.Repository}">
<avalonia:MaterialIcon Kind="Git" />
</controls:HyperlinkButton>
</StackPanel>

View File

@ -4,10 +4,12 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.Exceptions;
using Artemis.UI.Screens.Plugins.Help;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.Builders;
@ -28,7 +30,8 @@ public class PluginViewModel : ActivatableViewModelBase
private bool _canRemovePrerequisites;
private bool _enabling;
private Plugin _plugin;
private Window? _window;
private Window? _settingsWindow;
private Window? _helpWindow;
public PluginViewModel(Plugin plugin,
ReactiveCommand<Unit, Unit>? reload,
@ -56,6 +59,7 @@ public class PluginViewModel : ActivatableViewModelBase
Reload = reload;
OpenSettings = ReactiveCommand.Create(ExecuteOpenSettings, this.WhenAnyValue(vm => vm.IsEnabled, e => e && Plugin.ConfigurationDialog != null));
OpenHelp = ReactiveCommand.Create(ExecuteOpenHelp, this.WhenAnyValue(vm => vm.HasHelpPages));
RemoveSettings = ReactiveCommand.CreateFromTask(ExecuteRemoveSettings);
Remove = ReactiveCommand.CreateFromTask(ExecuteRemove);
InstallPrerequisites = ReactiveCommand.CreateFromTask(ExecuteInstallPrerequisites, this.WhenAnyValue(x => x.CanInstallPrerequisites));
@ -72,13 +76,15 @@ public class PluginViewModel : ActivatableViewModelBase
{
Plugin.Enabled -= OnPluginToggled;
Plugin.Disabled -= OnPluginToggled;
_window?.Close();
_settingsWindow?.Close();
_helpWindow?.Close();
}).DisposeWith(d);
});
}
public ReactiveCommand<Unit, Unit>? Reload { get; }
public ReactiveCommand<Unit, Unit> OpenSettings { get; }
public ReactiveCommand<Unit,Unit> OpenHelp { get; }
public ReactiveCommand<Unit, Unit> RemoveSettings { get; }
public ReactiveCommand<Unit, Unit> Remove { get; }
public ReactiveCommand<Unit, Unit> InstallPrerequisites { get; }
@ -102,6 +108,7 @@ public class PluginViewModel : ActivatableViewModelBase
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
public bool IsEnabled => Plugin.IsEnabled;
public bool HasHelpPages => Plugin.HelpPages.Any();
public bool CanInstallPrerequisites
{
@ -199,10 +206,10 @@ public class PluginViewModel : ActivatableViewModelBase
if (Plugin.ConfigurationDialog == null)
return;
if (_window != null)
if (_settingsWindow != null)
{
_window.WindowState = WindowState.Normal;
_window.Activate();
_settingsWindow.WindowState = WindowState.Normal;
_settingsWindow.Activate();
return;
}
@ -211,8 +218,8 @@ public class PluginViewModel : ActivatableViewModelBase
if (Plugin.Resolve(Plugin.ConfigurationDialog.Type) is not PluginConfigurationViewModel viewModel)
throw new ArtemisUIException($"The type of a plugin configuration dialog must inherit {nameof(PluginConfigurationViewModel)}");
_window = _windowService.ShowWindow(new PluginSettingsWindowViewModel(viewModel));
_window.Closed += (_, _) => _window = null;
_settingsWindow = _windowService.ShowWindow(new PluginSettingsWindowViewModel(viewModel));
_settingsWindow.Closed += (_, _) => _settingsWindow = null;
}
catch (Exception e)
{
@ -221,6 +228,30 @@ public class PluginViewModel : ActivatableViewModelBase
}
}
private void ExecuteOpenHelp()
{
if (Plugin.ConfigurationDialog == null)
return;
if (_helpWindow != null)
{
_helpWindow.WindowState = WindowState.Normal;
_helpWindow.Activate();
return;
}
try
{
_helpWindow = _windowService.ShowWindow(new PluginHelpWindowViewModel(Plugin, null));
_helpWindow.Closed += (_, _) => _helpWindow = null;
}
catch (Exception e)
{
_windowService.ShowExceptionDialog("An exception occured while trying to show the plugin's help window", e);
throw;
}
}
private void ExecuteOpenPluginDirectory()
{
try
@ -313,7 +344,7 @@ public class PluginViewModel : ActivatableViewModelBase
{
this.RaisePropertyChanged(nameof(IsEnabled));
if (!IsEnabled)
_window?.Close();
_settingsWindow?.Close();
});
}
}

View File

@ -3,9 +3,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:prerequisites="clr-namespace:Artemis.UI.Screens.Plugins.Prerequisites"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginPrerequisiteActionView"
x:DataType="plugins:PluginPrerequisiteActionViewModel">
x:Class="Artemis.UI.Screens.Plugins.Prerequisites.PluginPrerequisiteActionView"
x:DataType="prerequisites:PluginPrerequisiteActionViewModel">
<StackPanel>
<ProgressBar Value="{CompiledBinding Action.Progress.Percentage, Mode=OneWay}"
IsIndeterminate="{CompiledBinding Action.ProgressIndeterminate, Mode=OneWay}"

View File

@ -1,7 +1,6 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Plugins;
namespace Artemis.UI.Screens.Plugins.Prerequisites;
public partial class PluginPrerequisiteActionView : UserControl
{

View File

@ -1,7 +1,7 @@
using Artemis.Core;
using Artemis.UI.Shared;
namespace Artemis.UI.Screens.Plugins;
namespace Artemis.UI.Screens.Plugins.Prerequisites;
public class PluginPrerequisiteActionViewModel : ViewModelBase
{

View File

@ -3,9 +3,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Plugins"
xmlns:prerequisites="clr-namespace:Artemis.UI.Screens.Plugins.Prerequisites"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Plugins.PluginPrerequisiteView"
x:DataType="plugins:PluginPrerequisiteViewModel">
x:Class="Artemis.UI.Screens.Plugins.Prerequisites.PluginPrerequisiteView"
x:DataType="prerequisites:PluginPrerequisiteViewModel">
<StackPanel>
<TextBlock TextWrapping="Wrap" Text="{CompiledBinding PluginPrerequisite.Name, Mode=OneWay}" />
<TextBlock Classes="subtitle" TextWrapping="Wrap" Text="{CompiledBinding PluginPrerequisite.Description, Mode=OneWay}" Margin="0 0 0 15" />

View File

@ -1,7 +1,6 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Plugins;
namespace Artemis.UI.Screens.Plugins.Prerequisites;
public partial class PluginPrerequisiteView : ReactiveUserControl<PluginPrerequisiteViewModel>
{

View File

@ -8,7 +8,7 @@ using Artemis.Core;
using Artemis.UI.Shared;
using ReactiveUI;
namespace Artemis.UI.Screens.Plugins;
namespace Artemis.UI.Screens.Plugins.Prerequisites;
public class PluginPrerequisiteViewModel : ActivatableViewModelBase
{