using System;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Core.Common.Utils.Collections;
namespace Core.Common.Controls
{
///
/// 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 specified by
/// The parent node whose child object should be returned
///
/// The collection of child objects.
/// Post condition: Shall not return null.
///
IEnumerable GetChildNodeObjects(object parentNodeData, ITreeNode node);
///
/// 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 return value indicates which operations are valid.
/// DragOperations can be xored
/// examples:
/// folder can be moved and copied
/// output vars of models can be linked
///
DragOperations CanDrag(object nodeData);
///
/// Indicates if a node can be dropped to another location.
///
///
///
///
///
///
/// 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, Copy, Link, Move
/// ControlKeys pressed by the user should also be considered.
/// examples:
/// CanDrag: Folder can be moved or copied
/// shift key is move
/// ctrl key is copy
/// alt key is liknk but not supported -> default
/// default is move for folder in same project
/// is copy for folder to other project
///
/// TODO: change item, sourceParentNodeData, targetParentNodeData to ITreeNode!
DragOperations CanDrop(object item, ITreeNode sourceNode, ITreeNode targetNode, DragOperations validOperations);
///
///
///
///
///
///
bool CanInsert(object item, ITreeNode sourceNode, ITreeNode targetNode);
///
/// when a node is dropped onto a target node, this method handles the necessary data operations.
///
/// Item being dropped
///
/// Target node data where is being dropped.
///
///
/// TODO: change item, sourceParentNodeData, targetParentNodeData to ITreeNode!
void OnDragDrop(object item, object sourceParentNodeData, object targetParentNodeData, 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 sender, 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, NotifyCollectionChangingEventArgs 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);
}
}