mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Plugins - Implemented features enable/disable UI
This commit is contained in:
1 parent
e812929215
commit
c146479393
38 files changed
+571
-164
No files matched your search
@@ -8,10 +8,11 @@
|
||||
xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:modules="clr-namespace:Artemis.Core.Modules;assembly=Artemis.Core"
|
||||
xmlns:dataModel="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:DataModelDebugViewModel}">
|
||||
<UserControl.Resources>
|
||||
<dataModel:TypeToStringConverter x:Key="TypeToStringConverter"/>
|
||||
<dataModel:TypeToStringConverter x:Key="TypeToStringConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -43,19 +44,11 @@
|
||||
wpf:HintAssist.Hint="Select a module"
|
||||
IsEditable="True"
|
||||
TextSearch.TextPath="DisplayName"
|
||||
DisplayMemberPath="DisplayName"
|
||||
Margin="5 0 0 0"
|
||||
IsEnabled="{Binding IsModuleFilterEnabled}"
|
||||
SelectedItem="{Binding SelectedModule}"
|
||||
ItemsSource="{Binding Modules}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel d:DataContext="{d:DesignInstance Type=modules:Module}" Orientation="Horizontal">
|
||||
<wpf:PackIcon Kind="{Binding DisplayIcon}" VerticalAlignment="Center" Margin="0 0 5 0" />
|
||||
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
ItemsSource="{Binding Modules}" />
|
||||
</Grid>
|
||||
<TreeView Grid.Row="1" ItemsSource="{Binding MainDataModel.Children}" HorizontalContentAlignment="Stretch">
|
||||
<TreeView.Resources>
|
||||
@@ -73,12 +66,12 @@
|
||||
<Run>[</Run><Run Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" /><Run>]</Run>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
||||
<TextBlock Grid.Column="2"
|
||||
Text="{Binding DisplayValue}"
|
||||
FontFamily="Consolas"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Column="2"
|
||||
Text="{Binding DisplayValue}"
|
||||
FontFamily="Consolas"
|
||||
HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
|
||||
|
||||
</HierarchicalDataTemplate>
|
||||
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}" ItemsSource="{Binding ListChildren}">
|
||||
<Grid>
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
_updateTimer = new Timer(500);
|
||||
|
||||
DisplayName = "Data model";
|
||||
Modules = new BindableCollection<Module>();
|
||||
}
|
||||
|
||||
public DataModelPropertiesViewModel MainDataModel
|
||||
@@ -42,11 +43,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
set => SetAndNotify(ref _propertySearch, value);
|
||||
}
|
||||
|
||||
public List<Module> Modules
|
||||
{
|
||||
get => _modules;
|
||||
set => SetAndNotify(ref _modules, value);
|
||||
}
|
||||
public BindableCollection<Module> Modules { get; }
|
||||
|
||||
public Module SelectedModule
|
||||
{
|
||||
@@ -77,8 +74,8 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
GetDataModel();
|
||||
_updateTimer.Start();
|
||||
_updateTimer.Elapsed += OnUpdateTimerOnElapsed;
|
||||
_pluginManagementService.PluginEnabled += PluginManagementServiceOnPluginManagementToggled;
|
||||
_pluginManagementService.PluginDisabled += PluginManagementServiceOnPluginManagementToggled;
|
||||
_pluginManagementService.PluginFeatureEnabled += OnPluginFeatureToggled;
|
||||
_pluginManagementService.PluginFeatureDisabled += OnPluginFeatureToggled;
|
||||
|
||||
PopulateModules();
|
||||
|
||||
@@ -89,14 +86,23 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
{
|
||||
_updateTimer.Stop();
|
||||
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
|
||||
_pluginManagementService.PluginEnabled -= PluginManagementServiceOnPluginManagementToggled;
|
||||
_pluginManagementService.PluginDisabled -= PluginManagementServiceOnPluginManagementToggled;
|
||||
_pluginManagementService.PluginFeatureEnabled -= OnPluginFeatureToggled;
|
||||
_pluginManagementService.PluginFeatureDisabled -= OnPluginFeatureToggled;
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
private void OnPluginFeatureToggled(object sender, PluginFeatureEventArgs e)
|
||||
{
|
||||
if (e.PluginFeature is DataModelPluginFeature)
|
||||
PopulateModules();
|
||||
}
|
||||
|
||||
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs args)
|
||||
{
|
||||
if (MainDataModel == null)
|
||||
return;
|
||||
|
||||
lock (MainDataModel)
|
||||
{
|
||||
MainDataModel.Update(_dataModelUIService, null);
|
||||
@@ -110,14 +116,15 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
||||
: _dataModelUIService.GetMainDataModelVisualization();
|
||||
}
|
||||
|
||||
private void PluginManagementServiceOnPluginManagementToggled(object? sender, PluginEventArgs e)
|
||||
{
|
||||
PopulateModules();
|
||||
}
|
||||
|
||||
private void PopulateModules()
|
||||
{
|
||||
Modules = _pluginManagementService.GetFeaturesOfType<Module>().Where(p => p.IsEnabled).ToList();
|
||||
Modules.Clear();
|
||||
Modules.AddRange(_pluginManagementService.GetFeaturesOfType<Module>().Where(p => p.IsEnabled).OrderBy(m => m.DisplayName));
|
||||
|
||||
if (SelectedModule == null)
|
||||
_dataModelUIService.UpdateModules(MainDataModel);
|
||||
else if (!SelectedModule.IsEnabled)
|
||||
SelectedModule = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user