mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Plugin features - Added exception display
This commit is contained in:
parent
c146479393
commit
9452f81214
@ -29,7 +29,7 @@ namespace Artemis.UI.Shared.Input
|
|||||||
private bool _isEnabled = true;
|
private bool _isEnabled = true;
|
||||||
private string _placeholder = "Select a property";
|
private string _placeholder = "Select a property";
|
||||||
|
|
||||||
internal DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
public DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
_module = module;
|
_module = module;
|
||||||
_dataModelUIService = dataModelUIService;
|
_dataModelUIService = dataModelUIService;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ namespace Artemis.UI.Shared.Input
|
|||||||
private object _value;
|
private object _value;
|
||||||
private bool _displaySwitchButton;
|
private bool _displaySwitchButton;
|
||||||
|
|
||||||
internal DataModelStaticViewModel(Type targetType, DataModelPropertyAttribute targetDescription, IDataModelUIService dataModelUIService)
|
public DataModelStaticViewModel(Type targetType, DataModelPropertyAttribute targetDescription, IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
_dataModelUIService = dataModelUIService;
|
_dataModelUIService = dataModelUIService;
|
||||||
_rootView = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
|
_rootView = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
|
||||||
|
|||||||
17
src/Artemis.UI.Shared/Ninject/Factories/ISharedVMFactory.cs
Normal file
17
src/Artemis.UI.Shared/Ninject/Factories/ISharedVMFactory.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis.Core.DataModelExpansions;
|
||||||
|
using Artemis.Core.Modules;
|
||||||
|
using Artemis.UI.Shared.Input;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.Ninject.Factories
|
||||||
|
{
|
||||||
|
public interface ISharedVmFactory
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IDataModelVmFactory : ISharedVmFactory
|
||||||
|
{
|
||||||
|
DataModelDynamicViewModel DataModelDynamicViewModel(Module module);
|
||||||
|
DataModelStaticViewModel DataModelStaticViewModel(Type targetType, DataModelPropertyAttribute targetDescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Artemis.UI.Shared.Ninject.Factories;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Ninject.Extensions.Conventions;
|
using Ninject.Extensions.Conventions;
|
||||||
@ -29,6 +30,15 @@ namespace Artemis.UI.Shared.Ninject
|
|||||||
});
|
});
|
||||||
|
|
||||||
Kernel.Bind<ISnackbarMessageQueue>().ToConstant(new SnackbarMessageQueue(TimeSpan.FromSeconds(5))).InSingletonScope();
|
Kernel.Bind<ISnackbarMessageQueue>().ToConstant(new SnackbarMessageQueue(TimeSpan.FromSeconds(5))).InSingletonScope();
|
||||||
|
|
||||||
|
// Bind UI factories
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
{
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllInterfaces()
|
||||||
|
.InheritedFrom<ISharedVmFactory>()
|
||||||
|
.BindToFactory();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@ using Artemis.Core.Modules;
|
|||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Shared.DefaultTypes.DataModel.Display;
|
using Artemis.UI.Shared.DefaultTypes.DataModel.Display;
|
||||||
using Artemis.UI.Shared.Input;
|
using Artemis.UI.Shared.Input;
|
||||||
|
using Artemis.UI.Shared.Ninject.Factories;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Parameters;
|
using Ninject.Parameters;
|
||||||
|
|
||||||
@ -15,13 +16,15 @@ namespace Artemis.UI.Shared.Services
|
|||||||
internal class DataModelUIService : IDataModelUIService
|
internal class DataModelUIService : IDataModelUIService
|
||||||
{
|
{
|
||||||
private readonly IDataModelService _dataModelService;
|
private readonly IDataModelService _dataModelService;
|
||||||
|
private readonly IDataModelVmFactory _dataModelVmFactory;
|
||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
private readonly List<DataModelVisualizationRegistration> _registeredDataModelDisplays;
|
private readonly List<DataModelVisualizationRegistration> _registeredDataModelDisplays;
|
||||||
private readonly List<DataModelVisualizationRegistration> _registeredDataModelEditors;
|
private readonly List<DataModelVisualizationRegistration> _registeredDataModelEditors;
|
||||||
|
|
||||||
public DataModelUIService(IDataModelService dataModelService, IKernel kernel)
|
public DataModelUIService(IDataModelService dataModelService, IDataModelVmFactory dataModelVmFactory, IKernel kernel)
|
||||||
{
|
{
|
||||||
_dataModelService = dataModelService;
|
_dataModelService = dataModelService;
|
||||||
|
_dataModelVmFactory = dataModelVmFactory;
|
||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
|
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
|
||||||
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
|
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
|
||||||
@ -219,12 +222,12 @@ namespace Artemis.UI.Shared.Services
|
|||||||
|
|
||||||
public DataModelDynamicViewModel GetDynamicSelectionViewModel(Module module)
|
public DataModelDynamicViewModel GetDynamicSelectionViewModel(Module module)
|
||||||
{
|
{
|
||||||
return _kernel.Get<DataModelDynamicViewModel>(new ConstructorArgument("module", module));
|
return _dataModelVmFactory.DataModelDynamicViewModel(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelStaticViewModel GetStaticInputViewModel(Type targetType, DataModelPropertyAttribute targetDescription)
|
public DataModelStaticViewModel GetStaticInputViewModel(Type targetType, DataModelPropertyAttribute targetDescription)
|
||||||
{
|
{
|
||||||
return _kernel.Get<DataModelStaticViewModel>(new ConstructorArgument("targetType", targetType), new ConstructorArgument("targetDescription", targetDescription));
|
return _dataModelVmFactory.DataModelStaticViewModel(targetType, targetDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataModelInputViewModel InstantiateDataModelInputViewModel(DataModelVisualizationRegistration registration, DataModelPropertyAttribute description, object initialValue)
|
private DataModelInputViewModel InstantiateDataModelInputViewModel(DataModelVisualizationRegistration registration, DataModelPropertyAttribute description, object initialValue)
|
||||||
|
|||||||
@ -6,9 +6,13 @@
|
|||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Plugins"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Plugins"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance local:PluginFeatureViewModel}">
|
d:DataContext="{d:DesignInstance local:PluginFeatureViewModel}">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||||
|
</UserControl.Resources>
|
||||||
<Grid Margin="-3 -8">
|
<Grid Margin="-3 -8">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="30" />
|
<ColumnDefinition Width="30" />
|
||||||
@ -17,9 +21,26 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<!-- Icon column -->
|
<!-- Icon column -->
|
||||||
<materialDesign:PackIcon Kind="{Binding Icon}" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
<materialDesign:PackIcon Grid.Column="0"
|
||||||
|
Kind="{Binding Icon}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Visibility="{Binding LoadException, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}" />
|
||||||
|
|
||||||
|
<Button Grid.Column="0"
|
||||||
|
Margin="-8"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Visibility="{Binding LoadException, Converter={StaticResource NullToVisibilityConverter}}"
|
||||||
|
Style="{StaticResource MaterialDesignIconButton}"
|
||||||
|
Foreground="#E74C4C"
|
||||||
|
ToolTip="An exception occurred while enabling this feature, click to view"
|
||||||
|
Command="{s:Action ViewLoadException}">
|
||||||
|
<materialDesign:PackIcon Kind="AlertCircle" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- Display name column -->
|
<!-- Display name column -->
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Name}" VerticalAlignment="Center" />
|
<TextBlock Grid.Column="1" Text="{Binding Name}" Style="{StaticResource MaterialDesignTextBlock}" VerticalAlignment="Center" />
|
||||||
|
|
||||||
<!-- Enable toggle column -->
|
<!-- Enable toggle column -->
|
||||||
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="8"
|
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="8"
|
||||||
@ -28,7 +49,7 @@
|
|||||||
Feature enabled
|
Feature enabled
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="8"
|
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="7"
|
||||||
Visibility="{Binding Enabling, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
Visibility="{Binding Enabling, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||||
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
|
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -67,6 +67,14 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ViewLoadException()
|
||||||
|
{
|
||||||
|
if (LoadException == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_dialogService.ShowExceptionDialog("Feature failed to enable", Feature.LoadException);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnInitialActivate()
|
protected override void OnInitialActivate()
|
||||||
{
|
{
|
||||||
base.OnInitialActivate();
|
base.OnInitialActivate();
|
||||||
@ -148,7 +156,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
|||||||
{
|
{
|
||||||
if (e.PluginFeature != Feature) return;
|
if (e.PluginFeature != Feature) return;
|
||||||
Enabling = false;
|
Enabling = false;
|
||||||
|
|
||||||
NotifyOfPropertyChange(nameof(IsEnabled));
|
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||||
NotifyOfPropertyChange(nameof(LoadException));
|
NotifyOfPropertyChange(nameof(LoadException));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,6 @@
|
|||||||
<ListBox Grid.Row="1"
|
<ListBox Grid.Row="1"
|
||||||
MaxHeight="135"
|
MaxHeight="135"
|
||||||
ItemsSource="{Binding Items}"
|
ItemsSource="{Binding Items}"
|
||||||
materialDesign:RippleAssist.IsDisabled="True"
|
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
VirtualizingPanel.ScrollUnit="Pixel"
|
VirtualizingPanel.ScrollUnit="Pixel"
|
||||||
Visibility="{Binding IsEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
Visibility="{Binding IsEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
VerticalAlignment="Top" Height="120" />
|
VerticalAlignment="Top" Height="120" />
|
||||||
<TextBlock Grid.Row="1"
|
<TextBlock Grid.Row="1"
|
||||||
Style="{StaticResource MaterialDesignHeadline6TextBlock}"
|
Style="{StaticResource MaterialDesignHeadline6TextBlock}"
|
||||||
|
Foreground="{StaticResource PrimaryHueDarkForegroundBrush}"
|
||||||
Margin="15"
|
Margin="15"
|
||||||
materialDesign:ShadowAssist.ShadowDepth="Depth1"
|
materialDesign:ShadowAssist.ShadowDepth="Depth1"
|
||||||
Text="{Binding ActiveModules}"
|
Text="{Binding ActiveModules}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user