using System; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using Core.Common.Utils.Events; namespace Core.Common.Controls.TreeView { /// /// Defines logic for building treeViewNodes based on a certain node datatype. /// public interface ITreeNodePresenter { /// /// TreeView containing the nodes. /// ITreeView TreeView { get; set; } /// /// Gets supported type of the object for this builder. /// Type NodeTagType { get; } /// /// Apply properties to newly created newNode. /// /// /// /// /// void UpdateNode(ITreeNode parentNode, ITreeNode node, object nodeData); /// /// Returns array of child objects for for which nodes should be added. /// /// The data belonging to the parent node. /// /// The collection of child objects. /// Post condition: Shall not return null. /// IEnumerable GetChildNodeObjects(object parentNodeData); /// /// Indicates whether the node text property is editable. /// /// The node to be renamed. /// True if can be renamed, false otherwise. /// Any that can return true with this method, should use for renaming logic. /// bool CanRenameNode(ITreeNode node); /// /// Indicates that the can be renamed and newName is a valid name. /// /// The node to be renamed. /// Suggested new name for . /// True if can be renamed, false otherwise. /// Any that can return true with this method, should use for renaming logic. /// bool CanRenameNodeTo(ITreeNode node, string newName); /// /// Renames the node /// /// Entity to be renamed. /// New name for . /// /// void OnNodeRenamed(object nodeData, string newName); /// /// When the node has a checkbox, this method handles the data operation for checking/unchecking the node. /// /// void OnNodeChecked(ITreeNode node); /// /// Indicates if a node can be dragged to another location. /// /// The data contained within the dragged node. /// The return value indicates which operation is valid. DragOperations CanDrag(object nodeData); /// /// Indicates if a node can be dropped to another location. /// /// The data-object being dragged. /// The node corresponding with . /// The node being considered as drop target for . /// The supported drop operations of . /// The return value indicates what operation is valid when the sourceNode is dropped onto the targetNode. /// This can only one of the following values /// None, Move /// ControlKeys pressed by the user should also be considered. /// examples: /// CanDrag: Folder can be moved /// shift key is move /// default is move for folder in same project /// /// This method should be called for the node presenter of . /// TODO: change item, sourceParentNodeData, targetParentNodeData to ITreeNode! DragOperations CanDrop(object item, ITreeNode sourceNode, ITreeNode targetNode, DragOperations validOperations); /// /// Checks if insertion at a specific index into the target is allowed. /// /// The data-object being dragged. /// The node corresponding with . /// The node being considered as drop target for . /// True if insertion is supported; false otherwise. bool CanInsert(object item, ITreeNode sourceNode, ITreeNode targetNode); /// /// Handles dropping a piece of data onto another node. /// /// The data-object being dropped. /// The owner of . /// The data-object onto which is being dropped. /// The type of drag operation performed. /// /// This method should be called for the node presenter of the node corresponding /// with . /// TODO: change item, itemParent, target to ITreeNode! void OnDragDrop(object item, object itemParent, object target, DragOperations operation, int position); /// /// In case a node is selected by the user it might be necessary to notify observers. /// /// void OnNodeSelected(object nodeData); /// /// Returns context menu based on current data /// ContextMenuStrip GetContextMenu(ITreeNode node, object nodeData); /// /// Updates node due to it's property change. /// void OnPropertyChanged(object sender, ITreeNode node, PropertyChangedEventArgs e); /// /// Reflect changes in the collection of items contained by the e.Item to the tree /// /// Sender of the event /// Event arguments, e.Item contains object which was added / removed void OnCollectionChanged(object sender, NotifyCollectionChangeEventArgs e); // TODO: check it we need to replace these methods with OnKeyPressed() /// /// Indicates wether a nodeData can be removed from parentNodeData. /// /// /// /// bool CanRemove(object parentNodeData, object nodeData); /// /// Allow for deletion of node data from within the treeview. /// /// /// /// true if remove operation is processed bool RemoveNodeData(object parentNodeData, object nodeData); } }