mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +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
@@ -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