24 changed files with 227 additions and 75 deletions
@ -0,0 +1,29 @@ |
|||||
|
// -----------------------------------------------------------------------
|
||||
|
// <copyright file="LogicalTreeNode.cs" company="Steven Kirk">
|
||||
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
||||
|
// </copyright>
|
||||
|
// -----------------------------------------------------------------------
|
||||
|
|
||||
|
namespace Perspex.Diagnostics.ViewModels |
||||
|
{ |
||||
|
using System; |
||||
|
using Perspex.Controls; |
||||
|
using ReactiveUI; |
||||
|
|
||||
|
internal class LogicalTreeNode : TreeNode |
||||
|
{ |
||||
|
private string classes; |
||||
|
|
||||
|
public LogicalTreeNode(ILogical logical) |
||||
|
: base((Control)logical) |
||||
|
{ |
||||
|
this.Children = logical.LogicalChildren.CreateDerivedCollection(x => new LogicalTreeNode(x)); |
||||
|
} |
||||
|
|
||||
|
public static LogicalTreeNode[] Create(object control) |
||||
|
{ |
||||
|
var logical = control as ILogical; |
||||
|
return logical != null ? new[] { new LogicalTreeNode(logical) } : null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
// -----------------------------------------------------------------------
|
||||
|
// <copyright file="LogicalTreeNode.cs" company="Steven Kirk">
|
||||
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
||||
|
// </copyright>
|
||||
|
// -----------------------------------------------------------------------
|
||||
|
|
||||
|
namespace Perspex.Diagnostics.ViewModels |
||||
|
{ |
||||
|
using System; |
||||
|
using System.Reactive; |
||||
|
using System.Reactive.Linq; |
||||
|
using Perspex.Controls; |
||||
|
using ReactiveUI; |
||||
|
|
||||
|
internal class TreeNode : ReactiveObject |
||||
|
{ |
||||
|
private string classes; |
||||
|
|
||||
|
public TreeNode(Control control) |
||||
|
{ |
||||
|
this.Control = control; |
||||
|
this.Type = control.GetType().Name; |
||||
|
|
||||
|
control.Classes.Changed.Select(_ => Unit.Default) |
||||
|
.StartWith(Unit.Default) |
||||
|
.Subscribe(_ => |
||||
|
{ |
||||
|
if (control.Classes.Count > 0) |
||||
|
{ |
||||
|
this.Classes = "(" + string.Join(" ", control.Classes) + ")"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
this.Classes = string.Empty; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public IReactiveDerivedList<TreeNode> Children |
||||
|
{ |
||||
|
get; |
||||
|
protected set; |
||||
|
} |
||||
|
|
||||
|
public string Classes |
||||
|
{ |
||||
|
get { return this.classes; } |
||||
|
private set { this.RaiseAndSetIfChanged(ref this.classes, value); } |
||||
|
} |
||||
|
|
||||
|
public string Type |
||||
|
{ |
||||
|
get; |
||||
|
private set; |
||||
|
} |
||||
|
|
||||
|
public Control Control |
||||
|
{ |
||||
|
get; |
||||
|
private set; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue