|
|
@ -7,6 +7,7 @@ using System.Reactive; |
|
|
using System.Reactive.Linq; |
|
|
using System.Reactive.Linq; |
|
|
using Avalonia.Controls; |
|
|
using Avalonia.Controls; |
|
|
using Avalonia.Styling; |
|
|
using Avalonia.Styling; |
|
|
|
|
|
using Avalonia.VisualTree; |
|
|
using ReactiveUI; |
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
|
namespace Avalonia.Diagnostics.ViewModels |
|
|
namespace Avalonia.Diagnostics.ViewModels |
|
|
@ -16,32 +17,35 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
private string _classes; |
|
|
private string _classes; |
|
|
private bool _isExpanded; |
|
|
private bool _isExpanded; |
|
|
|
|
|
|
|
|
public TreeNode(Control control, TreeNode parent) |
|
|
public TreeNode(IVisual control, TreeNode parent) |
|
|
{ |
|
|
{ |
|
|
Control = control; |
|
|
|
|
|
Parent = parent; |
|
|
Parent = parent; |
|
|
Type = control.GetType().Name; |
|
|
Type = control.GetType().Name; |
|
|
|
|
|
Control = control; |
|
|
|
|
|
|
|
|
var classesChanged = Observable.FromEventPattern< |
|
|
if (control is IStyleable styleable) |
|
|
NotifyCollectionChangedEventHandler, |
|
|
{ |
|
|
NotifyCollectionChangedEventArgs>( |
|
|
var classesChanged = Observable.FromEventPattern< |
|
|
x => control.Classes.CollectionChanged += x, |
|
|
NotifyCollectionChangedEventHandler, |
|
|
x => control.Classes.CollectionChanged -= x) |
|
|
NotifyCollectionChangedEventArgs>( |
|
|
.TakeUntil(((IStyleable)control).StyleDetach); |
|
|
x => styleable.Classes.CollectionChanged += x, |
|
|
|
|
|
x => styleable.Classes.CollectionChanged -= x) |
|
|
|
|
|
.TakeUntil(((IStyleable)styleable).StyleDetach); |
|
|
|
|
|
|
|
|
classesChanged.Select(_ => Unit.Default) |
|
|
classesChanged.Select(_ => Unit.Default) |
|
|
.StartWith(Unit.Default) |
|
|
.StartWith(Unit.Default) |
|
|
.Subscribe(_ => |
|
|
.Subscribe(_ => |
|
|
{ |
|
|
|
|
|
if (control.Classes.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
Classes = "(" + string.Join(" ", control.Classes) + ")"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
{ |
|
|
Classes = string.Empty; |
|
|
if (styleable.Classes.Count > 0) |
|
|
} |
|
|
{ |
|
|
}); |
|
|
Classes = "(" + string.Join(" ", styleable.Classes) + ")"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Classes = string.Empty; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public IReadOnlyReactiveList<TreeNode> Children |
|
|
public IReadOnlyReactiveList<TreeNode> Children |
|
|
@ -56,7 +60,7 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
private set { this.RaiseAndSetIfChanged(ref _classes, value); } |
|
|
private set { this.RaiseAndSetIfChanged(ref _classes, value); } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Control Control |
|
|
public IVisual Control |
|
|
{ |
|
|
{ |
|
|
get; |
|
|
get; |
|
|
} |
|
|
} |
|
|
|