163 lines
5.2 KiB
C#
163 lines
5.2 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.Windows.Markup;
|
|
using Plume.WPF.Commands;
|
|
using Plume.WPF.Mvvm;
|
|
|
|
namespace JD.Oasis.Module.ViewModel.TreeViewModel.Common
|
|
{
|
|
[ContentProperty("Children")]
|
|
public class TreeNodeViewModel : BindableBase
|
|
{
|
|
|
|
private ObservableCollection<TreeNodeViewModel> _children = new ObservableCollection<TreeNodeViewModel>();
|
|
private DelegateCommand<object> _defaultActionCommand;
|
|
private bool _isDraggable = true;
|
|
private bool _isEditable;
|
|
private bool _isEditing;
|
|
private bool _isExpanded;
|
|
private bool _isLoading;
|
|
private bool _isSelectable = true;
|
|
private bool _isSelected;
|
|
private object _tag;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// CONSTRUCTOR
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
public TreeNodeViewModel(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// PUBLIC PROCEDURES
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
/// Gets the collection of child nodes.
|
|
/// </summary>
|
|
/// <value>The collection of child nodes.</value>
|
|
public ObservableCollection<TreeNodeViewModel> Children => _children ?? (_children = new ObservableCollection<TreeNodeViewModel>());
|
|
|
|
/// <summary>
|
|
/// Gets or sets the default action command.
|
|
/// </summary>
|
|
/// <value>The default action command.</value>
|
|
public DelegateCommand<object> DefaultActionCommand
|
|
{
|
|
get => _defaultActionCommand;
|
|
set
|
|
{
|
|
_defaultActionCommand = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
|
|
/// <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 => _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 => _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 => _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 => _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 => _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 => _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 => _isSelected;
|
|
set => SetProperty(ref _isSelected, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the name of the node.
|
|
/// </summary>
|
|
public string Name { get; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets custom data for the node.
|
|
/// </summary>
|
|
/// <value>The custom data for the node.</value>
|
|
public object Tag
|
|
{
|
|
get => _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() => $"{GetType().Name}[Name={Name}]";
|
|
}
|
|
}
|