예제 #1
0
        /* ��̬�����Զ���ؼ� */
        private void createCustomCtl(T_GENERIC_INFO info)
        {
            CheckBox cb;
            RadioButton rb;
            Color customColor = Color.Blue;
            CustomCtls.labelNum ud;

            if (info.widget == "")
            {
                MessageBox.Show("widget����Ϊ��, �޷������ؼ���" + info.name);
                return;
            }

            if (info.parent == "") return;
            Control ctl = this.Controls.Find(info.parent, true)[0];
            if (ctl == null) return;
            switch (info.custom)
            {
                case 1:
                    cb = new CheckBox();
                    cb.Name = info.widget;
                    cb.Text = info.desc;
                    cb.AutoSize = true;
                    cb.ForeColor = customColor;
                    cb.ContextMenuStrip = ctxMenu;
                    cb.Tag = "Custom";  /* ��Ҫ��ʱ�򣬸������tag��ɾ���ؼ� */
                    cb.CheckedChanged += new EventHandler(eventHandlerCustom);
                    addControlToContainer(ctl, cb);
                    break;
                case 2:
                    rb = new RadioButton();
                    rb.Name = info.widget;
                    rb.Text = info.desc;
                    rb.AutoSize = true;
                    rb.ForeColor = customColor;
                    rb.ContextMenuStrip = ctxMenu;
                    rb.Tag = "Custom";  /* ��Ҫ��ʱ�򣬸������tag��ɾ���ؼ� */
                    rb.CheckedChanged += new EventHandler(eventHandlerCustom);
                    addControlToContainer(ctl, rb);
                    break;
                case 3:
                    ud = new CustomCtls.labelNum();
                    ud.Name = info.widget;
                    ud.labelText = info.desc;
                    //ud.Size = new Size(50,25);
                    ud.ForeColor = customColor;
                    ud.ContextMenuStrip = ctxMenu;
                    ud.Tag = "Custom";  /* ��Ҫ��ʱ�򣬸������tag��ɾ���ؼ� */
                    ud.OnValueChanged += new EventHandler(eventHandlerCustom);
                    addControlToContainer(ctl, ud);
                    break;

            }
        }
예제 #2
0
        private List<T_GENERIC_INFO> getProtocolInfo(T_GENERIC_INFO info, XmlNode ndProt)
        {
            T_GENERIC_INFO retVal = info;
            List<T_GENERIC_INFO> retList = new List<T_GENERIC_INFO>();

            retVal.protocol = ndProt.Name;
            if (ndProt.Attributes != null)
            {
                if (ndProt.Attributes["Trigger"] != null) retVal.trigger = ndProt.Attributes["Trigger"].InnerText.Trim();
                if (ndProt.Attributes["Auto"] != null) retVal.auto = Convert.ToInt32(ndProt.Attributes["Auto"].InnerText.Trim());
                if (ndProt.Attributes["Repeat"] != null) retVal.repeat = Convert.ToInt32(ndProt.Attributes["Repeat"].InnerText.Trim());
                if (ndProt.Attributes["Delay"] != null) retVal.delay = Convert.ToInt32(ndProt.Attributes["Delay"].InnerText.Trim());
            }
            foreach (XmlNode nd in ndProt.ChildNodes)
            {
                switch (nd.Name)
                {
                    case "ID": /* 16进制 */
                        retVal.id = Convert.ToUInt16(nd.InnerText.Trim(), 16);
                        break;
                    case "DataLength":
                        retVal.dataLen = Convert.ToByte(nd.InnerText.Trim());
                        break;
                    case "StartBit":
                        retVal.startBit = Convert.ToByte(nd.InnerText.Trim());
                        if (retVal.endBit == 0) retVal.endBit = retVal.startBit;
                        break;
                    case "EndBit":
                        retVal.endBit = Convert.ToByte(nd.InnerText.Trim());
                        break;
                    case "Factor":
                        retVal.factor = Convert.ToDouble(nd.InnerText.Trim());
                        break;
                    case "Offset":
                        retVal.offset = Convert.ToDouble(nd.InnerText.Trim());
                        break;
                    case "PreOffset":
                        retVal.preoffset = Convert.ToDouble(nd.InnerText.Trim());
                        break;
                    default:
                        break;
                }
            }

            retList.Add(retVal);
            return retList;
        }
