mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Plugins - Added descriptions
Settings - Plugin settings tab UI - Catch exceptions during exception dialog display Plugins - Implemented enable/disable of plugins (WIP) Novation - Added Launchpad Mini layout and image
This commit is contained in:
1 parent
73245a3d4b
commit
16af36bc57
44 files changed
+810
-199
No files matched your search
@@ -93,7 +93,14 @@ namespace Artemis.UI
|
||||
logger.Fatal(e.Exception, "Unhandled exception");
|
||||
|
||||
var dialogService = Kernel.Get<IDialogService>();
|
||||
dialogService.ShowExceptionDialog("Artemis encountered an error", e.Exception);
|
||||
try
|
||||
{
|
||||
dialogService.ShowExceptionDialog("Artemis encountered an error", e.Exception);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// We did our best eh.. trap exceptions during exception display here to avoid an infinite loop
|
||||
}
|
||||
|
||||
// Don't shut down, is that a good idea? Depends on the exception of course..
|
||||
e.Handled = true;
|
||||
|
||||
@@ -225,56 +225,28 @@
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="PLUGINS" TextElement.Foreground="{DynamicResource MaterialDesignBody}">
|
||||
<DockPanel Margin="15">
|
||||
<TextBlock DockPanel.Dock="Top">The list below shows all loaded plugins. If you're missing something, view your logs folder.</TextBlock>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<DataGrid Margin="0 8 0 0"
|
||||
ItemsSource="{Binding Plugins}"
|
||||
CanUserSortColumns="True"
|
||||
CanUserAddRows="False"
|
||||
AutoGenerateColumns="False"
|
||||
materialDesign:DataGridAssist.CellPadding="13 8 8 8"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="8">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Type}" Header="Type" IsReadOnly="True" />
|
||||
<DataGridTextColumn Binding="{Binding Name}" Header="Name" IsReadOnly="True" Width="*" />
|
||||
<DataGridTextColumn Binding="{Binding Description}" Header="Description" IsReadOnly="True" Width="*" />
|
||||
<DataGridTextColumn Binding="{Binding Version}" Header="Version" IsReadOnly="True" />
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}" s:View.ActionTarget="{Binding}" Command="{s:Action OpenSettings}">
|
||||
CONFIGURE
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridCheckBoxColumn Header="Enabled"
|
||||
Binding="{Binding IsEnabled}"
|
||||
ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}"
|
||||
EditingElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnEditingStyle}">
|
||||
<DataGridCheckBoxColumn.HeaderStyle>
|
||||
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" TextAlignment="Right" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</DataGridCheckBoxColumn.HeaderStyle>
|
||||
</DataGridCheckBoxColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
|
||||
<TextBlock DockPanel.Dock="Top">The list below shows all loaded plugins. If you're missing something, view your logs folder.</TextBlock>
|
||||
<ItemsControl ItemsSource="{Binding Plugins}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl xaml:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</DockPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="DEVICES" TextElement.Foreground="{DynamicResource MaterialDesignBody}">
|
||||
<DockPanel Margin="15">
|
||||
<TextBlock DockPanel.Dock="Top">Below you view and manage the devices that were detected by Artemis</TextBlock>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
|
||||
<TextBlock DockPanel.Dock="Top">Below you view and manage the devices that were detected by Artemis</TextBlock>
|
||||
<ItemsControl ItemsSource="{Binding DeviceSettingsViewModels}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -287,8 +259,8 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
</DockPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</UserControl>
|
||||
@@ -10,6 +10,7 @@ using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Core.Utilities;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Settings.Debug;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
||||
@@ -205,7 +206,7 @@ namespace Artemis.UI.Screens.Settings
|
||||
try
|
||||
{
|
||||
var autoRunFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "Artemis.lnk");
|
||||
var executableFile = Process.GetCurrentProcess().MainModule.FileName;
|
||||
var executableFile = CurrentProcessUtilities.GetCurrentLocation();
|
||||
|
||||
if (File.Exists(autoRunFile))
|
||||
File.Delete(autoRunFile);
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
<materialDesign:PackIcon Kind="AlarmLight" />
|
||||
</Button>
|
||||
<StackPanel Grid.Row="1" Margin="8 24 8 0">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Device.RgbDevice.DeviceInfo.Model}" />
|
||||
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}" Text="{Binding Device.RgbDevice.DeviceInfo.Model}" />
|
||||
<TextBlock TextWrapping="Wrap" Style="{StaticResource MaterialDesignTextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}">
|
||||
<Run Text="{Binding Device.RgbDevice.DeviceInfo.Manufacturer, Mode=OneWay}" />
|
||||
-
|
||||
<Run Text="{Binding Device.RgbDevice.DeviceInfo.DeviceType, Mode=OneWay}" />
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Settings.Tabs.Plugins.PluginSettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:devices="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Plugins"
|
||||
d:DataContext="{d:DesignInstance devices:PluginSettingsViewModel}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<materialDesign:Card Width="400">
|
||||
<Grid Margin="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Grid.ColumnSpan="2" Margin="0 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<materialDesign:PackIcon Kind="{Binding Icon}" Width="48" Height="48" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Center" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}" Text="{Binding PluginInfo.Name}" Grid.Column="1" Grid.Row="0" />
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding PluginInfo.Description}"
|
||||
Style="{StaticResource MaterialDesignTextBlock}"
|
||||
Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" />
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
|
||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}" ToolTip="MaterialDesignOutlinedButton" Margin="4" s:View.ActionTarget="{Binding}" Command="{s:Action OpenSettings}">
|
||||
Settings
|
||||
</Button>
|
||||
<!-- <Button Style="{StaticResource MaterialDesignOutlinedButton}" ToolTip="MaterialDesignOutlinedButton" Margin="4"> -->
|
||||
<!-- Details -->
|
||||
<!-- </Button> -->
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="8">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding IsEnabled}">
|
||||
Plugin enabled
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</materialDesign:Card>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for PluginSettingsView.xaml
|
||||
/// </summary>
|
||||
public partial class PluginSettingsView : UserControl
|
||||
{
|
||||
public PluginSettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
@@ -10,36 +13,65 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
public class PluginSettingsViewModel : PropertyChangedBase
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly Plugin _plugin;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService, IPluginService pluginService)
|
||||
{
|
||||
_plugin = plugin;
|
||||
Plugin = plugin;
|
||||
PluginInfo = plugin.PluginInfo;
|
||||
|
||||
_windowManager = windowManager;
|
||||
_dialogService = dialogService;
|
||||
_pluginService = pluginService;
|
||||
}
|
||||
|
||||
public string Type => _plugin.GetType().BaseType?.Name ?? _plugin.GetType().Name;
|
||||
public string Name => _plugin.PluginInfo.Name;
|
||||
public string Description => _plugin.PluginInfo.Description;
|
||||
public Version Version => _plugin.PluginInfo.Version;
|
||||
public Plugin Plugin { get; set; }
|
||||
public PluginInfo PluginInfo { get; set; }
|
||||
|
||||
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
|
||||
|
||||
public PackIconKind Icon => GetIconKind();
|
||||
|
||||
private PackIconKind GetIconKind()
|
||||
{
|
||||
if (PluginInfo.Icon != null)
|
||||
{
|
||||
var parsedIcon = Enum.TryParse<PackIconKind>(PluginInfo.Icon, true, out var iconEnum);
|
||||
if (parsedIcon == false)
|
||||
return PackIconKind.QuestionMarkCircle;
|
||||
}
|
||||
|
||||
switch (Plugin)
|
||||
{
|
||||
case DataModelExpansion _:
|
||||
return PackIconKind.TableAdd;
|
||||
case DeviceProvider _:
|
||||
return PackIconKind.Devices;
|
||||
case ProfileModule _:
|
||||
return PackIconKind.VectorRectangle;
|
||||
case Core.Plugins.Abstract.Module _:
|
||||
return PackIconKind.GearBox;
|
||||
case LayerBrushProvider _:
|
||||
return PackIconKind.Brush;
|
||||
}
|
||||
|
||||
return PackIconKind.Plugin;
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _plugin.PluginInfo.Enabled;
|
||||
get => PluginInfo.Enabled;
|
||||
set => Task.Run(() => UpdateEnabled(value));
|
||||
}
|
||||
|
||||
public bool CanOpenSettings => IsEnabled && _plugin.HasConfigurationViewModel;
|
||||
public bool CanOpenSettings => IsEnabled && Plugin.HasConfigurationViewModel;
|
||||
|
||||
public async Task OpenSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var configurationViewModel = _plugin.GetConfigurationViewModel();
|
||||
var configurationViewModel = Plugin.GetConfigurationViewModel();
|
||||
if (configurationViewModel != null)
|
||||
_windowManager.ShowDialog(new PluginSettingsWindowViewModel(configurationViewModel));
|
||||
}
|
||||
@@ -50,15 +82,33 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEnabled(in bool enable)
|
||||
private async Task UpdateEnabled(bool enable)
|
||||
{
|
||||
if (_plugin.PluginInfo.Enabled == enable)
|
||||
if (PluginInfo.Enabled == enable)
|
||||
{
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!enable && Plugin is DeviceProvider)
|
||||
{
|
||||
var confirm = await _dialogService.ShowConfirmDialog(
|
||||
"Disable device provider",
|
||||
"You are disabling a device provider, this requires that Artemis restarts, please confirm."
|
||||
);
|
||||
if (!confirm)
|
||||
{
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable)
|
||||
_pluginService.EnablePlugin(_plugin);
|
||||
_pluginService.EnablePlugin(Plugin);
|
||||
else
|
||||
_pluginService.DisablePlugin(_plugin);
|
||||
_pluginService.DisablePlugin(Plugin);
|
||||
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user