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 string _placeholder = "Select a property";
|
||||
|
||||
internal DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
||||
public DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
||||
{
|
||||
_module = module;
|
||||
_dataModelUIService = dataModelUIService;
|
||||
|
||||
@ -25,7 +25,7 @@ namespace Artemis.UI.Shared.Input
|
||||
private object _value;
|
||||
private bool _displaySwitchButton;
|
||||
|
||||
internal DataModelStaticViewModel(Type targetType, DataModelPropertyAttribute targetDescription, IDataModelUIService dataModelUIService)
|
||||
public DataModelStaticViewModel(Type targetType, DataModelPropertyAttribute targetDescription, IDataModelUIService dataModelUIService)
|
||||
{
|
||||
_dataModelUIService = dataModelUIService;
|
||||
_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 Artemis.UI.Shared.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject.Extensions.Conventions;
|
||||
@ -29,6 +30,15 @@ namespace Artemis.UI.Shared.Ninject
|
||||
});
|
||||
|
||||
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.UI.Shared.DefaultTypes.DataModel.Display;
|
||||
using Artemis.UI.Shared.Input;
|
||||
using Artemis.UI.Shared.Ninject.Factories;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
|
||||
@ -15,13 +16,15 @@ namespace Artemis.UI.Shared.Services
|
||||
internal class DataModelUIService : IDataModelUIService
|
||||
{
|
||||
private readonly IDataModelService _dataModelService;
|
||||
private readonly IDataModelVmFactory _dataModelVmFactory;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly List<DataModelVisualizationRegistration> _registeredDataModelDisplays;
|
||||
private readonly List<DataModelVisualizationRegistration> _registeredDataModelEditors;
|
||||
|
||||
public DataModelUIService(IDataModelService dataModelService, IKernel kernel)
|
||||
public DataModelUIService(IDataModelService dataModelService, IDataModelVmFactory dataModelVmFactory, IKernel kernel)
|
||||
{
|
||||
_dataModelService = dataModelService;
|
||||
_dataModelVmFactory = dataModelVmFactory;
|
||||
_kernel = kernel;
|
||||
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
|
||||
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
|
||||
@ -219,12 +222,12 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
public DataModelDynamicViewModel GetDynamicSelectionViewModel(Module module)
|
||||
{
|
||||
return _kernel.Get<DataModelDynamicViewModel>(new ConstructorArgument("module", module));
|
||||
return _dataModelVmFactory.DataModelDynamicViewModel(module);
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@ -6,9 +6,13 @@
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Plugins"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:PluginFeatureViewModel}">
|
||||
<UserControl.Resources>
|
||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="-3 -8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
@ -17,9 +21,26 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 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 -->
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}" Style="{StaticResource MaterialDesignTextBlock}" VerticalAlignment="Center" />
|
||||
|
||||
<!-- Enable toggle column -->
|
||||
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="8"
|
||||
@ -28,7 +49,7 @@
|
||||
Feature enabled
|
||||
</CheckBox>
|
||||
</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}">
|
||||
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
|
||||
</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()
|
||||
{
|
||||
base.OnInitialActivate();
|
||||
|
||||
@ -102,7 +102,6 @@
|
||||
<ListBox Grid.Row="1"
|
||||
MaxHeight="135"
|
||||
ItemsSource="{Binding Items}"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
Visibility="{Binding IsEnabled, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
VerticalAlignment="Top" Height="120" />
|
||||
<TextBlock Grid.Row="1"
|
||||
Style="{StaticResource MaterialDesignHeadline6TextBlock}"
|
||||
Foreground="{StaticResource PrimaryHueDarkForegroundBrush}"
|
||||
Margin="15"
|
||||
materialDesign:ShadowAssist.ShadowDepth="Depth1"
|
||||
Text="{Binding ActiveModules}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user