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 _children = new ObservableCollection(); private DelegateCommand _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 ///////////////////////////////////////////////////////////////////////////////////////////////////// /// /// Gets the collection of child nodes. /// /// The collection of child nodes. public ObservableCollection Children => _children ?? (_children = new ObservableCollection()); /// /// Gets or sets the default action command. /// /// The default action command. public DelegateCommand DefaultActionCommand { get => _defaultActionCommand; set { _defaultActionCommand = value; OnPropertyChanged(); } } /// /// Gets or sets whether the node is draggable. /// /// /// true if the node is draggable; otherwise, false. /// public bool IsDraggable { get => _isDraggable; set => SetProperty(ref _isDraggable, value); } /// /// Gets or sets whether the node is editable. /// /// /// true if the node is editable; otherwise, false. /// public bool IsEditable { get => _isEditable; set => SetProperty(ref _isEditable, value); } /// /// Gets or sets whether the node is currently being edited. /// /// /// true if the node is currently being edited; otherwise, false. /// public bool IsEditing { get => _isEditing; set => SetProperty(ref _isEditing, value); } /// /// Gets or sets whether the node is expanded. /// /// /// true if the node is expanded; otherwise, false. /// public bool IsExpanded { get => _isExpanded; set => SetProperty(ref _isExpanded, value); } /// /// Gets or sets whether the node is currently loading children asynchronously. /// /// /// true if the node is currently loading children asynchronously; otherwise, false. /// public bool IsLoading { get => _isLoading; set => SetProperty(ref _isLoading, value); } /// /// Gets or sets whether the node is capable of being selected. /// /// /// true if the node is capable of being selected; otherwise, false. /// public bool IsSelectable { get => _isSelectable; set => SetProperty(ref _isSelectable, value); } /// /// Gets or sets whether the node is selected. /// /// /// true if the node is selected; otherwise, false. /// public bool IsSelected { get => _isSelected; set => SetProperty(ref _isSelected, value); } /// /// Gets the name of the node. /// public string Name { get; } /// /// Gets or sets custom data for the node. /// /// The custom data for the node. public object Tag { get => _tag; set => SetProperty(ref _tag, value); } /// /// Returns a representation of this instance. /// /// /// A representation of this instance. /// public override string ToString() => $"{GetType().Name}[Name={Name}]"; } }