174 lines
5.4 KiB
C#
174 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
using ActiproSoftware.Windows.Input;
|
|
using Plume.WPF.Mvvm;
|
|
|
|
namespace JD.AssetBrowser.Model
|
|
{
|
|
/// <summary>
|
|
/// Provides a common implementation of a tree node model.
|
|
/// </summary>
|
|
[ContentProperty("Children")]
|
|
public class TreeNodeModel : BindableBase
|
|
{
|
|
private ObservableCollection<TreeNodeModel> children = new ObservableCollection<TreeNodeModel>();
|
|
private DelegateCommand<object> _defaultActionCommand;
|
|
private ImageSource _imageSource;
|
|
private bool _isDraggable = true;
|
|
private bool _isEditable;
|
|
private bool _isEditing;
|
|
private bool _isExpanded;
|
|
private bool _isLoading;
|
|
private bool _isSelectable = true;
|
|
private bool _isSelected;
|
|
private string _name;
|
|
private object _tag;
|
|
|
|
/// <summary>
|
|
/// Gets the collection of child nodes.
|
|
/// </summary>
|
|
/// <value>The collection of child nodes.</value>
|
|
public ObservableCollection<TreeNodeModel> Children
|
|
{
|
|
get { return children ?? (children = new ObservableCollection<TreeNodeModel>()); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the default action command.
|
|
/// </summary>
|
|
/// <value>The default action command.</value>
|
|
public DelegateCommand<object> DefaultActionCommand
|
|
{
|
|
get { return _defaultActionCommand; }
|
|
set { SetProperty(ref _defaultActionCommand, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the <see cref="ImageSource"/> for an image to display on the node.
|
|
/// </summary>
|
|
/// <value>The <see cref="ImageSource"/> for an image to display on the node.</value>
|
|
public ImageSource ImageSource
|
|
{
|
|
get { return _imageSource; }
|
|
set { SetProperty(ref _imageSource, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is draggable.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is draggable; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsDraggable
|
|
{
|
|
get { return _isDraggable; }
|
|
set { SetProperty(ref _isDraggable, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is editable.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is editable; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsEditable
|
|
{
|
|
get { return _isEditable; }
|
|
set { SetProperty(ref _isEditable, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is currently being edited.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is currently being edited; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsEditing
|
|
{
|
|
get { return _isEditing; }
|
|
set { SetProperty(ref _isEditing, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is expanded.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is expanded; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsExpanded
|
|
{
|
|
get { return _isExpanded; }
|
|
set { SetProperty(ref _isExpanded, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is currently loading children asynchronously.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is currently loading children asynchronously; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsLoading
|
|
{
|
|
get { return _isLoading; }
|
|
set { SetProperty(ref _isLoading, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is capable of being selected.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is capable of being selected; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsSelectable
|
|
{
|
|
get { return _isSelectable; }
|
|
set { SetProperty(ref _isSelectable, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the node is selected.
|
|
/// </summary>
|
|
/// <value>
|
|
/// <c>true</c> if the node is selected; otherwise, <c>false</c>.
|
|
/// </value>
|
|
public bool IsSelected
|
|
{
|
|
get { return _isSelected; }
|
|
set { SetProperty(ref _isSelected, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the name of the node.
|
|
/// </summary>
|
|
/// <value>The name of the node.</value>
|
|
public string Name
|
|
{
|
|
get { return _name; }
|
|
set { SetProperty(ref _name, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets custom data for the node.
|
|
/// </summary>
|
|
/// <value>The custom data for the node.</value>
|
|
public object Tag
|
|
{
|
|
get { return _tag; }
|
|
set { SetProperty(ref _tag, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a <see cref="String"/> representation of this instance.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// A <see cref="String"/> representation of this instance.
|
|
/// </returns>
|
|
public override string ToString()
|
|
{
|
|
return $"{GetType().Name}[Name={Name}]";
|
|
}
|
|
|
|
}
|
|
}
|