void TreeViewAfterLabelEdit(object sender, NodeLabelEditEventArgs e) { var label = e.Label; if (label != null && AfterLabelEdit != null) { // Fire the event AFTER tree node editing took place. Weired behaviour otherwise. // See http://www.codeproject.com/KB/tree/CustomizedLabelEdit.aspx and comments var doItLater = new DoItLater( delegate() { var args = new VVVV.Core.Viewer.LabelEditEventArgs(e.Node.Tag, label); AfterLabelEdit(this, args); if (args.CancelEdit) { e.Node.BeginEdit(); } else { FTreeView.SelectedNode = e.Node; } }); FTreeView.BeginInvoke(doItLater); } e.CancelEdit = true; }
void FTreeViewMouseMove(object sender, MouseEventArgs e) { if (!ShowTooltip) { return; } var treeNode = FTreeView.GetNodeAt(e.Location) as MapperTreeNode; if (treeNode != FLastTooltipNode) { InvalidateTreeNode(FLastTooltipNode); FLastTooltipNode = treeNode; InvalidateTreeNode(FLastTooltipNode); if (treeNode != null) { var mapper = treeNode.Mapper; if (mapper.CanMap <IDescripted>()) { string tip = mapper.Map <IDescripted>().Description; if (!string.IsNullOrEmpty(tip)) { FToolTip.Show(tip, FTreeView, e.X + 15, treeNode.Bounds.Y + 30); return; } } } HideToolTip(); } }
public override void Reload() { FTreeView.BeginUpdate(); if (FRootMapper != null) { FRootMapper.Dispose(); } FRootMapper = new ModelMapper(Input, Registry); if (ShowRoot) { var rootNode = new MapperTreeNode(FRootMapper); rootNode.Expand(); FTreeView.Nodes.Add(rootNode); } else { var items = FRootMapper.Map <IParent>(); if (FSynchronizer != null) { FSynchronizer.Dispose(); } FSynchronizer = FTreeView.Nodes.SyncWith(items.Childs, item => new MapperTreeNode(FRootMapper.CreateChildMapper(item))); } FTreeView.EndUpdate(); }
void FTreeViewAfterSelect(object sender, TreeViewEventArgs e) { SelectedNode = e.Node; var doItLater = new DoItLater(() => OnSelectionChanged(CurrentSelection)); FTreeView.BeginInvoke(doItLater); }
void InvalidateTreeNode(TreeNode treeNode) { if (treeNode != null) { var bounds = new Rectangle(0, treeNode.Bounds.Y, FTreeView.Width, treeNode.Bounds.Height); FTreeView.Invalidate(bounds); } }
void TreeViewItemDrag(object sender, ItemDragEventArgs e) { var treeNode = e.Item as MapperTreeNode; var mapper = treeNode.Mapper; if (mapper.CanMap <IDraggable>()) { var dragable = mapper.Map <IDraggable>(); // check if this item allows being dragged if (dragable.AllowDrag()) { // start the dragdrop operation FTreeView.DoDragDrop(dragable.ItemToDrag(), DragDropEffects.All); } } }
void FTreeViewMouseDown(object sender, MouseEventArgs e) { HideToolTip(); var treeNode = FTreeView.GetNodeAt(e.X, e.Y) as MapperTreeNode; if (treeNode != null) { var mapper = treeNode.Mapper; //middle mousebutton is not handled in TreeViewNode_MouseClick, so do it here //as it is also obviously not handled in TreeView_MouseClick if (e.Button == MouseButtons.Middle) { OnClick(mapper, e); } else { OnMouseDown(mapper, e); } } }