예제 #3
0
        /* ����ָ�����ֿؼ���Ĭ��ֵ */
        private void setCtlValue(T_GENERIC_INFO info, string tooltip)
        {
            Control[] ctls;
            Control ctl;
            NumericUpDown ud;
            RadioButton rb;
            CheckBox cb;

            if (info.widget == "") return;
            ctls = this.Controls.Find(info.widget, true);
            if (ctls.Length == 0) return;
            ctl = ctls[0];
            if (ctl == null) return;

            toolTipMain.SetToolTip(ctl, tooltip);
            if (ctl is labelNum)
                (ctl as labelNum).toolTipText=(tooltip);
            //Console.WriteLine(ctl.Name);
            if (info.repeat == 1) setCtlBackColorRepeat(ctl);
            else if (info.auto == 1)
                hilightCtlBackColor(ctl); /* �Զ����� */
            else restoreCtlBackColor(ctl);

            if (ctl is NumericUpDown)
            {
                ud = ctl as NumericUpDown;
                ud.Minimum = Convert.ToInt32(info.min);
                ud.Maximum = Convert.ToInt32(info.max);
                ud.Value = Convert.ToDecimal(info.vDefault);
            }
            else if (ctl is RadioButton)
            {
                rb = ctl as RadioButton;
                rb.Checked = Convert.ToBoolean(info.vDefault);
            }
            else if (ctl is CheckBox)
            {
                cb = ctl as CheckBox;
                cb.Checked = Convert.ToBoolean(info.vDefault);
            }
            else if (ctl is labelNum)
            {
                (ctl as labelNum).Minimum = Convert.ToInt32(info.min);
                (ctl as labelNum).Maximum = Convert.ToInt32(info.max);
                (ctl as labelNum).Value = Convert.ToDecimal(info.vDefault);
            }
        }
예제 #4
0
        private T_GENERIC_INFO getFuncInfo(T_GENERIC_INFO info, XmlNode nd)
        {
            T_GENERIC_INFO retVal = info;

            retVal.name = nd.Name;
            if (nd.Attributes != null)    // 节点的Attributes
            {
                if (nd.Attributes["desc"] != null) retVal.desc = nd.Attributes["desc"].InnerText.Trim();
                if (nd.Attributes["Custom"] != null) retVal.custom = Convert.ToInt32(nd.Attributes["Custom"].InnerText.Trim());
                if (nd.Attributes["Parent"] != null) retVal.parent = nd.Attributes["Parent"].InnerText.Trim();
                if (nd.Attributes["widget"] != null) retVal.widget = nd.Attributes["widget"].InnerText.Trim();
                if (nd.Attributes["widget2"] != null) retVal.widget2 = nd.Attributes["widget2"].InnerText.Trim();
                if (nd.Attributes["widget3"] != null) retVal.widget3 = nd.Attributes["widget3"].InnerText.Trim();
                if (nd.Attributes["min"] != null) retVal.min = Convert.ToDouble(nd.Attributes["min"].InnerText.Trim());
                if (nd.Attributes["max"] != null) retVal.max = Convert.ToDouble(nd.Attributes["max"].InnerText.Trim());
                if (nd.Attributes["default"] != null) retVal.vDefault = Convert.ToDouble(nd.Attributes["default"].InnerText.Trim());
                if (nd.Attributes["init"] != null) retVal.init = Convert.ToInt32(nd.Attributes["init"].InnerText.Trim());
                if (nd.Attributes["Auto"] != null) retVal.auto = Convert.ToInt32(nd.Attributes["Auto"].InnerText.Trim());
                if (nd.Attributes["Repeat"] != null) retVal.repeat = Convert.ToInt32(nd.Attributes["Repeat"].InnerText.Trim());
                if (nd.Attributes["Delay"] != null) retVal.delay = Convert.ToInt32(nd.Attributes["Delay"].InnerText.Trim());
            }
            return retVal;
        }