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();
        }
        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);
        }
        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++;
        }