Beispiel #1
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (mdown.X == e.X && mdown.Y == e.Y)
            {
                select(hitTest(e.X, e.Y).node, Control.ModifierKeys == Keys.Shift);
            }

            if (bDragging)
            {
                bDragging = false;
                recalcFocus();
                return;
            }

            if (bLinking)
            {
                bLinking = false;
                Node.Address a   = hitTest(e.X, e.Y, false);
                Node.Address old = linkTo.node.getProperties()[linkTo.port].input;
                if (old != null)
                {
                    Node.disconnect(old.node, old.port, linkTo.node, linkTo.port);
                }
                if (a.node != null && a.port != null)
                {
                    Node.connect(a.node, a.port, linkTo.node, linkTo.port);
                }

                Invalidate();
                return;
            }
            base.OnMouseUp(e);
        }
Beispiel #2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            this.Focus();
            Node.Address a;

            mdown = e.Location;

            //if the mouse is over a node, selected it and begin dragging. otherwise do base.
            //  if shift is selected, toggle selection instead of replacing
            if ((a = hitTest(e.X, e.Y, true)).node != null)
            {
                if (a.port != null)
                {
                    bLinking = true;
                    ScreenToCanvas(ref mdown);
                    mdrag  = mdown;
                    linkTo = a;
                }
                else
                {
                    if (!project.selectedNodes.Contains(a.node))
                    {
                        select(a.node, Control.ModifierKeys == Keys.Shift);
                    }
                    bDragging = true;
                    ScreenToCanvas(ref mdown);
                }
            }
            else
            {
                base.OnMouseDown(e);
            }
        }