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 { /// /// Provides a common implementation of a tree node model. /// [ContentProperty("Children")] public class TreeNodeModel : BindableBase { private ObservableCollection children = new ObservableCollection(); private DelegateCommand _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; /// /// Gets the collection of child nodes. /// /// The collection of child nodes. public ObservableCollection Children { get { return children ?? (children = new ObservableCollection()); } } /// /// Gets or sets the default action command. /// /// The default action command. public DelegateCommand DefaultActionCommand { get { return _defaultActionCommand; } set { SetProperty(ref _defaultActionCommand, value); } } /// /// Gets or sets the for an image to display on the node. /// /// The for an image to display on the node. public ImageSource ImageSource { get { return _imageSource; } set { SetProperty(ref _imageSource, value); } } /// /// Gets or sets whether the node is draggable. /// /// /// true if the node is draggable; otherwise, false. /// public bool IsDraggable { get { return _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 { return _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 { return _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 { return _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 { return _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 { return _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 { return _isSelected; } set { SetProperty(ref _isSelected, value); } } /// /// Gets or sets the name of the node. /// /// The name of the node. public string Name { get { return _name; } set { SetProperty(ref _name, value); } } /// /// Gets or sets custom data for the node. /// /// The custom data for the node. public object Tag { get { return _tag; } set { SetProperty(ref _tag, value); } } /// /// Returns a representation of this instance. /// /// /// A representation of this instance. /// public override string ToString() { return $"{GetType().Name}[Name={Name}]"; } } }