/// <summary>
        /// Currently it is hooked up to mouse down event
        /// </summary>
        /// <param name="node"></param>
        /// <param name="evt"></param>
        public void MapNodeClick(MapNode node, NodeMouseEventArgs evt)
        {
            if (mapCtrl.MapView.NodeTextEditor.IsTextEditing)
            {
                mapCtrl.EndNodeEdit();
                return;
            }

            bool shiftKeyDown = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
            bool ctrlKeyDown = (Control.ModifierKeys & Keys.Control) == Keys.Control;

            // Toggle folding or follow link (node has children + no key modifier)
            if (node.HasChildren && !shiftKeyDown && !ctrlKeyDown)
            {
                mapCtrl.MapView.SelectedNodes.Add(node, shiftKeyDown || ctrlKeyDown);
                if (node.Link == null || evt.NodePortion == NodePortion.Body)
                {
                    if (node.Parent != null) mapCtrl.ToggleFolded(node);
                }
                else
                {
                    mapCtrl.FollowLink(node);
                }
            }
            // deselect already selected node (ctrl key + node already selected)
            else if (mapCtrl.MapView.SelectedNodes.Count > 1 && mapCtrl.MapView.SelectedNodes.Contains(node) && ctrlKeyDown)
            {
                mapCtrl.MapView.SelectedNodes.Remove(node);
            }
            else
            {
                mapCtrl.MapView.SelectedNodes.Add(node, shiftKeyDown || ctrlKeyDown);

                //edit node or follow link (no children + only selected node + no key modifier)
                if (mapCtrl.MapView.SelectedNodes.Count == 1 && !node.HasChildren &&
                !shiftKeyDown && !ctrlKeyDown)
                {
                    if (node.Link == null)
                    {
                        mapCtrl.BeginNodeEdit(node, TextCursorPosition.End);
                    }
                    else
                    {
                        mapCtrl.FollowLink(node);
                    }
                }
            }
        }
示例#2
0
 void Canvas_NodeRightClick(MapNode node, NodeMouseEventArgs args)
 {
     ContextMenu.Show(MapView.Canvas, args.Location);
 }
 internal void NodeDragStart(MapNode node, NodeMouseEventArgs e)
 {
     if(!node.Selected)
     {
         node.Selected = true;
     }
 }
        internal void NodeRightClick(MapNode node, NodeMouseEventArgs e)
        {
            if (mapCtrl.MapView.NodeTextEditor.IsTextEditing)
                mapCtrl.EndNodeEdit();

            bool shiftKeyDown = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
            bool ctrlKeyDown = (Control.ModifierKeys & Keys.Control) == Keys.Control;

            if (!shiftKeyDown && !ctrlKeyDown)
                mapCtrl.MapView.Tree.SelectedNodes.Add(node);
        }
        public void MapNodeMouseOver(MapNode node, NodeMouseEventArgs evt)
        {
            if (mapCtrl.MapView.NodeTextEditor.IsTextEditing) return;

            if (Control.ModifierKeys != Keys.None || mapCtrl.MapView.SelectedNodes.Count > 1)
            {
                return;
            }

            mapCtrl.MapView.SelectedNodes.Add(node, false);

            if (node.Link != null)
            {
                if (!node.HasChildren)
                {
                    mapCtrl.MapView.Canvas.Cursor = Cursors.Hand;
                }
                else if (node.HasChildren)
                {
                    if (evt.NodePortion == NodePortion.Head)
                        mapCtrl.MapView.Canvas.Cursor = Cursors.Hand;
                    else
                        mapCtrl.MapView.Canvas.Cursor = Cursors.Default;
                }
            }
            else
            {
                mapCtrl.MapView.Canvas.Cursor = Cursors.Default;
            }

            return;
        }