コード例 #1
0
 private void setLineSelection(LinkLineNode node, bool selected)
 {
     if (node != null)
     {
         if (selected)
         {
             node.SelectLine(selected);
         }
         else
         {
             bool bCanDeSelect = true;
             if (_selectedLine != null)
             {
                 if (_selectedLine.IsOnTheLine(node))
                 {
                     bCanDeSelect = false;
                 }
             }
             if (bCanDeSelect)
             {
                 node.SelectLine(selected);
             }
         }
     }
 }
コード例 #2
0
        private LinkLineNode HitTest(int x, int y)
        {
            LinkLineNode nodeTest = null;

            for (int i = 0; i < Controls.Count; i++)
            {
                LinkLineNode node = Controls[i] as LinkLineNode;
                if (node != null)
                {
                    if (nodeTest == null)
                    {
                        if (node.HitTest(x, y))
                        {
                            nodeTest = node;
                        }
                        else
                        {
                            setLineSelection(node, false);
                        }
                    }
                    else
                    {
                        setLineSelection(node, false);
                    }
                }
            }
            return(nodeTest);
        }
コード例 #3
0
        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);
                    }
                }
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        protected override List <Control> GetRelatedControls()
        {
            List <Control> ctrls = base.GetRelatedControls();

            if (_firerPort != null)
            {
                LinkLineNode l = _firerPort;
                ctrls.Add(l);
                if (_firerPort.Label != null && _firerPort.Label.Parent != null)
                {
                    ctrls.Add(_firerPort.Label);
                }
                l = l.NextNode as LinkLineNode;
                while (l != null)
                {
                    LinkLineNodePort p = l as LinkLineNodePort;
                    if (p != null && p.Label != null && p.Label.Parent != null)
                    {
                        ctrls.Add(p.Label);
                    }
                    ctrls.Add(l);
                    l = l.NextNode as LinkLineNode;
                }
            }
            return(ctrls);
        }
コード例 #6
0
        public void CreateViewer(MathNodeRoot item)
        {
            MathExpViewer mv = holder.AddMathViewer(item, 50, 50);
            ReturnIcon    ri = holder.CreateReturnIcon(item.DataType);

            LinkLineNode.JoinToEnd((LinkLineNode)mv.OutputPorts[0].NextNode, ri.InPort);
        }
コード例 #7
0
 protected override void OnPaint(PaintEventArgs e)
 {
     for (int i = 0; i < Controls.Count; i++)
     {
         LinkLineNode node = Controls[i] as LinkLineNode;
         if (node != null)
         {
             node.DrawLine(e.Graphics);
         }
     }
 }
コード例 #8
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            base.OnMouseDoubleClick(e);
            LinkLineNode nodeTest = HitTest(e.X, e.Y);

            if (nodeTest != null)
            {
                nodeTest.SelectLine(true);
                nodeTest.InsertNode(e.X, e.Y);
            }
        }
コード例 #9
0
        public void Apply()
        {
            bool b = _host.DisableUndo;

            _host.DisableUndo = true;
            LinkLineNode c = GetLineNode(_nodeKey);

            if (c != null)
            {
                OnApply(c);
            }
            _host.DisableUndo = b;
        }
