private int StartPointOut = 10; //��ʼ����������һ�м���Ĭ�Ͼ���

        #endregion Fields

        #region Constructors

        public DrawLineArithmetic(List<LineInfo> Lines, List<BlockInfo> Blocks)
        {
            CurrentBlocks = Blocks;
            ModifyLines = Lines;

            for (int i = 0; i < ModifyLines.Count; i++)
            {
                BlockInfo Sctrl = new BlockInfo();
                BlockInfo Ectrl = new BlockInfo();
                LineInfo line = ModifyLines[i];
                foreach (BlockInfo block in Blocks)
                {
                    if (block.BlockName == line.StartInfo.Split(';')[0])
                    { Sctrl = block; }
                    else if (block.BlockName == line.EndInfo.Split(';')[0])
                    { Ectrl = block; }
                }

                List<Point> tempMpoint = drawLine(line.StartPoint, line.EndPoint, Sctrl, Ectrl);
                line.MiddlePoint = ClearWay(tempMpoint, line.StartPoint, line.EndPoint, Sctrl, Ectrl);
                ModifyLines[i] = line;
            }
        }
        /// <summary>
        /// ����һ����·������ؼ��Ľ���
        /// </summary>
        /// <param name="curWay">·�߷���</param>
        /// <param name="ctrlBlock">�ؼ�����Ϣ</param>
        /// <returns>���ؽ���㼯</returns>
        private List<Point> WaysIsCross(List<Point> curWay, BlockInfo ctrlBlock)
        {
            //��ǰ�ؼ����Ľ�����
            Point LeftUp = ctrlBlock.StartPoint;
            Point RightUp = new Point(LeftUp.X + ctrlBlock.Width, LeftUp.Y);
            Point LeftDown = new Point(LeftUp.X, LeftUp.Y + ctrlBlock.Height);
            Point RightDown = new Point(RightUp.X, LeftDown.Y);
            List<Point> BlockOutline = new List<Point>(new Point[] { LeftUp, RightUp, RightDown, LeftDown, LeftUp });//�ؼ���������
            List<Point> CrossPoints = new List<Point>();//���㼯��

            for (int i = 1; i < curWay.Count; i++)
            {//��·�е�ÿһ�߶��������ߵĽ��㼯
                CrossPoints.AddRange(WaysIsCross(new List<Point>(new Point[] { curWay[i - 1], curWay[i] }), BlockOutline));
            }
            return CrossPoints;
        }
        private List<Point> RightUpToLeftDown(Point start, Point end, BlockInfo Sctrl, BlockInfo Ectrl)
        {
            //���ַ���
            List<Point> WayA =
                new List<Point>(new Point[] { start, new Point(start.X, Ectrl.StartPoint.Y), new Point(end.X, Ectrl.StartPoint.Y), end });
            List<Point> WayB =
                new List<Point>(new Point[] { start, new Point(start.X, Sctrl.StartPoint.Y + Sctrl.Height), new Point(end.X, Sctrl.StartPoint.Y + Sctrl.Height), end });
            List<Point> WayC =
                new List<Point>(new Point[] { start, new Point(start.X, Ectrl.StartPoint.Y + Ectrl.Height), new Point(end.X, Ectrl.StartPoint.Y + Ectrl.Height), end });
            List<Point> WayD =
                new List<Point>(new Point[] { start, new Point(start.X, Sctrl.StartPoint.Y), new Point(end.X, Sctrl.StartPoint.Y), end });

            return ChooseRightWay(WayA, WayB, WayC, WayD);
        }
        private List<Point> LeftUpToRightDown(Point start, Point end, BlockInfo Sctrl, BlockInfo Ectrl)
        {
            //���ַ���
            List<Point> WayA =
                new List<Point>(new Point[] { start, new Point(start.X, end.Y), end });
            List<Point> WayB =
                new List<Point>(new Point[] { start, new Point(end.X, start.Y), end });
            List<Point> WayC =
                new List<Point>(new Point[] { start, new Point(start.X, Ectrl.StartPoint.Y + Ectrl.Height), new Point(end.X, Ectrl.StartPoint.Y + Ectrl.Height), end });
            //List<Point> WayD =
            //    new List<Point>(new Point[] { start, new Point(Ectrl.StartPoint.X + Ectrl.Width, start.Y), new Point(Ectrl.StartPoint.X + Ectrl.Width, Ectrl.StartPoint.Y + Ectrl.Height), new Point(end.X, Ectrl.StartPoint.Y + Ectrl.Height), end });

            return ChooseRightWay(WayA, WayB, WayC, null);
        }
        private List<Point> drawLine(Point start, Point end, BlockInfo Sctrl, BlockInfo Ectrl)
        {
            //��ʼ������ͽ�β��ȥ���Ƿ��谭����//������

            //����ģ��ܽ������
            Point FirstMiddlePoint = new Point(start.X + StartPointOut, start.Y);
            Point LastMiddlePoint = new Point(end.X - StartPointOut, end.Y);

            //Ѱ�������м�·��
            if (FirstMiddlePoint.X <= LastMiddlePoint.X)//������� �յ�����
            {
                if (FirstMiddlePoint.Y < LastMiddlePoint.Y)//��������� �յ�������
                { return LeftUpToRightDown(FirstMiddlePoint, LastMiddlePoint, Sctrl, Ectrl); }
                else//��������� �յ�������
                { return LeftDownToRightUp(FirstMiddlePoint, LastMiddlePoint, Sctrl, Ectrl); }

            }
            else//��������յ�����
            {
                if (FirstMiddlePoint.Y < LastMiddlePoint.Y)//��������� �յ�������
                { return RightUpToLeftDown(FirstMiddlePoint, LastMiddlePoint, Sctrl, Ectrl); }
                else//��������� �յ�������
                { return RightDownToLeftUp(FirstMiddlePoint, LastMiddlePoint, Sctrl, Ectrl); }
            }
        }
        /// <summary>
        /// ���·���м���������ظ��ĵ㡢�ظ���·���Լ��ƿ�����յ�ģ��
        /// </summary>
        /// <param name="OldWay">�����ظ����·��</param>
        /// <param name="StartP">ֱ�����</param>
        /// <param name="EndP">ֱ���յ�</param>
        /// <param name="Sctrl">��ʼģ��</param>
        /// <param name="Ectrl">�յ�ģ��</param>
        /// <returns>�������ظ����·��</returns>
        private List<Point> ClearWay(List<Point> OldWay, Point StartP, Point EndP, BlockInfo Sctrl, BlockInfo Ectrl)
        {
            List<Point> NewWay = new List<Point>();
            Point FirstMpoint = new Point(StartP.X + StartPointOut, StartP.Y);
            Point LastMpoint = new Point(EndP.X - StartPointOut, EndP.Y);
            //������ڵ���ڵ�
            NewWay.Add(FirstMpoint);
            NewWay.AddRange(OldWay);
            NewWay.Add(LastMpoint);

            ClearPoint(ref NewWay);

            //�ƿ�����յ�ģ��
            int index = NewWay.Count - 1;
            if (index > 2)
            {
                if (NewWay[0].Y == NewWay[1].Y && NewWay[0].Y == StartP.Y
                    && StartP.X > NewWay[1].X && StartP.X < NewWay[0].X)
                {
                    if (NewWay[2].Y > NewWay[1].Y)
                    {
                        NewWay.Insert(2, new Point(NewWay[1].X, Sctrl.StartPoint.Y + Sctrl.Height));
                        NewWay[1] = new Point(NewWay[0].X, NewWay[2].Y);
                    }
                    else
                    {
                        NewWay.Insert(2, new Point(NewWay[1].X, Sctrl.StartPoint.Y));
                        NewWay[1] = new Point(NewWay[0].X, NewWay[2].Y);
                    }
                }
                if (NewWay[index].Y == NewWay[index - 1].Y && NewWay[index].Y == EndP.Y
                    && EndP.X > NewWay[index].X && EndP.X < NewWay[index - 1].X)
                {
                    if (NewWay[index - 2].Y > NewWay[index - 1].Y)
                    {
                        NewWay[index - 1] = new Point(NewWay[index].X, Ectrl.StartPoint.Y + Ectrl.Height);
                        NewWay.Insert(index - 1, new Point(NewWay[index - 2].X, Ectrl.StartPoint.Y + Ectrl.Height));
                    }
                    else
                    {
                        NewWay[index - 1] = new Point(NewWay[index].X, Ectrl.StartPoint.Y);
                        NewWay.Insert(index - 1, new Point(NewWay[index - 2].X, Ectrl.StartPoint.Y));
                    }
                }
            }
            return NewWay;
        }
        /* ���ڴ洢�õ�List<ArrayList>��ʽ����Ϣ���ݺ�
         * Cassview��ʹ�õĿؼ���ϢctrlsInfo
         * ����ʹ�õĿؼ���������ϢblockInfo��linesInfo
         * ����֮���ת�� */
        /// <summary>
        /// ����Ϣ�����ж�ȡ��Ϣ
        /// </summary>
        /// <param name="infoArray"></param>
        private void ReadInfo(List<List<ArrayList>> infoArray)
        {
            List<ArrayList> ctrol = infoArray[0];
            List<ArrayList> line = infoArray[1];
            for (int i = 0; i < ctrol.Count; i++)
            {
                ArrayList temp = ctrol[i];
                ControlInfo tempCtrl = new ControlInfo();
                BlockInfo tempBlock = new BlockInfo();

                string[] BasicInfo = (string[])(temp[0]);
                Point[] SizeInfo = (Point[])(temp[3]);
                List<string[]> FuncInfo1 = (List<string[]>)(temp[1]);
                List<string[]> FuncInfo2 = (List<string[]>)(temp[2]);
                //��������
                tempCtrl.ControlNum = Convert.ToInt32(BasicInfo[0]);
                tempCtrl.ControlName = BasicInfo[1];
                tempBlock.BlockNum = tempCtrl.ControlNum;
                tempBlock.BlockName = tempCtrl.ControlName;
                tempCtrl.SortName = BasicInfo[2];
                if (BasicInfo[3] != null)
                {
                    tempCtrl.OtherProperty = BasicInfo[3].Split('$');
                }
                tempCtrl.HasEnumProperty = Convert.ToBoolean(BasicInfo[4]);
                tempCtrl.CodeInfo = new string[3];
                tempCtrl.CodeInfo[0] = BasicInfo[5];
                tempCtrl.CodeInfo[1] = BasicInfo[6];
                tempCtrl.CodeInfo[2] = BasicInfo[7];
                string[] LoadInfo = BasicInfo[8].Split(';');
                tempCtrl.CanOptimize = Convert.ToBoolean(BasicInfo[10]);

                if (LoadInfo[0] != "0")
                {//��������˿ڱ��� �˿ڳ�ֵ��Ϣ20090616
                    List<string[]> tempIOinfo = new List<string[]>();
                    foreach (string element in LoadInfo)
                    {
                        string[] info = new string[4];
                        info[2] = element.Split(',')[0];
                        info[3] = element.Split(',')[1];
                        tempIOinfo.Add(info);
                    }
                    tempCtrl.InputInfo = tempIOinfo;
                }
                else
                {
                    tempCtrl.InputInfo = InitializeIOinfo(Convert.ToInt32(BasicInfo[8]));
                }
                tempCtrl.OutputInfo = InitializeIOinfo(Convert.ToInt32(BasicInfo[9]));
                tempCtrl.VisibleFunctionProperty = new List<XProp>();
                tempCtrl.UnvisibleFunctionProperty = new List<XProp>();
                if (FuncInfo1 != null)
                {//�ɼ�����
                    for (int x = 0; x < FuncInfo1.Count; x++)
                    {
                        XProp attribute = new XProp();
                        attribute.EnumValue = FuncInfo1[x][0];
                        attribute.Name = FuncInfo1[x][1];
                        attribute.TheValue = FuncInfo1[x][2];
                        attribute.ValueType = FuncInfo1[x][3];
                        attribute.VarName = FuncInfo1[x][4];
                        attribute.ValueExplain = FuncInfo1[x][5];
                        attribute.Opnode = FuncInfo1[x][6];
                        attribute.Optype = FuncInfo1[x][7];
                        attribute.Opvalue = FuncInfo1[x][8];
                        attribute.Relate = FuncInfo1[x][9];
                        tempCtrl.VisibleFunctionProperty.Add(attribute);
                    }
                }
                if (FuncInfo2 != null)
                {//��������
                    for (int y = 0; y < FuncInfo2.Count; y++)
                    {
                        XProp attribute = new XProp();
                        attribute.EnumValue = FuncInfo2[y][0];
                        attribute.Name = FuncInfo2[y][1];
                        attribute.TheValue = FuncInfo2[y][2];
                        attribute.ValueType = FuncInfo2[y][3];
                        attribute.VarName = FuncInfo2[y][4];
                        attribute.ValueExplain = FuncInfo2[y][5];
                        attribute.Opnode = FuncInfo2[y][6];
                        attribute.Optype = FuncInfo2[y][7];
                        attribute.Opvalue = FuncInfo2[y][8];
                        attribute.Relate = FuncInfo2[y][9];
                        tempCtrl.UnvisibleFunctionProperty.Add(attribute);
                    }
                }
                //λ�á���С��Ϣ
                tempBlock.StartPoint = SizeInfo[0];
                tempBlock.Width = SizeInfo[1].X;
                tempBlock.Height = SizeInfo[1].Y;

                this.ctrlsInfo.Add(tempCtrl);
                this.blocksInfo.Add(tempBlock);
            }
            for (int i = 0; i < line.Count; i++)
            {//������Ϣ
                LineInfo tempLine = new LineInfo();

                Point[] SEinfo = (Point[])(line[i][0]);
                string[] SEctrl = (string[])(line[i][1]);
                tempLine.StartPoint = SEinfo[0];
                tempLine.EndPoint = SEinfo[1];
                tempLine.StartInfo = SEctrl[0];
                tempLine.EndInfo = SEctrl[1];

                this.linesInfo.Add(tempLine);
            }
            portReflash();//ˢ�¿ؼ��˿���Ϣ
            //���¼��������м��
            DrawLineArithmetic newArith = new DrawLineArithmetic(this.linesInfo, this.blocksInfo);
            this.linesInfo = newArith.ModifyLines;
        }
        /// <summary>
        /// CassView�ӿؼ������¼��������
        /// </summary>
        /// <param name="sender">�¼�������</param>
        /// <param name="e">�¼�����</param>
        private void CassView_ControlAdded(object sender, ControlEventArgs e)
        {
            if (this.Controls.Count > this.recordControls && !CassViewGenerator.isUndo)
            {
                ControlInfo CtrlInfo = new ControlInfo();
                BlockInfo BlckInfo = new BlockInfo();
                CtrlInfo.ControlName = e.Control.Site.Name;
                BlckInfo.BlockName = e.Control.Site.Name;
                bool isCopy = false;//�Ƿ�ʱճ���ؼ�
                PropertyDescriptor serialNumber = TypeDescriptor.GetProperties(e.Control)["SerialNumber"];
                PropertyDescriptor portNameProperty = TypeDescriptor.GetProperties(e.Control)["PortName"];
                PropertyDescriptor showNumberProperty = TypeDescriptor.GetProperties(e.Control)["ShowNumber"];
                PropertyDescriptor controlScaling = TypeDescriptor.GetProperties(e.Control)["Scaling"];
                if (controlScaling != null)
                {//���ݵ�ǰ�����ʵ����ؼ���С
                    controlScaling.SetValue(e.Control, this.scaling);
                }
                //����ģ�����
                if (serialNumber != null)
                {
                    List<int> tempNumlist = new List<int>();//��ʱ������пؼ�����ż���
                    foreach (ControlInfo ctrl in this.ctrlsInfo)
                    {
                        tempNumlist.Add(ctrl.ControlNum);
                    }
                    for (int i = 0; i <= this.ctrlsInfo.Count; i++)
                    {
                        if (!tempNumlist.Contains(i) || i == this.ctrlsInfo.Count)
                        {
                            serialNumber.SetValue(e.Control, i);
                            CtrlInfo.ControlNum = i;
                            BlckInfo.BlockNum = i;
                            break;
                        }
                    }
                }//end if (serialNumber != null)
                if (showNumberProperty != null)
                {//�����Ƿ���ʾ���
                    showNumberProperty.SetValue(e.Control, CassViewGenerator.ShowNumber);
                }
                if (ToolBoxServiceImpl.toolXML.FirstChild != null)
                {
                    string moduleSort = null;
                    bool setValue = false;
                    bool StartFind = false;

                    foreach (XmlNode categoryNode in ToolBoxServiceImpl.toolXML.FirstChild.ChildNodes)
                    {
                        if (categoryNode != null && categoryNode.Attributes[0].InnerText != CassViewGenerator.SpecialCodeNode)
                        {
                            //�ϳ��ؼ�
                            if (ToolBoxServiceImpl.typeNameString != null && ToolBoxServiceImpl.typeNameString.Length == 4)
                            {
                                if (categoryNode.Attributes[0].InnerText == ToolBoxServiceImpl.typeNameString[3])
                                {
                                    moduleSort = ToolBoxServiceImpl.typeNameString[2];
                                    StartFind = true;
                                }
                            }//ճ���ؼ�
                            else if (this.FindControlName(e.Control.Site.Name) == -1)
                            {
                                PropertyDescriptor moduleSortProperty = TypeDescriptor.GetProperties(e.Control)["ModuleSort"];
                                if (moduleSortProperty != null)
                                {
                                    moduleSort = moduleSortProperty.GetValue(e.Control).ToString();
                                    StartFind = true;
                                    isCopy = true;
                                }
                                InitializeIOport(e.Control);
                                //������������ͳ���ϵͳ������Ҫ�������
                            }
                            if (StartFind)//��ʼ��ڵ�����
                            {
                                foreach (XmlNode toolItemNode in categoryNode.ChildNodes)
                                {
                                    if (moduleSort == toolItemNode.Attributes[0].InnerText.Split(',')[2]
                                        && toolItemNode.FirstChild != null)
                                    {
                                        //��ȡ�������ԣ�����ģ��������ԣ��ı�ģ����ʽ
                                        //����ʼ���ؼ��������Ϣ
                                        ReadBasicProperty(toolItemNode.FirstChild, e.Control, ref CtrlInfo);

                                        //��ȡ�������ԣ�Ϊģ����ӹ������ԣ�����ģ�����
                                        if (toolItemNode.FirstChild != null && toolItemNode.FirstChild.NextSibling != null
                                            && toolItemNode.FirstChild.NextSibling.ChildNodes.Count > 0)
                                        {
                                            ReadFunctionProperty(toolItemNode.FirstChild.NextSibling, ref CtrlInfo);
                                        }//end if (toolItemNode.FirstChild != null)

                                        //��ȡָ�����ԣ�������������Control.Cʱ����
                                        if ((toolItemNode.LastChild.Name == "CodeProperty" || toolItemNode.LastChild.Name == "OtherInfo") && toolItemNode.LastChild != null
                                            && toolItemNode.LastChild.HasChildNodes)
                                        {
                                            ReadOtherProperty(toolItemNode.LastChild, ref CtrlInfo);
                                        }
                                        setValue = true;
                                        break;
                                    }//end if (moduleSort == toolItemNode.Attributes[0].InnerText.Split(',')[2])
                                }// end foreach(XmlNode toolItemNode in categoryNode.ChildNodes)
                            }
                        }//end if (categoryNode != null && categoryNode.Attributes[0].InnerText != CassViewGenerator.SpecialCodeNode)
                        if (setValue)
                        { break; }
                    }//end foreach (XmlNode categoryNode in ToolBoxServiceImpl.toolXML.FirstChild.ChildNodes)
                    ToolBoxServiceImpl.typeNameString = null;
                }//end if (ToolBoxServiceImpl.toolXML.FirstChild != null)

                if (portNameProperty != null && CtrlInfo.CodeInfo != null)
                {
                    string portName = AddPortName(CtrlInfo, ref CassViewGenerator.PortInfoList);
                    CtrlInfo.CodeInfo[2] = CtrlInfo.CodeInfo[1] + portName;
                    XProp.SetValue(portName, CassViewGenerator.portIndex, CtrlInfo.VisibleFunctionProperty);
                    portNameProperty.SetValue(e.Control, CtrlInfo.CodeInfo[2]);
                }
                if (isCopy && GenerateCode.SortCtrlName.Contains(CtrlInfo.CodeInfo[0]))
                {//����ؼ��Կؼ���Ϣ��Codeinfo���ֽ��и�ֵ
                    foreach (ControlInfo ctrl in this.CopyCtrl)
                    {
                        if (ctrl.CodeInfo[0] == CtrlInfo.CodeInfo[0])
                        {
                            CtrlInfo.CodeInfo = ctrl.CodeInfo;
                            break;
                        }
                    }
                    if ((GenerateCode.SortCtrlName.IndexOf(CtrlInfo.CodeInfo[0]) == 1 || GenerateCode.SortCtrlName.IndexOf(CtrlInfo.CodeInfo[0]) == 2))
                    {
                        if (CtrlInfo.CodeInfo[1] != null)
                        {
                            PropertyDescriptor ChoosePortName = TypeDescriptor.GetProperties(e.Control)["ChoosePortName"];
                            ChoosePortName.SetValue(e.Control, CtrlInfo.CodeInfo[1]);
                        }
                        if (CtrlInfo.CodeInfo[2] != null)
                        {
                            PropertyDescriptor ChooseModuleProperty = TypeDescriptor.GetProperties(e.Control)["ChooseModuleProperty"];
                            ChooseModuleProperty.SetValue(e.Control, CtrlInfo.CodeInfo[2]);
                        }
                    }
                }
                if (!this.ctrlsInfo.Contains(CtrlInfo))
                {
                    this.ctrlsInfo.Add(CtrlInfo);
                    this.blocksInfo.Add(BlckInfo);
                }
                this.recordControls++;

                if (CassViewGenerator.currentUndo != null)
                {//�ؼ��������//ע��ʱ�ؼ�λ�û�ûȷ�� ������blockinfo ���޸�ȷ��ֵ
                    Operation ctrlOpt = new Operation();
                    ctrlOpt.Oname = UndoOperation.OperateStyle.�ؼ����.ToString();
                    ctrlOpt.Item = e.Control;
                    ctrlOpt.Change = new object[4];
                    ctrlOpt.Change[0] = ((HostControl)CassViewGenerator.currentTabPage.Controls[0]).HostDesign;
                    ctrlOpt.Change[1] = e.Control.Site.Name;
                    ctrlOpt.Change[2] = ctrlsInfo[ctrlsInfo.Count - 1];
                    ctrlOpt.Change[3] = blocksInfo[blocksInfo.Count - 1];
                    CassViewGenerator.AddOpt(ctrlOpt);
                    this.UndoFlag = true;
                }
            }//end if (this.Controls.Count > this.recordControls)
            else if(CassViewGenerator .isUndo)
            {//����������Ȼ��Ҫ���ӿؼ�ָ��
                this.recordControls++;
            }
            #region �������ģ����������

            e.Control.BackColor = this.BackColor;
            e.Control.LocationChanged += new EventHandler(Control_LocationChanged);
            e.Control.Tag = e.Control.Site.Name;
            if (this.linesEditable == true)
            {
                e.Control.Visible = false;
            }

            #endregion
        }
        private void OperateDoing(ref Operation Opt)
        {
            switch (Opt.Oname)
            {
            case "比例放大":
            {
                cassview.Scaling = Convert.ToSingle(Opt.Change[1]);
                break;
            }

            case "比例缩小":
            {
                cassview.Scaling = Convert.ToSingle(Opt.Change[1]);
                break;
            }

            case "控件删除":
            {
                for (int i = 0; i < cassview.Controls.Count; i++)
                {
                    if (cassview.Controls[i].Site.Name == ((Control)Opt.Item).Tag.ToString())
                    {
                        cassview.Controls.RemoveAt(i);
                        break;
                    }
                }
                break;
            }

            case "控件添加":
            {
                CreateControl(ref Opt);
                cassview.Controls.Add((Control)Opt.Item);
                cassview.ctrlsInfo.Add((ControlInfo)Opt.Change[2]);
                cassview.blocksInfo.Add((BlockInfo)Opt.Change[3]);

                if (Opt.Change.Length > 4)
                {
                    for (int i = 4; i < Opt.Change.Length; i++)
                    {
                        Opt.Change[i] = AddnewLine((LineInfo)Opt.Change[i]);
                    }
                }
                cassview.portReflash();
                cassview.DrawBackgroundImage();
                break;
            }

            case "控件移动":
            {
                BlockInfo tempBinfo = (BlockInfo)Opt.Change[1];
                for (int i = 0; i < cassview.blocksInfo.Count; i++)
                {
                    int x = cassview.Controls.Count;
                    if (cassview.blocksInfo[i].BlockNum == ((BlockInfo)Opt.Change[0]).BlockNum)
                    {
                        foreach (Control element in cassview.Controls)
                        {
                            PropertyDescriptor Number = TypeDescriptor.GetProperties(element)["SerialNumber"];
                            if (Number != null && Number.GetValue(element).ToString() == cassview.blocksInfo[i].BlockNum.ToString())
                            {
                                element.Location = new Point(tempBinfo.StartPoint.X + 5, tempBinfo.StartPoint.Y + 5);
                                Opt.Item         = element;
                                break;
                            }
                        }
                    }
                }
                break;
            }

            case "控件置前":
            {
                ((Control)Opt.Item).BringToFront();
                break;
            }

            case "控件置后":
            {
                ((Control)Opt.Item).SendToBack();
                break;
            }

            case "直线删除":
            {
                cassview.DeleteLine(GetLineinfoNum((LineInfo)Opt.Item), true);
                break;
            }

            case "直线添加":
            {
                Opt.Item = AddnewLine((LineInfo)Opt.Item);
                break;
            }

            case "属性修改":
            {
                if (Opt.Change[0].ToString() == "模块点名")
                {
                    foreach (Control element in cassview.Controls)
                    {
                        if (element.Tag.ToString() == ((Control)Opt.Item).Tag.ToString())
                        {        //找到删除后新建的控件
                            Opt.Item = element;
                            break;
                        }
                    }
                    string Cmname = TypeDescriptor.GetProperties((Control)Opt.Item)["ModuleName"].GetValue((Control)Opt.Item).ToString();        //当前控件模块名
                    CassView.ModifyPortName(Cmname, Opt.Change[1].ToString(), Opt.Change[2].ToString());
                    PropertyDescriptor portNameProperty = TypeDescriptor.GetProperties((Control)Opt.Item)["PortName"];
                    cassview.FindControlInfo((Control)Opt.Item).CodeInfo[2] = Cmname + Opt.Change[2].ToString();
                    portNameProperty.SetValue((Control)Opt.Item, Cmname + Opt.Change[2].ToString());

                    for (int i = 0; i < cassview.ctrlsInfo.Count; i++)
                    {
                        if (cassview.ctrlsInfo[i].ControlName == ((Control)Opt.Item).Site.Name && cassview.ctrlsInfo[i].VisibleFunctionProperty != null)
                        {
                            for (int j = 0; j < cassview.ctrlsInfo[i].VisibleFunctionProperty.Count; j++)
                            {
                                if (cassview.ctrlsInfo[i].VisibleFunctionProperty[j].Name == "模块点名")
                                {
                                    cassview.ctrlsInfo[i].VisibleFunctionProperty[j].TheValue = Opt.Change[2];
                                }
                            }
                            break;
                        }
                    }
                }
                else
                {
                    CassViewGenerator.SpecialValueChange(cassview, (Control)Opt.Item, Opt.Change[0].ToString(), Opt.Change[1], Opt.Change[2]);
                    CassViewGenerator.SetCodeInfo(cassview, (Control)Opt.Item, Opt.Change[0].ToString(), Opt.Change[2].ToString());
                }
                break;
            }
            }
        }