public XPropDescriptor(XProp prop, Attribute[] attrs)
     : base(prop.Name, attrs)
 {
     this.xProp = prop;
 }
 /// <summary>
 /// ���ݽڵ���Ϣ�ҵ���ǰ�������Լ������Ƿ��ж�Ӧ������
 /// û������ݽڵ���Ϣ����������
 /// ���ɼ�����������Valueֵ��ƥ�� �������޸�
 /// </summary>
 /// <param name="Property"></param>
 /// <param name="FuntionInfos"></param>
 /// <returns>�����ҵ�����</returns>
 private XProp FindFunctionProperty(XmlNode Property, List<XProp> FuntionInfos, bool visible)
 {
     //Ѱ��ƥ����Ϣ
     foreach (XProp element in FuntionInfos)
     {
         if (element.Name == Property.Attributes["name"].Value
             && element.VarName == Property.Attributes["varname"].Value
             && element.ValueType == Property.Attributes["type"].Value)
         {
             if (Property.Attributes.Count >= 5)
             {//����������Ϣ
                 element.ValueExplain = Property.Attributes["exp"].Value;
                 if (Property.Attributes.Count >= 6)
                 {//�����Ż�������Ϣ
                     element.Opnode = Property.Attributes["opnode"].Value;
                     element.Optype = Property.Attributes["optype"].Value;
                     element.Opvalue = Property.Attributes["opvalue"].Value;
                     element.Relate = Property.Attributes["relate"].Value;
                 }
             }
             if (Property.Attributes["type"].Value != "MyEnum")
             {
                 if (!visible)
                 {//���ɼ�����ֱ�Ӹ���ֵ
                     element.TheValue = Property.InnerText;
                 }
                 return element;
             }
             else if (element.EnumValue == Property.InnerText)
             {
                 if (!visible)
                 {
                     element.TheValue = Property.InnerText.Split(',')[0];
                 }
                 return element;
             }
         }
     }
     //��������Ϣ
     XProp newFun = new XProp();
     newFun.Name = Property.Attributes["name"].Value;
     newFun.VarName = Property.Attributes["varname"].Value;
     newFun.ValueType = Property.Attributes["type"].Value;
     if (Property.Attributes.Count >= 5)
     {
         newFun.ValueExplain = Property.Attributes["exp"].Value;
         if (Property.Attributes.Count >= 6)
         {
             newFun.Opnode = Property.Attributes["opnode"].Value;
             newFun.Optype = Property.Attributes["optype"].Value;
             newFun.Opvalue = Property.Attributes["opvalue"].Value;
             newFun.Relate = Property.Attributes["relate"].Value;
         }
     }
     if (newFun.ValueType != "MyEnum")
     {
         object obj = Property.InnerText;
         if (newFun.ValueType != "queue" && obj.ToString() != "array")
         {
             Convert.ChangeType(obj, Type.GetType(newFun.ValueType));
         }
         newFun.TheValue = obj;
     }
     else
     {
         newFun.EnumValue = Property.InnerText;
         newFun.TheValue = Property.InnerText.Split(',')[0];
     }
     return newFun;
 }
        /* ���ڴ洢�õ�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>
 /// ���ݹ�������
 /// </summary>
 /// <param name="properties"></param>
 /// <returns></returns>
 private static List<XProp> CopyProperty(List<XProp> properties)
 {
     List<XProp> copyP = new List<XProp>();
     foreach (XProp element in properties)
     {
         XProp newPerty = new XProp();
         newPerty.EnumValue = element.EnumValue;
         newPerty.Name = element.Name;
         newPerty.Opnode = element.Opnode;
         newPerty.Optype = element.Optype;
         newPerty.Opvalue = element.Opvalue;
         newPerty.Relate = element.Relate;
         newPerty.TheValue = element.TheValue;
         newPerty.ValueExplain = element.ValueExplain;
         newPerty.ValueType = element.ValueType;
         newPerty.VarName = element.VarName;
         copyP.Add(newPerty);
     }
     return copyP;
 }
 /// <summary>
 /// ��ȡ"FunctionProperty"�ӽڵ�,�Կؼ���Ϣ�Ĺ������Բ��ֽ��г�ʼ��
 /// </summary>
 /// <param name="node">�������Խڵ�</param>
 /// <param name="CtrlInfo">�ؼ���Ϣ</param>
 /// <returns>�����Ϣ��ֵ��Ŀؼ���Ϣ</returns>
 public static void ReadFunctionProperty(XmlNode node, ref ControlInfo CtrlInfo)
 {
     List<XProp> VFunctionProperty = new List<XProp>();
     List<XProp> UFunctionProperty = new List<XProp>();
     foreach (XmlNode property in node.ChildNodes)
     {
         if (property.Name.Equals("Property"))
         {
             XProp Function = new XProp();
             Function.Name = property.Attributes["name"].Value;
             Function.VarName = property.Attributes["varname"].Value;
             Function.ValueType = property.Attributes["type"].Value;
             if (property.Attributes.Count >= 5)
             {//����5������������Ϊ������ӵIJ���������Ϣ
                 Function.ValueExplain = property.Attributes["exp"].Value;
                 if (property.Attributes.Count >= 6)
                 {//�������Կ�ʼΪ�Ż�����
                     Function.Opnode = property.Attributes["opnode"].Value;
                     Function.Optype = property.Attributes["optype"].Value;
                     Function.Opvalue = property.Attributes["opvalue"].Value;
                     Function.Relate = property.Attributes["relate"].Value;
                     if (Function.Opnode != null || Function.Optype != null || Function.Opvalue != null | Function.Relate != null)
                     {
                         CtrlInfo.CanOptimize = true;
                     }
                 }
             }
             if (property.Attributes["visible"].Value == "yes")
             {
                 if (property.Attributes["type"].Value != "MyEnum")
                 {//20090709��Ӳ��ֿؼ���ģ������Ĺ�������
                     object obj = property.InnerText;
                     Convert.ChangeType(obj, Type.GetType(property.Attributes["type"].Value));
                     Function.TheValue = obj;
                 }
                 else if (property.Attributes["type"].Value == "MyEnum")
                 {
                     CtrlInfo.HasEnumProperty = true;
                     Function.EnumValue = property.InnerText;
                     Function.TheValue = property.InnerText.Split(',')[0];
                 }
                 VFunctionProperty.Add(Function);
             }
             else
             {
                 if (property.Attributes["type"].Value != "MyEnum")
                 {
                     object obj = property.InnerText;
                     if (Function.ValueType != "queue" && obj.ToString() != "array")
                     {//20090604����ӵĶ���������λ��������,����ֵ������
                         Convert.ChangeType(obj, Type.GetType(property.Attributes["type"].Value));
                     }
                     Function.TheValue = obj;
                 }
                 else
                 {
                     Function.EnumValue = property.InnerText;
                     Function.TheValue = property.InnerText.Split(',')[0];
                 }
                 UFunctionProperty.Add(Function);
             }
         }//end if (property.Name.Equals("Property"))
     }//end foreach (XmlNode property in node.ChildNodes)
     CtrlInfo.VisibleFunctionProperty = VFunctionProperty;
     CtrlInfo.UnvisibleFunctionProperty = UFunctionProperty;
 }
        /// <summary>
        /// �ӿؼ���Ϣ�л�ȡ��ʾ��Ϣ
        /// �������index��-1�򷵻ض�Ӧ��ŵIJ�����ʾ��Ϣ
        /// ���򷵻����в�������ʾ��Ϣ
        /// </summary>
        /// <param name="ctrl">�ؼ���Ϣ</param>
        /// <param name="index">�������</param>
        /// <returns>��ʾ��Ϣ</returns>
        public void GetTipmessage(ControlInfo ctrl, int index)
        {
            List<string> TipMes = new List<string>();//�����õ���Ϣ����
            string tip = null;//��ʾ
            if (ctrl.VisibleFunctionProperty.Count == 0 && ctrl.UnvisibleFunctionProperty.Count == 0)
            {//Ĭ�Ϲ�������Ϊ����û�в�����ʾ��Ϣ
                this.toolTip1.Hide(this);
                return;
            }
            if (index == -1)
            {//����ȫ���IJ�����Ϣ
                int paraCount = 0;

                //foreach (XProp element in ctrl.VisibleFunctionProperty)
                //{
                //    tempMes = AddressTable.ConvertShowType(element.ValueType) + " " + element.VarName;
                //    if (TipMes.Count % 4 == 3)//ÿ��3������
                //    { tempMes = "\n" + tempMes; }
                //    TipMes.Add(tempMes);
                //}
                foreach (XProp element in ctrl.UnvisibleFunctionProperty)
                {
                    if (element.TheValue.ToString().Contains("array"))
                    {
                        //tempMes = AddressTable.ConvertShowType(element.ValueType) + " " + element.VarName;
                        //if (TipMes.Count % 4 == 3)
                        //{ tempMes = "\n" + tempMes; }
                        //TipMes.Add(tempMes);
                        paraCount++;
                    }
                }
                paraCount += ctrl.VisibleFunctionProperty.Count;
                if (this.toolTip1.ToolTipTitle != ctrl.SortName)
                { //�ؼ�������������
                    this.toolTip1.ToolTipTitle = ctrl.SortName;
                }

                if (PLCCodeEditor.CanTipCode.Contains(ctrl.CodeInfo[1]))
                {
                    tip += "1������";
                }
                else if (paraCount == 0)
                { tip += "�޲���"; }
                else
                {
                    tip += paraCount + "������";
                }

                tip += "\n" + ctrl.OtherProperty[2];

                this.toolTip1.Show(tip, this, new Point(Size.Width, 0));
                //return TipMes;
            }
            else if(ctrl.VisibleFunctionProperty.Count!=0)
            {//�����ƶ�������Ϣ
                int ParaCount = 0;//����������� �ڲ��ɼ��������Ա����м�¼����
                XProp tempFun = new XProp();

                if (index < ctrl.VisibleFunctionProperty.Count)
                {//�������С�ڿɼ���������
                    tempFun = ctrl.VisibleFunctionProperty[index];
                }
                //else
                //{
                    for (int x = 0; x < ctrl.UnvisibleFunctionProperty.Count; x++)
                    {
                        if (ctrl.UnvisibleFunctionProperty[x].TheValue.ToString().Contains("array"))
                        {//���ɼ��������
                            if (index == ParaCount + ctrl.VisibleFunctionProperty.Count)
                            {//��ŷ���
                                tempFun = ctrl.UnvisibleFunctionProperty[x];
                            }
                            ParaCount++;
                        }
                    }
                //}
                //string tip = AddressTable.ConvertShowType(tempFun.ValueType) + " " + tempFun.VarName;
                //if (index <= ParaCount + ctrl.VisibleFunctionProperty.Count - 1)
                //{
                //    if (index != ParaCount + ctrl.VisibleFunctionProperty.Count - 1)
                //    {//����Ϊ���һ������
                //        tip = tip + ",...";
                //    }
                //    if (index != 0)
                //    { //����Ϊ��һ������
                //        tip = "...," + tip;
                //    }
                //    //���ͺ��м���������Ϣ
                //    tip += "\n" + tempFun.Name + ":\n" + tempFun.ValueExplain;

                //    TipMes.Add(tip);
                //}
                string title = tempFun.Name + " (" + (index + 1) + "/" + (ParaCount + ctrl.VisibleFunctionProperty.Count) + ")";
                tip = AddressTable.ConvertShowType2(tempFun.ValueType) + "\n";
                for (int i = 0; i < tempFun.ValueExplain.Length; i++)
                {
                    if (i % 11 == 0)
                    {//11���ַ�����
                        tip += "\n";
                    }
                    tip += tempFun.ValueExplain[i];
                }
                if (this.toolTip1.ToolTipTitle != title)
                { this.toolTip1.ToolTipTitle = title; }
                this.toolTip1.Show(tip, this, new Point(Size.Width, 0));

            }
            //return TipMes;
        }
Exemple #7
0
 public XPropDescriptor(XProp prop, Attribute[] attrs)
     : base(prop.Name, attrs)
 {
     this.xProp = prop;
 }
 /// <summary>
 /// ��ǰ�ؼ���ij�����Ƿ�������ַ����
 /// </summary>
 /// <param name="address">��ַ��Ϣ�б�</param>
 /// <param name="ctrl">��ǰ�ؼ���Ϣ</param>
 /// <param name="atribt">������Ϣ</param>
 /// <returns>���ڵ�ַ��Ϣ����Ϊtrue</returns>
 private bool Findaddressinfo(List<string[]> address, ControlInfo ctrl, XProp atribt)
 {
     foreach (string[] ads in address)
     {
         if (ads[0] == ctrl.CodeInfo[2])
         {//�ؼ�����ͬ
             if (ads[6] == atribt.VarName)
             {
                 return true;
             }
         }
     }
     return false;
 }