コード例 #10
0
 /// <summary>
 /// create action components and make port links
 /// </summary>
 /// <param name="designer"></param>
 public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer)
 {
     if (designer.LoadAction(this))
     {
         if (_ifActions != null)
         {
             if (_ifActions.LoadToDesigner(used, designer))
             {
                 //make port link
                 if (this.OutPortList[0].LinkedInPort == null)
                 {
                     LinkLineNode end = this.OutPortList[0].End;
                     ActionPortIn pi  = _ifActions.GetInPort(this.OutPortList[0].LinkedPortID, this.OutPortList[0].LinkedPortInstanceID);
                     if (pi == null)
                     {
                         throw new MathException("Out port {0} is linked to [{1},{2}] of Branch {3}; but [{1},{2}] is not among the in-ports of the branch", this.OutPortList[0].PortID, this.OutPortList[0].LinkedPortID, this.OutPortList[0].LinkedPortInstanceID, _ifActions.BranchId);
                     }
                     LinkLineNode start = pi.Start;
                     end.SetNext(start);
                     start.SetPrevious(end);
                 }
             }
         }
         if (_elseActions != null)
         {
             if (_elseActions.LoadToDesigner(used, designer))
             {
                 //make port link
                 if (this.OutPortList[1].LinkedInPort == null)
                 {
                     LinkLineNode end = this.OutPortList[1].End;
                     ActionPortIn pi  = _elseActions.GetInPort(this.OutPortList[1].LinkedPortID, this.OutPortList[1].LinkedPortInstanceID);
                     if (pi == null)
                     {
                         throw new MathException("Out port {0} is linked to [{1},{2}] of Branch {3}; but [{1},{2}] is not among the in-ports of the branch", this.OutPortList[1].PortID, this.OutPortList[1].LinkedPortID, this.OutPortList[1].LinkedPortInstanceID, _elseActions.BranchId);
                     }
                     LinkLineNode start = pi.Start;
                     end.SetNext(start);
                     start.SetPrevious(end);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
コード例 #11
0
        protected override LinkLineNode CreateTargetLinkNode()
        {
            Control p = this.Parent;

            if (p != null)
            {
                ObjectDrawing ov = this.Owner as ObjectDrawing;
                if (ov != null && ov.ObjectEntity != null && ov.ObjectEntity.ProgEntity != null)
                {
                    LinkLineNode ll = ov.CreateOutport();
                    if (ll != null)
                    {
                        return(ll.End);
                    }
                }
            }
            return(null);
        }
コード例 #12
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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
 public override void LinkJumpBranches()
 {
     if (_jumpToId != 0)
     {
         if (_jumpToActionBranch == null)
         {
             throw new DesignerException("Cannot set portlink from {0} to {1}. Linked actions not set", this.BranchId, _jumpToId);
         }
         ActionPortOut po = this.OutPortList[0];
         ActionPortIn  pi = _jumpToActionBranch.GetInPort(po.LinkedPortID, po.LinkedPortInstanceID);               //.InPortList[po.LinkedPortIndex];
         if (pi == null)
         {
             throw new DesignerException("out-port {0} is linked to [{1},{2}] of the jump-to-branch {3}, but in-port [{1},{2}] is not among the in-port list of the branch",
                                         po.PortID, po.LinkedPortID, po.LinkedPortInstanceID, _jumpToActionBranch.BranchId);
         }
         LinkLineNode        start = po.End;
         LinkLineNode        end;
         LinkLineNodeOutPort pipo = pi.Start as LinkLineNodeOutPort;
         if (pipo != null)
         {
             if (pipo.LinkedPortID != pi.PortID || pipo.LinkedPortInstanceID != pi.PortInstanceID)
             {
                 throw new DesignerException("Input [{0},{1}] is already linked to [{2},{3}], cannot link it to [{4},{5}]",
                                             pi.PortID, pi.PortInstanceID, pipo.PortID, pipo.PortInstanceID, po.PortID, po.PortInstanceID);
             }
         }
         else
         {
             end = pi.Start;
             if (end != start)
             {
                 start.SetNext(end);
                 end.SetPrevious(start);
                 po.LinkedPortID = pi.PortID;
                 pi.LinkedPortID = po.PortID;
             }
             else
             {
                 //it is not an error, it is already linked
             }
         }
     }
     base.LinkJumpBranches();
 }
コード例 #14
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);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #15
0
 public void InitLinkLine()
 {
     if (pd != null)
     {
         LinkLineNodeOutPort[] _outports = this.Variable.OutPorts;
         for (int i = 0; i < _outports.Length; i++)
         {
             if (_outports[i].LinkedInPort == null)
             {
                 LinkLineNode l = _outports[i];
                 while (l != null)
                 {
                     l.CreateForwardLine();
                     ((Control)l).Visible = (l is LinkLineNodePort);
                     l = (LinkLineNode)l.NextNode;
                 }
             }
         }
     }
 }
コード例 #16
0
        public bool IsOnTheLine(LinkLineNode lineNode)
        {
            LinkLineNodeOutPort start = lineNode.Start as LinkLineNodeOutPort;

            if (start != null)
            {
                if (start.PortID == _startNode.PortID && start.PortInstanceID == _startNode.PortInstanceID)
                {
                    LinkLineNodeInPort end = lineNode.End as LinkLineNodeInPort;
                    if (end != null)
                    {
                        if (end.PortID == _endNode.PortID && end.PortInstanceID == _endNode.PortInstanceID)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #17
0
        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);
                }
            }
        }
コード例 #18
0
        public override void InitGraph()
        {
            LinkCircleNode previousNode = null;             //当前要创建的节点的前驱节点
            LinkCircleNode currentNode  = null;             //当前要创建的节点
            LinkCircleNode headNode     = null;             //头节点

            //这里一条连接线也代表一个节点
            LinkLineNode headLineNode     = null;
            LinkLineNode currentLineNode  = null;
            LinkLineNode previousLineNode = null;

            headNode     = new LinkCircleNode(40, 50, diameter, status.头结点颜色, "H");      //先创建一个头节点
            headLineNode = new LinkLineNode(40 + diameter, 50 + diameter / 2, 40 + diameter + lineLength, 50 + diameter / 2, lineWidth, Color.Red);

            for (int i = 0; i < status.Length; i++)
            {
                currentNode     = new LinkCircleNode(40 + (i + 1) * (diameter + lineLength), 50, diameter, status.结点颜色, status.L[i].ToString());
                currentLineNode = new LinkLineNode(40 + diameter + (i + 1) * (diameter + lineLength), 50 + diameter / 2, 40 + diameter + (i + 1) * (diameter + lineLength) + lineLength, 50 + diameter / 2, lineWidth, Color.Red);

                if (i == 0)                 //说明当前创建的节点为第一个节点
                {
                    headNode.Next     = currentNode;
                    headLineNode.Next = currentLineNode;
                }
                else
                {
                    previousNode.Next     = currentNode;
                    previousLineNode.Next = currentLineNode;
                }
                previousNode     = currentNode;
                previousLineNode = currentLineNode;
            }

            currentNode.Next     = null;          //这里要注意,要把最后一个节点的Next设置为null
            currentLineNode.Next = null;

            circleNodeIterator  = headNode.CreateIterator();
            circleNodeIterator1 = headNode.CreateIterator();
            lineNodeIterator    = headLineNode.CreateIterator();
        }
コード例 #19
0
 public virtual void OnLineNodeDeleted(LinkLineNode previousNode, LinkLineNode nodeRemoved, LinkLineNode nextNode)
 {
 }
コード例 #20
0
 protected virtual void OnLineNodeAdded(LinkLineNode newNode)
 {
 }
コード例 #21
0
 protected virtual void OnCreateContextMenuForLinkLine(LinkLineNode lineNode, ContextMenu mnu, Point pt)
 {
 }
コード例 #22
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            LinkLineNode nodeTest = HitTest(e.X, e.Y);

            if (nodeTest != null)
            {
                if (AllowLineSelection)
                {
                    nodeTest.SelectLine(true);
                    if (nodeTest.Start != null && nodeTest.End != null)
                    {
                        LinkLineNodeOutPort startNode = nodeTest.Start as LinkLineNodeOutPort;
                        LinkLineNodeInPort  endNode   = nodeTest.End as LinkLineNodeInPort;
                        if (startNode != null && endNode != null)
                        {
                            bool bChanged = true;
                            if (_selectedLine != null)
                            {
                                if (_selectedLine.StartNode.PortID == startNode.PortID &&
                                    _selectedLine.StartNode.PortInstanceID == startNode.PortInstanceID &&
                                    _selectedLine.EndNode.PortID == endNode.PortID &&
                                    _selectedLine.EndNode.PortInstanceID == endNode.PortInstanceID)
                                {
                                    bChanged = false;
                                }
                            }
                            if (bChanged)
                            {
                                _selectedLine = new LinkLineEnds(startNode, endNode);
                                OnLineSelectionChanged();
                            }
                        }
                    }
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                ContextMenu mnu = new ContextMenu();
                Point       pt  = new Point(e.X, e.Y);
                if (nodeTest != null)
                {
                    //nodeTest is the line holder
                    nodeTest.SelectLine(true);
                    MenuItemWithBitmap mi = new MenuItemWithBitmap("Add line join", Resource1.newLineBreak);
                    mi.Click += new EventHandler(miAddLineNode_Click);
                    mi.Tag    = new NodeData(nodeTest, pt);
                    mnu.MenuItems.Add(mi);
                    //
                    if (AllowLineDisconnect)
                    {
                        if (nodeTest.LinkedInPort != null && nodeTest.LinkedOutPort != null)
                        {
                            mi        = new MenuItemWithBitmap("Disconnect", Resource1.disconnect);
                            mi.Click += new EventHandler(miDisconnectNodes_Click);
                            mi.Tag    = new NodeData(nodeTest, pt);
                            mnu.MenuItems.Add(mi);
                        }
                    }
                    OnCreateContextMenuForLinkLine(nodeTest, mnu, pt);
                }
                else
                {
                    OnCreateContextMenu(mnu, pt);
                }
                if (mnu.MenuItems.Count > 0)
                {
                    _menuPoint = pt;
                    mnu.Show(this, pt);
                }
            }
        }
コード例 #23
0
        public override void ExecuteAndUpdateCurrentLine()
        {
            switch (CurrentLine)
            {
            case 0:
                CurrentLine = 3;
                return;

            case 3:                      //L=(LinkList)malloc(sizeof(Lnode));  L->next=NULL;
                //生成一个头节点
                LinkCircleNode headNode     = null;
                LinkLineNode   headLineNode = null;
                headNode           = new LinkCircleNode(40, 50, diameter, status.头结点颜色, "H");
                headLineNode       = new LinkLineNode(40 + diameter, 50 + diameter / 2, 40 + diameter + lineLength, 50 + diameter / 2, lineWidth, Color.Red);
                headNode.Next      = null;
                headLineNode.Next  = null;
                circleNodeIterator = headNode.CreateIterator();
                lineNodeIterator   = headLineNode.CreateIterator();
                break;

            case 4:                      //for(i=n;i>0;i--){
                if (status.I == 0)
                {
                    CurrentLine = 9;
                    return;
                }
                break;

            case 5:                      //p=(LinkList)malloc(sizeof(Lnode));  scanf(&p->data);
                if (iteratorInsertNode != null)
                {
                    ((NodeListIterator)circleNodeIterator).RefreshAllNodes((LinkCircleNode)iteratorInsertNode.First().CurrentItem, 40, 50, diameter, lineLength, status.结点颜色);
                }
                iteratorInsertNode = new LinkCircleNode(40 + diameter - 4, 50 + diameter, diameter, status.插入结点颜色, status.L[status.I - 1].ToString()).CreateIterator();
                status.CanEdit     = true;
                status.P           = "p当前指向结点" + ((LinkCircleNode)iteratorInsertNode.First().CurrentItem).Text;
                break;

            case 6:                      //p->next=L->next;
                ((LinkCircleNode)iteratorInsertNode.First().CurrentItem).Next = ((LinkCircleNode)circleNodeIterator.First().CurrentItem).Next;
                //生成贝赛尔曲线
                nullIteratorBezierLine = new BezierLine(new Rectangle(1, 1, 1, 1), GetPoints(), lineWidth, Color.Red).CreateIterator();
                break;

            case 7:                      //L->next=p;
                ((LinkCircleNode)circleNodeIterator.First().CurrentItem).Next = (LinkCircleNode)iteratorInsertNode.First().CurrentItem;
                //刷新所有的结点的位置
                ((NodeListIterator)circleNodeIterator).RefreshAllNodes((LinkCircleNode)iteratorInsertNode.First().CurrentItem, 40, 50, diameter, lineLength, status.结点颜色);
                //设置当前结点的颜色
                ((NodeListIterator)circleNodeIterator).SetCurrentItemNewColor(iteratorInsertNode.First().CurrentItem, status.插入结点颜色, status.结点颜色);
                //以下是生成一个箭头,并把它插入到箭头链表,最后刷新这个箭头链表
                LinkLineNode lineNode = new LinkLineNode(1, 1, 1 + lineLength, 1, 2, Color.Red);
                lineNode.Next = ((LinkLineNode)lineNodeIterator.First().CurrentItem).Next;
                ((LinkLineNode)lineNodeIterator.First().CurrentItem).Next = lineNode;
                ((NodeListIterator)lineNodeIterator).RefreshAllNodes((LinkLineNode)lineNodeIterator.First().CurrentItem, 40 - lineLength, 50 + diameter / 2, diameter, lineLength, Color.Red);
                //删除贝赛尔曲线
                nullIteratorBezierLine = null;
                //i--
                status.CanEdit = true;
                status.I--;
                CurrentLine = 4;
                return;

            case 9:
                return;
            }
            CurrentLine++;
        }
コード例 #24
0
 protected override void OnApply(LinkLineNode node)
 {
     node.BreakLine(_point, ref _node1, ref _node2);
     ActiveDrawing.RefreshControl(node.Parent);
 }
コード例 #25
0
 protected abstract void OnApply(LinkLineNode node);
コード例 #26
0
 protected override void OnApply(LinkLineNode node)
 {
     node.Delete();
 }
コード例 #27
0
 protected override void OnApply(LinkLineNode node)
 {
     node.InsertNode(_point.X, _point.Y);
 }
コード例 #28
0
        public override void ExecuteAndUpdateCurrentLine()
        {
            switch (CurrentLine)
            {
            case 0:
                CurrentLine = 2;
                return;

            case 2:                                                //p = L;j = 0;
                circleNodeIterator1 = circleNodeIterator1.First(); //使p指向头结点
                status.CanEdit      = true;
                status.J            = 0;
                nullIteratorP       = new Pointer(circleNodeIterator1.CurrentItem.Bounds.X - 33, circleNodeIterator1.CurrentItem.Bounds.Y - 33, Color.Purple, "p").CreateIterator();
                status.CanEdit      = true;
                status.P            = "p当前指向结点" + ((LinkCircleNode)circleNodeIterator1.CurrentItem).Text;
                break;

            case 3:                      //while(p && j<i-1){
                //判断while语句条件是否成立,如果成立,CurrentLine = 4;不成立,CurrentLine = 6;
                if (circleNodeIterator1 == null || status.J >= status.I - 1)
                {
                    CurrentLine = 6;
                    return;
                }
                break;

            case 4:                                               //p = p->next; j++;
                circleNodeIterator1 = circleNodeIterator1.Next(); //p下移一个结点
                ((NodeListIterator)circleNodeIterator).SetCurrentItemNewColor(circleNodeIterator1.CurrentItem, status.当前结点颜色, status.结点颜色);
                status.CanEdit = true;
                status.P       = "p当前指向结点" + ((LinkCircleNode)circleNodeIterator1.CurrentItem).Text;
                //把指针p设置到新的位置
                ((Pointer)nullIteratorP.CurrentItem).SetToNewPosition(circleNodeIterator1.CurrentItem.Bounds.X - 33, circleNodeIterator1.CurrentItem.Bounds.Y - 33);
                status.CanEdit = true;
                status.J++;
                CurrentLine = 3;
                return;

            case 6:                      //if(p == NULL)
                CurrentLine = 8;
                return;

            case 8:                      //s = (LinkList)malloc(sizeof(LNode));
                x = this.circleNodeIterator1.CurrentItem.Bounds.X + diameter - 5;
                y = this.circleNodeIterator1.CurrentItem.Bounds.Y + diameter;
                iteratorInsertNode = new LinkCircleNode(x, y, diameter, status.插入结点颜色, "").CreateIterator();
                break;

            case 9:                      //s->data = e;
                iteratorInsertNode = new LinkCircleNode(x, y, diameter, status.插入结点颜色, status.E.ToString()).CreateIterator();
                break;

            case 10:                      //s->next = p->next;
                nullIteratorBezierLine = new BezierLine(new Rectangle(1, 1, 1, 1), GetPoints(), 2, Color.Red).CreateIterator();
                break;

            case 11:                      //p->next = s;
                int xx1, yy1;
                xx1 = circleNodeIterator1.CurrentItem.Bounds.X + diameter;
                yy1 = circleNodeIterator1.CurrentItem.Bounds.Y + diameter / 2;
                nullIteratorBezierLine = null;
                iteratorInsertNode.CurrentItem.Bounds = new Rectangle(xx1 + lineLength, yy1 - diameter / 2, diameter, diameter);
                ((NodeListIterator)circleNodeIterator).InsertNodeAndRefresh(status.I, (INode)iteratorInsertNode.CurrentItem, diameter, lineLength);

                LinkLineNode insertLineNode = new LinkLineNode(xx1 + diameter + lineLength, yy1, xx1 + diameter + 2 * lineLength, yy1, 2, Color.Black);
                ((NodeListIterator)lineNodeIterator).InsertNodeAndRefresh(status.I, insertLineNode, diameter, lineLength);
                status.CanEdit = true;
                status.L       = status.L.Insert(status.I - 1, status.E.ToString());
                status.CanEdit = true;
                status.Length++;
                break;

            case 12:
                return;
            }
            CurrentLine++;
        }
コード例 #29
0
        Image CreatePreviewImage(string s, int pos, char e)
        {
            int height     = 80;
            int width      = 530;
            int lineLength = 18;
            int diameter   = 30;
            int leftSpan   = 3;
            int topSpan    = 20;


            IIterator circleNodeIterator;          //用于输出结点链表的指针
            IIterator lineNodeIterator;            //用于输出连接线链表的指针

            LinkCircleNode headNode         = null;
            LinkLineNode   headLineNode     = null;
            LinkCircleNode previousNode     = null;
            LinkLineNode   previousLineNode = null;
            LinkCircleNode currentNode      = null;
            LinkLineNode   currentLineNode  = null;

            previousNode     = headNode = new LinkCircleNode(leftSpan, topSpan, diameter, Color.Red, "H");
            previousLineNode = headLineNode = new LinkLineNode(leftSpan + diameter, topSpan + diameter / 2, leftSpan + diameter + lineLength, topSpan + diameter / 2, lineWidth, Color.Red);

            s = s.Insert(pos - 1, e.ToString());

            for (int i = 0; i < s.Length; i++)
            {
                if (i != pos - 1)
                {
                    currentNode = new LinkCircleNode(leftSpan + (i + 1) * (lineLength + diameter), topSpan, diameter, Color.DarkTurquoise, s[i].ToString());
                }
                else
                {
                    currentNode = new LinkCircleNode(leftSpan + (i + 1) * (lineLength + diameter), topSpan, diameter, Color.DarkOrange, s[i].ToString());
                }
                currentLineNode       = new LinkLineNode(leftSpan + diameter + (i + 1) * (lineLength + diameter), topSpan + diameter / 2, leftSpan + diameter + (i + 1) * (lineLength + diameter) + lineLength, topSpan + diameter / 2, lineWidth, Color.Red);
                previousNode.Next     = currentNode;
                previousLineNode.Next = currentLineNode;

                previousNode     = currentNode;
                previousLineNode = currentLineNode;
            }

            currentNode.Next     = null;
            currentLineNode.Next = null;

            circleNodeIterator = headNode.CreateIterator();
            lineNodeIterator   = headLineNode.CreateIterator();

            Bitmap   bmp = new Bitmap(width, height);
            Graphics g   = Graphics.FromImage(bmp);

            if (circleNodeIterator != null)
            {
                for (IIterator iterator = circleNodeIterator.First(); !circleNodeIterator.IsDone(); iterator = circleNodeIterator.Next())
                {
                    iterator.CurrentItem.Draw(g);
                }
            }
            if (lineNodeIterator != null)
            {
                for (IIterator iterator = lineNodeIterator.First(); !lineNodeIterator.IsDone(); iterator = lineNodeIterator.Next())
                {
                    iterator.CurrentItem.Draw(g);
                }
            }

            return(bmp);
        }
コード例 #30
0
        /// <summary>
        /// create ParameterDrawing and ports
        /// </summary>
        /// <returns></returns>
        public Control[] GetControls()
        {
            List <LinkLineNodeOutPort> _outports = new List <LinkLineNodeOutPort>();

            LinkLineNodeOutPort[] _outportsV = this.Variable.OutPorts;
            List <Control>        cs         = new List <Control>();

            pd           = new ParameterDrawing();
            pd.Parameter = this;
            cs.Add(pd);
            _outports.AddRange(_outportsV);
            //cast type==================================
            if (_castTo != null)
            {
                if (_castTo.Outports != null)
                {
                    _outports.AddRange(_castTo.Outports);
                }
                //new out port
                if (_castTo.NewOutport == null)
                {
                    ProgramNewOutPort op = new ProgramNewOutPort(this);
                    _castTo.NewOutport = op;
                }
                pd.XmlData = _castTo.OwnerObject.GetXmlNode();
                _outports.Add(_castTo.NewOutport);
            }
            //===========================================
            for (int i = 0; i < _outports.Count; i++)
            {
                cs.Add(_outports[i].Label);
                _outports[i].Owner = pd;
                if (_outports[i] is ProgramOutPort)
                {
                }
                else
                {
                    if (_outports[i].Label != null)
                    {
                        ((DrawingVariable)_outports[i].Label).OnMouseSelect += new EventHandler(Parameter_OnMouseSelect);
                        if (((DrawingVariable)_outports[i].Label).Variable != null)
                        {
                            ((DrawingVariable)_outports[i].Label).Variable.VariableName = this.Name;
                            ((MathNodeVariable)(((DrawingVariable)_outports[i].Label).Variable)).VariableType = this.DataType;
                        }
                    }
                }
                if (_outports[i].LinkedInPort == null)
                {
                    LinkLineNode l = _outports[i];
                    while (l != null)
                    {
                        cs.Add(l);
                        l = (LinkLineNode)l.NextNode;
                    }
                }
                else
                {
                    cs.Add(_outports[i]);
                }
            }
            Control[] a = new Control[cs.Count];
            cs.CopyTo(a);
            return(a);
        }