コード例 #1
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }