mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Conditions - Implemented self referencing list conditions
This commit is contained in:
1 parent
879d19e4ea
commit
2946364463
4 files changed
+52
-19
No files matched your search
@@ -61,8 +61,8 @@
|
||||
HorizontalAlignment="Left"
|
||||
Click="PropertyButton_OnClick">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu ItemsSource="{Binding DataModelViewModel.Children}" IsOpen="{Binding IsDataModelViewModelOpen, Mode=OneWayToSource}">
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<ContextMenu IsOpen="{Binding IsDataModelViewModelOpen, Mode=OneWayToSource}">
|
||||
<ContextMenu.Resources>
|
||||
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
||||
<Setter Property="ItemsSource" Value="{Binding Children}" />
|
||||
<Setter Property="Command" Value="{Binding Data.SelectPropertyCommand, Source={StaticResource DataContextProxy}}" />
|
||||
@@ -72,7 +72,14 @@
|
||||
<Setter Property="IsSubmenuOpen" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" />
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource DataModelDataTemplate}" />
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
</ContextMenu.Resources>
|
||||
<ContextMenu.ItemsSource>
|
||||
<CompositeCollection>
|
||||
<CollectionContainer Collection="{Binding Data.ExtraDataModelViewModels, Source={StaticResource DataContextProxy}}" />
|
||||
<Separator Visibility="{Binding Data.HasExtraDataModels, Source={StaticResource DataContextProxy}, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"/>
|
||||
<CollectionContainer Collection="{Binding Data.DataModelViewModel.Children, Source={StaticResource DataContextProxy}}" />
|
||||
</CompositeCollection>
|
||||
</ContextMenu.ItemsSource>
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
<Grid>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Windows.Media;
|
||||
@@ -21,11 +22,11 @@ namespace Artemis.UI.Shared.Input
|
||||
private Brush _buttonBrush = new SolidColorBrush(Color.FromRgb(171, 71, 188));
|
||||
private DataModelPath _dataModelPath;
|
||||
private DataModelPropertiesViewModel _dataModelViewModel;
|
||||
private bool _displaySwitchButton;
|
||||
private Type[] _filterTypes;
|
||||
private bool _isDataModelViewModelOpen;
|
||||
private bool _isEnabled = true;
|
||||
private string _placeholder = "Select a property";
|
||||
private bool _displaySwitchButton;
|
||||
|
||||
internal DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
||||
{
|
||||
@@ -33,6 +34,7 @@ namespace Artemis.UI.Shared.Input
|
||||
_dataModelUIService = dataModelUIService;
|
||||
_updateTimer = new Timer(500);
|
||||
|
||||
ExtraDataModelViewModels = new BindableCollection<DataModelPropertiesViewModel>();
|
||||
ShowDataModelValues = settingsService.GetSetting<bool>("ProfileEditor.ShowDataModelValues");
|
||||
SelectPropertyCommand = new DelegateCommand(ExecuteSelectPropertyCommand);
|
||||
|
||||
@@ -73,6 +75,9 @@ namespace Artemis.UI.Shared.Input
|
||||
}
|
||||
}
|
||||
|
||||
public BindableCollection<DataModelPropertiesViewModel> ExtraDataModelViewModels { get; }
|
||||
public bool HasExtraDataModels => ExtraDataModelViewModels.Any();
|
||||
|
||||
public DelegateCommand SelectPropertyCommand { get; }
|
||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||
|
||||
@@ -144,22 +149,11 @@ namespace Artemis.UI.Shared.Input
|
||||
// Get the data models
|
||||
DataModelViewModel = _dataModelUIService.GetPluginDataModelVisualization(_module, true);
|
||||
DataModelViewModel.UpdateRequested += DataModelOnUpdateRequested;
|
||||
|
||||
ExtraDataModelViewModels.CollectionChanged += ExtraDataModelViewModelsOnCollectionChanged;
|
||||
_updateTimer.Start();
|
||||
_updateTimer.Elapsed += OnUpdateTimerOnElapsed;
|
||||
}
|
||||
|
||||
private void DataModelOnUpdateRequested(object sender, EventArgs e)
|
||||
{
|
||||
DataModelViewModel.ApplyTypeFilter(true, FilterTypes);
|
||||
}
|
||||
|
||||
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (IsDataModelViewModelOpen)
|
||||
DataModelViewModel.Update(_dataModelUIService);
|
||||
}
|
||||
|
||||
private void ExecuteSelectPropertyCommand(object context)
|
||||
{
|
||||
if (!(context is DataModelVisualizationViewModel selected))
|
||||
@@ -178,6 +172,32 @@ namespace Artemis.UI.Shared.Input
|
||||
DataModelPath?.Dispose();
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void DataModelOnUpdateRequested(object sender, EventArgs e)
|
||||
{
|
||||
DataModelViewModel.ApplyTypeFilter(true, FilterTypes);
|
||||
foreach (DataModelPropertiesViewModel extraDataModelViewModel in ExtraDataModelViewModels)
|
||||
extraDataModelViewModel.ApplyTypeFilter(true, FilterTypes);
|
||||
}
|
||||
|
||||
private void ExtraDataModelViewModelsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(HasExtraDataModels));
|
||||
}
|
||||
|
||||
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (!IsDataModelViewModelOpen)
|
||||
return;
|
||||
|
||||
DataModelViewModel.Update(_dataModelUIService);
|
||||
foreach (DataModelPropertiesViewModel extraDataModelViewModel in ExtraDataModelViewModels)
|
||||
extraDataModelViewModel.Update(_dataModelUIService);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler<DataModelInputDynamicEventArgs> PropertySelected;
|
||||
|
||||
Reference in new issue
Block a user