mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Nodes - Rewrote storage
This commit is contained in:
1 parent
3dfc25b092
commit
5b183d3010
23 files changed
+270
-134
No files matched your search
+2
-1
@@ -18,7 +18,8 @@
|
||||
DockPanel.Dock="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
FilterTypes="{CompiledBinding FilterTypes}"
|
||||
DataModelPath="{CompiledBinding EventPath}"/>
|
||||
DataModelPath="{CompiledBinding EventPath}"
|
||||
ShowFullPath="{CompiledBinding ShowFullPaths.Value}"/>
|
||||
|
||||
<TextBlock DockPanel.Dock="Top">When the event fires..</TextBlock>
|
||||
<ComboBox PlaceholderText="Select a play mode" HorizontalAlignment="Stretch" DockPanel.Dock="Top" SelectedIndex="{CompiledBinding SelectedTriggerMode}">
|
||||
|
||||
+5
-1
@@ -4,6 +4,7 @@ using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Screens.VisualScripting;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@@ -20,15 +21,17 @@ public class EventConditionViewModel : ActivatableViewModelBase
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ObservableAsPropertyHelper<bool> _showOverlapOptions;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private ObservableAsPropertyHelper<DataModelPath?>? _eventPath;
|
||||
private ObservableAsPropertyHelper<int>? _selectedOverlapMode;
|
||||
private ObservableAsPropertyHelper<int>? _selectedTriggerMode;
|
||||
|
||||
public EventConditionViewModel(EventCondition eventCondition, IProfileEditorService profileEditorService, IWindowService windowService)
|
||||
public EventConditionViewModel(EventCondition eventCondition, IProfileEditorService profileEditorService, IWindowService windowService, ISettingsService settingsService)
|
||||
{
|
||||
_eventCondition = eventCondition;
|
||||
_profileEditorService = profileEditorService;
|
||||
_windowService = windowService;
|
||||
_settingsService = settingsService;
|
||||
_showOverlapOptions = this.WhenAnyValue(vm => vm.SelectedTriggerMode)
|
||||
.Select(m => m == 0)
|
||||
.ToProperty(this, vm => vm.ShowOverlapOptions);
|
||||
@@ -47,6 +50,7 @@ public class EventConditionViewModel : ActivatableViewModelBase
|
||||
public ReactiveCommand<Unit, Unit> OpenEditor { get; }
|
||||
public bool ShowOverlapOptions => _showOverlapOptions.Value;
|
||||
public bool IsConditionForLayer => _eventCondition.ProfileElement is Layer;
|
||||
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", false);
|
||||
|
||||
public DataModelPath? EventPath
|
||||
{
|
||||
|
||||
@@ -128,40 +128,41 @@
|
||||
<MenuItem Header="_Options">
|
||||
<MenuItem Header="Focus Selected Layer"
|
||||
ToolTip.Tip="If enabled, displays only the layer you currently have selected"
|
||||
IsEnabled="False">
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding FocusSelectedLayer}">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{Binding FocusSelectedLayer.Value}" />
|
||||
</MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding FocusSelectedLayer.Value}"></avalonia:MaterialIcon>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display Data Model Values">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{Binding ShowDataModelValues.Value}" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="Display Data Model Values"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding ShowDataModelValues}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowDataModelValues.Value}"></avalonia:MaterialIcon>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display Full Condition Paths">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{Binding ShowFullPaths.Value}" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="Display Full Condition Paths"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding ShowFullPaths}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding ShowFullPaths.Value}"></avalonia:MaterialIcon>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Always Display Cable Values" ToolTip.Tip="If enabled, cable values are always shown instead of only on hover">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{Binding AlwaysShowValues.Value}" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="Always Display Cable Values"
|
||||
ToolTip.Tip="If enabled, cable values are always shown instead of only on hover"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding AlwaysShowValues}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysShowValues.Value}"></avalonia:MaterialIcon>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Apply All Data Bindings During Edit" ToolTip.Tip="If enabled, updates all data bindings instead of only the one you are editing">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox BorderThickness="0"
|
||||
IsHitTestVisible="False"
|
||||
IsChecked="{Binding AlwaysApplyDataBindings.Value}" />
|
||||
</MenuItem.Icon>
|
||||
<MenuItem Header="Apply All Data Bindings During Edit"
|
||||
ToolTip.Tip="If enabled, updates all data bindings instead of only the one you are editing"
|
||||
Command="{CompiledBinding ToggleBooleanSetting}"
|
||||
CommandParameter="{CompiledBinding AlwaysApplyDataBindings}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding AlwaysApplyDataBindings.Value}"></avalonia:MaterialIcon>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Help">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
@@ -12,13 +13,15 @@ namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
||||
public class MenuBarViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private ProfileEditorHistory? _history;
|
||||
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
|
||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||
|
||||
public MenuBarViewModel(IProfileEditorService profileEditorService, IProfileService profileService)
|
||||
public MenuBarViewModel(IProfileEditorService profileEditorService, IProfileService profileService, ISettingsService settingsService)
|
||||
{
|
||||
_profileService = profileService;
|
||||
_settingsService = settingsService;
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
profileEditorService.History.Subscribe(history => History = history).DisposeWith(d);
|
||||
@@ -29,16 +32,30 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
||||
.ToProperty(this, vm => vm.IsSuspended)
|
||||
.DisposeWith(d);
|
||||
});
|
||||
|
||||
ToggleBooleanSetting = ReactiveCommand.Create<PluginSetting<bool>>(ExecuteToggleBooleanSetting);
|
||||
}
|
||||
|
||||
private void ExecuteToggleBooleanSetting(PluginSetting<bool> setting)
|
||||
{
|
||||
setting.Value = !setting.Value;
|
||||
setting.Save();
|
||||
}
|
||||
|
||||
public ReactiveCommand<PluginSetting<bool>, Unit> ToggleBooleanSetting { get; }
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
public PluginSetting<bool> FocusSelectedLayer => _settingsService.GetSetting("ProfileEditor.FocusSelectedLayer", false);
|
||||
public PluginSetting<bool> ShowDataModelValues => _settingsService.GetSetting("ProfileEditor.ShowDataModelValues", false);
|
||||
public PluginSetting<bool> ShowFullPaths => _settingsService.GetSetting("ProfileEditor.ShowFullPaths", false);
|
||||
public PluginSetting<bool> AlwaysShowValues => _settingsService.GetSetting("ProfileEditor.AlwaysShowValues", false);
|
||||
public PluginSetting<bool> AlwaysApplyDataBindings => _settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", false);
|
||||
|
||||
public ProfileEditorHistory? History
|
||||
{
|
||||
get => _history;
|
||||
set => RaiseAndSetIfChanged(ref _history, value);
|
||||
}
|
||||
|
||||
public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value;
|
||||
|
||||
public bool IsSuspended
|
||||
{
|
||||
get => _isSuspended?.Value ?? false;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</TreeView.Styles>
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="{x:Type core:NodeData}">
|
||||
<StackPanel Margin="-15 1 0 1">
|
||||
<StackPanel Margin="-15 1 0 1" Background="Transparent" PointerReleased="InputElement_OnPointerReleased">
|
||||
<TextBlock Classes="BodyStrongTextBlockStyle" Text="{Binding Name}"></TextBlock>
|
||||
<TextBlock Foreground="{DynamicResource TextFillColorSecondary}" Text="{Binding Description}"></TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using Artemis.Core;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using Avalonia.Controls.PanAndZoom;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
@@ -26,4 +29,13 @@ public class NodePickerView : ReactiveUserControl<NodePickerViewModel>
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
if (sender is not IDataContextProvider {DataContext: NodeData nodeData} || ViewModel == null)
|
||||
return;
|
||||
|
||||
ViewModel.CreateNode(nodeData);
|
||||
ViewModel.IsVisible = false;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
|
||||
private bool _isVisible;
|
||||
private Point _position;
|
||||
private DateTime _closed;
|
||||
private string? _searchText;
|
||||
private object? _selectedNode;
|
||||
private IPin? _targetPin;
|
||||
@@ -43,8 +42,7 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
if (DateTime.Now - _closed > TimeSpan.FromSeconds(10))
|
||||
SearchText = null;
|
||||
SearchText = null;
|
||||
TargetPin = null;
|
||||
|
||||
nodeSourceList.Edit(list =>
|
||||
@@ -54,24 +52,8 @@ public class NodePickerViewModel : ActivatableViewModelBase
|
||||
});
|
||||
|
||||
IsVisible = true;
|
||||
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
_closed = DateTime.Now;
|
||||
IsVisible = false;
|
||||
}).DisposeWith(d);
|
||||
Disposable.Create(() => IsVisible = false).DisposeWith(d);
|
||||
});
|
||||
|
||||
this.WhenAnyValue(vm => vm.SelectedNode)
|
||||
.WhereNotNull()
|
||||
.Where(o => o is NodeData)
|
||||
.Throttle(TimeSpan.FromMilliseconds(200), RxApp.MainThreadScheduler)
|
||||
.Subscribe(data =>
|
||||
{
|
||||
CreateNode((NodeData) data);
|
||||
IsVisible = false;
|
||||
SelectedNode = null;
|
||||
});
|
||||
}
|
||||
|
||||
public ReadOnlyObservableCollection<DynamicData.List.IGrouping<NodeData, string>> Categories { get; }
|
||||
|
||||
Reference in new issue
Block a user