protected override void OnApply(LinkLineNode node)
        {
            LinkLineNode node1 = GetLineNode(_node1);
            LinkLineNode node2 = GetLineNode(_node2);
            LinkLineNode start = (LinkLineNode)node1.PrevNode;
            LinkLineNode end   = (LinkLineNode)node2.NextNode;

            node1.ClearLine();
            node2.ClearLine();
            node.Parent.Controls.Remove(node1);
            node.Parent.Controls.Remove(node2);
            start.SetNext(end);
            end.SetPrevious(start);
            if (start.Line == null)
            {
                start.CreateForwardLine();
            }
            else
            {
                end.CreateBackwardLine();
            }
            if (start.LinkedOutPort != null)
            {
                if (end.LinkedInPort != null)
                {
                    start.LinkedOutPort.LinkedPortID = end.LinkedInPort.PortID;
                    end.LinkedInPort.LinkedPortID    = start.LinkedOutPort.PortID;
                }
            }
            ActiveDrawing.RefreshControl(node.Parent);
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            LinkLineNode nodeTest = HitTest(e.X, e.Y);

            if (nodeTest != null)
            {
                this.Cursor = Cursors.Hand;
                nodeTest.SelectLine(true);
            }
            else
            {
                this.Cursor = Cursors.Default;
            }
            if (!bMouseIn)
            {
                bMouseIn = true;
                for (int i = 0; i < Controls.Count; i++)
                {
                    ActiveDrawing ad = Controls[i] as ActiveDrawing;
                    if (ad != null)
                    {
                        ad.FireOnLeave(e);
                    }
                }
            }
        }
        public void SetMouseUpControl()
        {
            ActiveDrawing a = _mouseDownControl;

            _mouseDownControl = null;
            OnActiveDrawingMouseUp(a);
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (!bMouseEnter)
            {
                bMouseEnter = true;
                if (this.Parent != null)
                {
                    for (int i = 0; i < this.Parent.Controls.Count; i++)
                    {
                        ActiveDrawing ad = this.Parent.Controls[i] as ActiveDrawing;
                        if (ad != null && ad != this)
                        {
                            ad.FireOnLeave(EventArgs.Empty);
                        }
                    }
                }
                Diagram dg = this.Parent as Diagram;
                if (dg != null)
                {
                    dg.OnChildActiveDrawingMouseEnter(this);
                }
                OnEnter(EventArgs.Empty);
            }
            const int MARGIN_D = 2;

            if (this.Parent != null && (e.Button & MouseButtons.Left) == MouseButtons.Left && bMD)
            {
                int  offsetX = 0;
                int  offsetY = 0;
                bool b       = false;
                if (!this.Capture)
                {
                    this.Capture = true;
                }
                int   x  = this.Left + e.X - x0;
                int   xd = this.Left;
                int   yd = this.Top;
                Point p0 = this.Parent.PointToClient(this.PointToScreen(e.Location));
                if (p0.X > MARGIN_D && p0.X < this.Parent.ClientSize.Width - MARGIN_D)
                {
                    xd = x;
                    b  = true;
                }
                int y = this.Top + e.Y - y0;
                if (p0.Y > MARGIN_D && p0.Y < this.Parent.ClientSize.Height - MARGIN_D)
                {
                    yd = y;
                    b  = true;
                }
                if (b)
                {
                    this.Location = new Point(xd - offsetX, yd - offsetY);
                    RefreshParent();
                }
            }
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            ActiveDrawing ad = _owner as ActiveDrawing;

            if (ad != null)
            {
                ad.OnRelativeDrawingMouseDown(this, e);
            }
        }
        protected override void OnLeave(EventArgs e)
        {
            base.OnLeave(e);
            ActiveDrawing ad = _owner as ActiveDrawing;

            if (ad != null)
            {
                ad.OnRelativeDrawingMouseLeave(this);
            }
        }
 public void SaveLocations()
 {
     for (int i = 0; i < Controls.Count; i++)
     {
         ActiveDrawing a = Controls[i] as ActiveDrawing;
         if (a != null)
         {
             a.SaveLocation();
         }
     }
 }
        protected override void OnMove(EventArgs e)
        {
            base.OnMove(e);
            SaveLocation();
            SaveRelativePosition();
            ActiveDrawing ad = _owner as ActiveDrawing;

            if (ad != null)
            {
                ad.OnRelativeDrawingMove(this);
            }
        }
 public ActiveDrawing GetActiveDrawingById(UInt32 id)
 {
     foreach (Control c in Controls)
     {
         ActiveDrawing ad = c as ActiveDrawing;
         if (ad != null)
         {
             if (ad.ActiveDrawingID == id)
             {
                 return(ad);
             }
         }
     }
     return(null);
 }
        protected override void OnEnter(EventArgs e)
        {
            base.OnEnter(e);
            ActiveDrawing ad = _owner as ActiveDrawing;

            if (ad != null)
            {
                ad.OnRelativeDrawingMouseEnter(this);
            }
            Diagram dv = this.Parent as Diagram;

            if (dv != null)
            {
                dv.OnChildActiveDrawingMouseEnter(this);
            }
        }
        public void Apply()
        {
            bool b = _host.DisableUndo;

            _host.DisableUndo = true;
            Control c = _host.GetUndoControl(_ctrlKey);

            if (c != null)
            {
                c.Size = _size;
                if (c.Parent != null)
                {
                    ActiveDrawing.RefreshControl(c.Parent);
                }
            }
            _host.DisableUndo = b;
        }
        private void miDisconnectNodes_Click(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                NodeData nd = mi.Tag as NodeData;
                if (nd != null)
                {
                    LinkLineNode node = nd.Node;

                    if (node != null)
                    {
                        if (nd.Data != null)
                        {
                            if (nd.Data.GetType().Equals(typeof(Point)))
                            {
                                Point pt = (Point)nd.Data;
                                if (node.Line != null)
                                {
                                    //===================
                                    UInt32             key  = node.ActiveDrawingID;
                                    UInt32             key1 = 0;
                                    UInt32             key2 = 0;
                                    LinkLineNodeInPort ip   = node.LinkedInPort;
                                    node.BreakLine(pt, ref key1, ref key2);
                                    OnDisconnectLine(ip);
                                    if (UndoHost != null)
                                    {
                                        if (!UndoHost.DisableUndo)
                                        {
                                            LinkLineUndoReconnect undo = new LinkLineUndoReconnect(UndoHost, key, key1, key2);
                                            LinkLineUndoBreak     redo = new LinkLineUndoBreak(UndoHost, key, key1, key2, pt);
                                            UndoHost.AddUndoEntity(new UndoEntity(undo, redo));
                                        }
                                    }
                                    ActiveDrawing.RefreshControl(this);
                                }
                            }
                        }
                    }
                }
            }
        }
        private void miAddLineNode_Click(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                NodeData nd = mi.Tag as NodeData;
                if (nd != null)
                {
                    LinkLineNode node = nd.Node;

                    if (node != null)
                    {
                        if (nd.Data != null)
                        {
                            if (nd.Data.GetType().Equals(typeof(Point)))
                            {
                                Point pt = (Point)nd.Data;
                                if (node.Line != null)
                                {
                                    UInt32       key2    = node.ActiveDrawingID;
                                    LinkLineNode newNode = node.InsertNode(pt.X + 5, pt.Y + 5);
                                    if (UndoHost != null)
                                    {
                                        if (!UndoHost.DisableUndo)
                                        {
                                            UInt32     key1   = newNode.ActiveDrawingID;
                                            UndoEntity entity = new UndoEntity(
                                                new LinkLineUndoDelete(UndoHost, key1), new LinkLineUndoAdd(UndoHost, key2, pt));
                                            UndoHost.AddUndoEntity(entity);
                                        }
                                    }
                                    newNode.SaveLocation();
                                    newNode.Selected = true;
                                    ActiveDrawing.RefreshControl(this);
                                    OnLineNodeAdded(newNode);
                                }
                            }
                        }
                    }
                }
            }
        }
        protected override void OnApply(LinkLineNode node)
        {
            LinkLineNode prevNode = node;

            if (prevNode != null)
            {
                LinkLineNode nextNode = GetLineNode(_next);
                if (nextNode != null)
                {
                    if (prevNode.Line != null)
                    {
                        if (prevNode.Line.EndPoint == nextNode)
                        {
                            prevNode.ClearLine();
                        }
                    }
                    if (nextNode.Line != null)
                    {
                        if (nextNode.Line.StartPoint == prevNode)
                        {
                            nextNode.ClearLine();
                        }
                    }
                    LinkLineNode newNode = new LinkLineNode(nextNode, prevNode);
                    newNode.Location        = _point;
                    newNode.ActiveDrawingID = _deleted;
                    nextNode.Parent.Controls.Add(newNode);
                    if (prevNode.Line == null)
                    {
                        prevNode.CreateForwardLine();
                        newNode.CreateForwardLine();
                    }
                    else
                    {
                        newNode.CreateBackwardLine();
                        nextNode.CreateBackwardLine();
                    }
                    ActiveDrawing.RefreshControl(nextNode.Parent);
                }
            }
        }
예제 #15
0
 private void showEditor(IMathExpression exp)
 {
     try
     {
         Rectangle   rc  = this.Parent.RectangleToScreen(this.Bounds);
         IMathEditor dlg = exp.CreateEditor(rc);
         if (((Form)dlg).ShowDialog(this.FindForm()) == DialogResult.OK)
         {
             LoadData(dlg.MathExpression);
             //
             Refresh();
             if (this.Parent != null)
             {
                 ActiveDrawing.RefreshControl(this.Parent);
             }
             setChanged();
         }
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
     }
 }
 protected override void OnApply(LinkLineNode node)
 {
     node.BreakLine(_point, ref _node1, ref _node2);
     ActiveDrawing.RefreshControl(node.Parent);
 }
 public void SetMouseDownControl(ActiveDrawing ad)
 {
     _mouseDownControl = ad;
     OnActiveDrawingMouseDown();
 }
 public virtual void OnActiveDrawingMouseUp(ActiveDrawing a)
 {
 }
 public void OnChildActiveDrawingMouseEnter(ActiveDrawing actDrwing)
 {
     bMouseIn = false;
 }