Beispiel #1
0
        private void sendButtonClick(object sender, EventArgs e)
        {
            Type t = sender.GetType();

            Library.SendButton tb = (Library.SendButton)sender;
            DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
            DataBus.DataSend.CDataSend          dataSend;
            dataSend = new DataBus.DataSend.CDataSend();

            string RelatedPort = "";
            string PortData    = "";
            string PortBind    = "";
            string DeviceType  = "";


            PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
            PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
            PropertyInfo m_PortData    = t.GetProperty("PortData");
            PropertyInfo m_PortBind    = t.GetProperty("PortBind");
            PropertyInfo m_DeviceName  = t.GetProperty("DeviceName");
            PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
            string       currentName   = "Denchp_" + t.Name.ToString();

            dataPT.GetBoardPortByNameBdnum(currentName, BoardNumber, ref RelatedPort, ref DeviceType);
            dataPT.GetBoardSendPortByNameBdnum(currentName, BoardNumber, ref RelatedPort, ref PortData, ref PortBind);
            bool isSuccess = dataSend.SendControlData(tb.sendData.Text, RelatedPort, PortBind, this.BoardNumber);

            if (isSuccess == true)
            {
                System.Windows.Forms.MessageBox.Show("Success!");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Failed!");
            }

            m_BoardNumber.SetValue(tb, BoardNumber, null);
            m_RelatedPort.SetValue(tb, RelatedPort, null);
            //m_DeviceType.SetValue(tb, currentType, null);
            m_DeviceName.SetValue(tb, currentName, null);
            m_PortData.SetValue(tb, PortData, null);
            m_PortBind.SetValue(tb, PortBind, null);
        }
Beispiel #2
0
        //打开一个编辑画面
        public void OpenOneForm(String name)
        {
            //需新增功能: 所有form只打开一次
            for (int i = 0; i < editFormList.Count; i++)
            {
                if (editFormList[i].currentName == name)
                {
                    editFormList[i].Show();
                    return;
                }
            }
            RunTimeForm m_RTeditWindow = new RunTimeForm(this);

            try
            {
                string      fileName = myProjectPath + name + ".xml";
                HostControl hc       = _hostSurfaceManager.LoadNewHost(fileName);

                m_RTeditWindow.parentForm  = this;
                m_RTeditWindow.currentName = name;
                m_RTeditWindow.Text        = name;
                m_RTeditWindow.TabText     = name;
                editFormList.Add(m_RTeditWindow);

                //填充画面
                UserControl f    = new UserControl();
                UserControl user = (UserControl)_hostSurfaceManager.basicHostLoader.mComponents[0];
                f.BackColor             = user.BackColor;
                f.BackgroundImage       = user.BackgroundImage;
                f.BackgroundImageLayout = user.BackgroundImageLayout;
                f.BorderStyle           = user.BorderStyle;
                f.Font      = user.Font;
                f.ForeColor = user.ForeColor;
                f.Size      = user.Size;
                f.Location  = new Point(0, 0);// user.Location;
                f.Name      = user.Name;

                #region 填充元件

                string        nodeString  = null;
                List <string> dllFailList = new List <string>(); //自定义控件出现错误的列表

                for (int i = 1; i < _hostSurfaceManager.basicHostLoader.mComponents.Count; i++)
                {
                    Type t = _hostSurfaceManager.basicHostLoader.mComponents[i].GetType();
                    //自定义控件的处理-->
                    nodeString = "Components/AddedComponent[@Name=\"" + t.Name + "\"]";//注意这里AddedComponent作为与原先的区别
                    XmlNode tmpXNode = mXDoc.SelectSingleNode(nodeString);
                    if (tmpXNode != null)
                    {
                        //XmlNode test = tmpXNode.SelectSingleNode("Asm");
                        string   asmStr   = tmpXNode.Attributes["Asm"].Value;
                        Assembly assembly = null;
                        if (asmStr.Substring(asmStr.Length - 3) == "dll" || asmStr.Substring(asmStr.Length - 3) == "DLL")
                        {
                            if (File.Exists(@dllmng.DLLPATH + asmStr))
                            {
                                assembly = Assembly.LoadFile(dllmng.DLLPATH + asmStr);
                            }
                            else
                            {
                                if (!dllFailList.Contains("Can not find DLL: " + asmStr + " in file " + dllmng.DLLPATH))
                                {
                                    dllFailList.Add("Can not find DLL: " + asmStr + " in file " + dllmng.DLLPATH);
                                }
                                continue;
                            }
                        }
                        else
                        {
                            if (File.Exists(@dllmng.DLLPATH + asmStr + ".dll"))
                            {
                                assembly = Assembly.LoadFile(dllmng.DLLPATH + asmStr + ".dll");
                            }
                            else
                            {
                                if (!dllFailList.Contains("Can not find DLL: " + asmStr + ".dll" + " in file " + dllmng.DLLPATH))
                                {
                                    dllFailList.Add("Can not find DLL: " + asmStr + ".dll" + " in file " + dllmng.DLLPATH);
                                }
                                continue;
                            }
                        }
                        Type   type      = assembly.GetType(t.FullName.ToString()); //类名称
                        Object obj       = System.Activator.CreateInstance(type);
                        Object objInXml  = _hostSurfaceManager.basicHostLoader.mComponents[i];
                        Type   typeInXml = _hostSurfaceManager.basicHostLoader.mComponents[i].GetType();

                        ArrayList mObjectAttribs = new ArrayList();
                        if (tmpXNode != null)
                        {
                            try
                            {
                                XmlNodeList tmpXPropLst = tmpXNode.SelectNodes("Propertys/Property");
                                XmlNode     m_tmpXNode;
                                IEnumerator tmpIe = tmpXPropLst.GetEnumerator();
                                while (tmpIe.MoveNext())
                                {
                                    m_tmpXNode = tmpIe.Current as XmlNode;
                                    mObjectAttribs.Add(m_tmpXNode.Attributes["Name"].Value);
                                }
                            }
                            catch
                            { }
                        }
                        foreach (string arr in mObjectAttribs)
                        {
                            try
                            {
                                object arrObj = typeInXml.GetProperty(arr).GetValue(objInXml, null); //get
                                type.GetProperty(arr).SetValue(obj, arrObj, null);                   //set
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                        f.Controls.Add((Control)obj);
                        //<----
                    }
                    if (t.Name.Equals("PictureBox"))
                    {
                        Library.PictureBox control = (Library.PictureBox)Activator.CreateInstance(t);
                        Library.PictureBox cs      = (Library.PictureBox)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor   = cs.BackColor;
                        control.BorderStyle = cs.BorderStyle;
                        control.Image       = cs.Image;
                        control.SizeMode    = cs.SizeMode;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.Name        = cs.Name;
                        //增加运行时标志,目的仅为可见性使用!!!
                        control.isVisible = cs.isVisible;

                        //增加退出keydown 事件
                        control.KeyDown += new KeyEventHandler(control_KeyDown);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("Button"))
                    {
                        Library.Button control = (Library.Button)Activator.CreateInstance(t);
                        Library.Button cs      = (Library.Button)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor         = cs.BackColor;
                        control.Image             = cs.Image;
                        control.ImageAlign        = cs.ImageAlign;
                        control.Font              = cs.Font;
                        control.ForeColor         = cs.ForeColor;
                        control.FlatStyle         = cs.FlatStyle;
                        control.Text              = cs.Text;
                        control.TextAlign         = cs.TextAlign;
                        control.TextImageRelation = cs.TextImageRelation;
                        control.Size              = cs.Size;
                        control.Location          = cs.Location;
                        control.Name              = cs.Name;

                        control.KeyDown += new KeyEventHandler(control_KeyDown);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("SendButton"))
                    {
                        Library.SendButton control = (Library.SendButton)Activator.CreateInstance(t);
                        Library.SendButton cs      = (Library.SendButton)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor   = cs.BackColor;
                        control.BorderStyle = cs.BorderStyle;
                        control.Font        = cs.Font;
                        control.ForeColor   = cs.ForeColor;
                        control.Text        = cs.Text;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.Name        = cs.Name;
                        //增加运行时标志,目的仅为可见性使用!!!
                        // control.isVisible = cs.isVisible;
                        control.ID = cs.ID;
                        control.RelatedDeviceType = cs.RelatedDeviceType;
                        control.BoardNumber       = cs.BoardNumber;
                        control.RelatedPort       = cs.RelatedPort;
                        control.DeviceName        = cs.DeviceName;
                        control.rtdm = rtdm;
                        //control.Enabled = false; //选中无光标闪烁
                        //增加退出keydown 事件
                        control.KeyDown += new KeyEventHandler(control_KeyDown);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("TextBox"))
                    {
                        Library.TextBox control = (Library.TextBox)Activator.CreateInstance(t);
                        Library.TextBox cs      = (Library.TextBox)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor   = cs.BackColor;
                        control.BorderStyle = cs.BorderStyle;
                        control.Font        = cs.Font;
                        control.ForeColor   = cs.ForeColor;
                        control.Text        = cs.Text;
                        control.TextAlign   = cs.TextAlign;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.Name        = cs.Name;
                        //增加运行时标志,目的仅为可见性使用!!!
                        control.isVisible = cs.isVisible;

                        control.ID = cs.ID;
                        control.RelatedDeviceType = cs.RelatedDeviceType;
                        control.BoardNumber       = cs.BoardNumber;
                        control.RelatedPort       = cs.RelatedPort;
                        control.DeviceName        = cs.DeviceName;

                        control.rtdm = rtdm;

                        //control.Enabled = false; //选中无光标闪烁
                        //增加退出keydown 事件
                        control.KeyDown += new KeyEventHandler(control_KeyDown);
                        f.Controls.Add(control);
                    }

                    if (t.Name.Equals("Lable"))
                    {
                        Library.Lable control = (Library.Lable)Activator.CreateInstance(t);
                        Library.Lable cs      = (Library.Lable)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor   = cs.BackColor;
                        control.BorderStyle = cs.BorderStyle;
                        control.Font        = cs.Font;
                        control.ForeColor   = cs.ForeColor;
                        control.Text        = cs.Text;
                        control.TextAlign   = cs.TextAlign;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.Name        = cs.Name;

                        //增加退出keydown 事件
                        control.KeyDown += new KeyEventHandler(control_KeyDown);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("LDDS"))
                    {
                        Library.LDDS.Module control = (Library.LDDS.Module)Activator.CreateInstance(t);
                        Library.LDDS.Module cs      = (Library.LDDS.Module)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor     = cs.BackColor;
                        control.Size          = cs.Size;
                        control.Location      = cs.Location;
                        control.Name          = cs.Name;
                        control.InterfaceName = cs.InterfaceName;

                        control.OnDrawLineClick += new Library.LDDS.Module.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("ArrowLink"))
                    {
                        Library.LDDS.ArrowLink control = (Library.LDDS.ArrowLink)Activator.CreateInstance(t);
                        Library.LDDS.ArrowLink cs      = (Library.LDDS.ArrowLink)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor     = cs.BackColor;
                        control.Size          = cs.Size;
                        control.Location      = cs.Location;
                        control.Name          = cs.Name;
                        control.InterfaceName = cs.InterfaceName;

                        control.ArrowName = cs.ArrowName;
                        if (control.ArrowName.ToString() == "WaterMixingArrow")
                        {
                            this.BackgroundImage = global::Designer.Properties.Resources.WaterMixingArrow_new;
                        }
                        else if (control.ArrowName.ToString() == "ThermistorArrow")
                        {
                            this.BackgroundImage = global::Designer.Properties.Resources.ThermistorArrow;
                        }
                        else if (control.ArrowName.ToString() == "VibTestingArrow")
                        {
                            this.BackgroundImage = global::Designer.Properties.Resources.VibTestingArrow;
                        }
                        else if (control.ArrowName.ToString() == "FlowtestingArrow")
                        {
                            this.BackgroundImage = global::Designer.Properties.Resources.FlowTestingArrow_new;
                        }
                        else if (control.ArrowName.ToString() == "LengthArrow")
                        {
                            this.BackgroundImage = global::Designer.Properties.Resources.LengthArrow;
                        }
                        else if (control.ArrowName.ToString() == "HumidityArrow")
                        {
                            this.BackgroundImage = global::Designer.Properties.Resources.HumidityArrow;
                        }
                        //control.BackgroundImage = global::Library.Properties.Resources.VibTestingArrow;

                        control.OnDrawLineClick += new Library.LDDS.Module.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }


                    if (t.Name.Equals("Regenerator1"))
                    {
                        Library.LDDS.Regenerator1 control = (Library.LDDS.Regenerator1)Activator.CreateInstance(t);
                        Library.LDDS.Regenerator1 cs      = (Library.LDDS.Regenerator1)_hostSurfaceManager.basicHostLoader.mComponents[i];

                        control.BackColor        = cs.BackColor;
                        control.Size             = cs.Size;
                        control.Location         = cs.Location;
                        control.Name             = cs.Name;
                        control.BoardNumber      = cs.BoardNumber;
                        control.InterfaceName    = cs.InterfaceName;
                        control.rtdm             = rtdm;
                        control.OnDrawLineClick += new Library.LDDS.Regenerator1.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("Regenerator2"))
                    {
                        Library.LDDS.Regenerator2 control = (Library.LDDS.Regenerator2)Activator.CreateInstance(t);
                        Library.LDDS.Regenerator2 cs      = (Library.LDDS.Regenerator2)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor        = cs.BackColor;
                        control.Size             = cs.Size;
                        control.Location         = cs.Location;
                        control.Name             = cs.Name;
                        control.BoardNumber      = cs.BoardNumber;
                        control.InterfaceName    = cs.InterfaceName;
                        control.rtdm             = rtdm;
                        control.OnDrawLineClick += new Library.LDDS.Regenerator2.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("Regenerator3"))
                    {
                        Library.LDDS.Regenerator3 control = (Library.LDDS.Regenerator3)Activator.CreateInstance(t);
                        Library.LDDS.Regenerator3 cs      = (Library.LDDS.Regenerator3)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor        = cs.BackColor;
                        control.Size             = cs.Size;
                        control.Location         = cs.Location;
                        control.Name             = cs.Name;
                        control.BoardNumber      = cs.BoardNumber;
                        control.InterfaceName    = cs.InterfaceName;
                        control.rtdm             = rtdm;
                        control.OnDrawLineClick += new Library.LDDS.Regenerator2.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("Regenerator4"))
                    {
                        Library.LDDS.Regenerator4 control = (Library.LDDS.Regenerator4)Activator.CreateInstance(t);
                        Library.LDDS.Regenerator4 cs      = (Library.LDDS.Regenerator4)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.BackColor        = cs.BackColor;
                        control.Size             = cs.Size;
                        control.Location         = cs.Location;
                        control.Name             = cs.Name;
                        control.BoardNumber      = cs.BoardNumber;
                        control.InterfaceName    = cs.InterfaceName;
                        control.rtdm             = rtdm;
                        control.OnDrawLineClick += new Library.LDDS.Regenerator2.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("Dehumidifier1"))
                    {
                        Library.LDDS.Dehumidifier1          control = (Library.LDDS.Dehumidifier1)Activator.CreateInstance(t);
                        Library.LDDS.Dehumidifier1          cs      = (Library.LDDS.Dehumidifier1)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        DataBus.DataAccess.CData_PointTable dataPT  = new DataBus.DataAccess.CData_PointTable();

                        control.BackColor     = cs.BackColor;
                        control.Size          = cs.Size;
                        control.Location      = cs.Location;
                        control.Name          = cs.Name;
                        control.DeviceName    = control.DeviceName;
                        control.InterfaceName = cs.InterfaceName;
                        control.BoardNumber   = cs.BoardNumber;
                        control.rtdm          = rtdm;

                        control.OnDrawLineClick += new Library.LDDS.Dehumidifier1.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }


                    if (t.Name.Equals("Dehumidifier2"))
                    {
                        Library.LDDS.Dehumidifier2 control = (Library.LDDS.Dehumidifier2)Activator.CreateInstance(t);
                        Library.LDDS.Dehumidifier2 cs      = (Library.LDDS.Dehumidifier2)_hostSurfaceManager.basicHostLoader.mComponents[i];

                        control.BackColor        = cs.BackColor;
                        control.Size             = cs.Size;
                        control.Location         = cs.Location;
                        control.Name             = cs.Name;
                        control.InterfaceName    = cs.InterfaceName;
                        control.BoardNumber      = cs.BoardNumber;
                        control.rtdm             = rtdm;
                        control.OnDrawLineClick += new Library.LDDS.Dehumidifier2.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("Dehumidifier3"))
                    {
                        Library.LDDS.Dehumidifier3          control = (Library.LDDS.Dehumidifier3)Activator.CreateInstance(t);
                        Library.LDDS.Dehumidifier3          cs      = (Library.LDDS.Dehumidifier3)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        DataBus.DataAccess.CData_PointTable dataPT  = new DataBus.DataAccess.CData_PointTable();

                        control.BackColor     = cs.BackColor;
                        control.Size          = cs.Size;
                        control.Location      = cs.Location;
                        control.Name          = cs.Name;
                        control.DeviceName    = control.DeviceName;
                        control.InterfaceName = cs.InterfaceName;
                        control.BoardNumber   = cs.BoardNumber;
                        control.rtdm          = rtdm;

                        control.OnDrawLineClick += new Library.LDDS.Dehumidifier1.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }


                    if (t.Name.Equals("Dehumidifier4"))
                    {
                        Library.LDDS.Dehumidifier4 control = (Library.LDDS.Dehumidifier4)Activator.CreateInstance(t);
                        Library.LDDS.Dehumidifier4 cs      = (Library.LDDS.Dehumidifier4)_hostSurfaceManager.basicHostLoader.mComponents[i];

                        control.BackColor        = cs.BackColor;
                        control.Size             = cs.Size;
                        control.Location         = cs.Location;
                        control.Name             = cs.Name;
                        control.InterfaceName    = cs.InterfaceName;
                        control.BoardNumber      = cs.BoardNumber;
                        control.rtdm             = rtdm;
                        control.OnDrawLineClick += new Library.LDDS.Dehumidifier2.OnDrawLineEventHandle(Control_OnDrawLineClick);
                        f.Controls.Add(control);
                    }

                    if (t.Name.Equals("AtoMain"))
                    {
                        //                         AutotunerFinVerOne.AtoMain control = new AutotunerFinVerOne.AtoMain();
                        //                         AutotunerFinVerOne.AtoMain cs = (AutotunerFinVerOne.AtoMain)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        //                         control.ret_val = "AHU B4_309 Supply Air Temp Control Loop";
                        //                         cs.ret_val = "AHU B4_309 Supply Air Temp Control Loop";
                        //                         control.BackColor = cs.BackColor;
                        //                         control.Size = cs.Size;
                        //                         control.Location = cs.Location;
                        //                         //control.Name = cs.Name;
                        //                         f.Controls.Add(control);
                    }
                    //if (t.Name.Equals("ButtonCheck"))
                    //{
                    //    //                         SBB_ACMV.Controls.ButtonCheck control = (SBB_ACMV.Controls.ButtonCheck)Activator.CreateInstance(t);
                    //    //                         SBB_ACMV.Controls.ButtonCheck cs = (SBB_ACMV.Controls.ButtonCheck)_hostSurfaceManager.basicHostLoader.mComponents[i];
                    //    //                         control.BoardNo = cs.BoardNo;
                    //    //                         //control.BoardNoText = cs.BoardNoText;
                    //    //                         control.loopNo = cs.loopNo;
                    //    //                         //control.loopNoText = cs.loopNoText;
                    //    //                         control.BackColor = cs.BackColor;
                    //    //                         control.Name = cs.Name;
                    //    //                         control.Size = cs.Size;
                    //    //                         control.Location = cs.Location;
                    //    //                         //control.Name = cs.Name;
                    //    //                         f.Controls.Add(control);
                    //}


                    if (t.Name.Equals("SendButton"))
                    {
                        Library.SendButton control = (Library.SendButton)Activator.CreateInstance(t);
                        Library.SendButton cs      = (Library.SendButton)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.PortData    = cs.PortData;
                        control.PortBind    = cs.PortBind;
                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.DeviceName  = cs.DeviceName;
                        control.BackColor   = cs.BackColor;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        //control.Name = cs.Name;
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("statusIndicator"))
                    {
                        Library.statusIndicator control = (Library.statusIndicator)Activator.CreateInstance(t);
                        Library.statusIndicator cs      = (Library.statusIndicator)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.DeviceName  = cs.DeviceName;
                        control.BackColor   = cs.BackColor;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        //control.Name = cs.Name;
                        f.Controls.Add(control);
                        control.rtdm = rtdm;
                    }
                    if (t.Name.Equals("levelmeter"))
                    {
                        Library.Common.levelmeter control = (Library.Common.levelmeter)Activator.CreateInstance(t);
                        Library.Common.levelmeter cs      = (Library.Common.levelmeter)_hostSurfaceManager.basicHostLoader.mComponents[i];

                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.DeviceName  = cs.DeviceName;
                        control.BackColor   = cs.BackColor;
                        control.Value       = cs.Value;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.rtdm        = rtdm;
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("ButtonCheck"))
                    {
                        Library.Common.ButtonCheck control = (Library.Common.ButtonCheck)Activator.CreateInstance(t);
                        Library.Common.ButtonCheck cs      = (Library.Common.ButtonCheck)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.PortData    = cs.PortData;
                        control.PortBind    = cs.PortBind;
                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.DeviceName  = cs.DeviceName;
                        control.BackColor   = cs.BackColor;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.CheckStyleX = cs.CheckStyleX;
                        control.CheckCurrentState();
                        //control.Name = cs.Name;
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("ButtonCheckFun"))
                    {
                        Library.Common.ButtonCheckFun control = (Library.Common.ButtonCheckFun)Activator.CreateInstance(t);
                        Library.Common.ButtonCheckFun cs      = (Library.Common.ButtonCheckFun)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.PortData    = cs.PortData;
                        control.PortBind    = cs.PortBind;
                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.DeviceName  = cs.DeviceName;
                        control.BackColor   = cs.BackColor;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.CheckStyleX = cs.CheckStyleX;
                        control.CheckCurrentState();
                        //control.Name = cs.Name;
                        f.Controls.Add(control);
                    }
                    //if (t.Name.Equals("OnOff"))
                    //{
                    //    Library.Common.CommunicationOnOff control = (Library.Common.CommunicationOnOff)Activator.CreateInstance(t);
                    //    Library.Common.CommunicationOnOff cs = (Library.Common.CommunicationOnOff)_hostSurfaceManager.basicHostLoader.mComponents[i];
                    //    control.PortData = cs.PortData;
                    //    control.PortBind = cs.PortBind;
                    //    control.RelatedPort = cs.RelatedPort;
                    //    control.BoardNumber = cs.BoardNumber;
                    //    control.DeviceName = cs.DeviceName;
                    //    control.BackColor = cs.BackColor;
                    //    control.Name = cs.Name;
                    //    control.Size = cs.Size;
                    //    control.Location = cs.Location;
                    //    control.CheckStyleX = cs.CheckStyleX;
                    //    control.CheckCurrentState();
                    //    //control.Name = cs.Name;
                    //    f.Controls.Add(control);
                    //}
                    if (t.Name.Equals("Alarm"))
                    {
                        Library.Common.Alarm control = (Library.Common.Alarm)Activator.CreateInstance(t);
                        Library.Common.Alarm cs      = (Library.Common.Alarm)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.UpLimit     = cs.UpLimit;
                        control.DownLimit   = cs.DownLimit;
                        control.BackColor   = cs.BackColor;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.rtdm        = rtdm;
                        //control.Name = cs.Name;
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("RunState"))
                    {
                        Library.Common.RunState control = (Library.Common.RunState)Activator.CreateInstance(t);
                        Library.Common.RunState cs      = (Library.Common.RunState)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        control.RelatedPort = cs.RelatedPort;
                        control.BoardNumber = cs.BoardNumber;
                        control.BackColor   = cs.BackColor;
                        control.Name        = cs.Name;
                        control.Size        = cs.Size;
                        control.Location    = cs.Location;
                        control.rtdm        = rtdm;
                        f.Controls.Add(control);
                    }
                    if (t.Name.Equals("NumericUpDownEx"))
                    {
                        //                         SBB_ACMV.Controls.NumericUpDownEx control = (SBB_ACMV.Controls.NumericUpDownEx)Activator.CreateInstance(t);
                        //                         SBB_ACMV.Controls.NumericUpDownEx cs = (SBB_ACMV.Controls.NumericUpDownEx)_hostSurfaceManager.basicHostLoader.mComponents[i];
                        //                         control.BoardNo = cs.BoardNo;
                        //                         //control.BoardNoText = cs.BoardNoText;
                        //                         control.PortNo = cs.PortNo;
                        //                         //control.PortNoText = cs.PortNoText;
                        //                         control.BackColor = cs.BackColor;
                        //                         control.Name = cs.Name;
                        //                         control.Size = cs.Size;
                        //                         control.Location = cs.Location;
                        //                         //control.Name = cs.Name;
                        //                         f.Controls.Add(control);
                    }
                }

                //自定义dll错误信息显示
                string infoStr = "";
                foreach (string dllFail in dllFailList)
                {
                    infoStr += dllFail + "\r\n";
                }
                if (infoStr != "")
                {
                    MessageBox.Show(infoStr + "\r\n" + "Please Check!", "Custom Control(DLL) Error Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }


                //全屏幕form
                //                 FormState formState = new FormState();
                //                 this.SetVisibleCore(false);
                //                 formState.Maximize(m_RTeditWindow, false);
                //                 this.SetVisibleCore(true);
                //放置到主窗体
                m_RTeditWindow.panel1.Controls.Add(f);
                m_RTeditWindow.Show(m_RTmainWindow.ControlsDockPanel);

                #endregion
                f.KeyDown += new KeyEventHandler(f_KeyDown);
            }
            catch (Exception)
            {
                MessageBox.Show("Load Error!", "Load Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void UpdataButton_Click(object sender, EventArgs e)
        {
            if (couldBeBind == false)
            {
                return;
            }
            Type t = currentObj.GetType();

            if (t.Name.Equals("TextBox"))
            {
                Library.TextBox tb = (Library.TextBox)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);

                dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                //PropertyInfo m_DeviceID = t.GetProperty("ID");
                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                //m_DeviceID.SetValue(tb, currentID, null);
                m_DeviceName.SetValue(tb, currentName, null);
                currentType = "";
                currentName = "";

                /*  ================旧方法,不再使用,使用新的数据表及绑定方法,2016-3-26 xuehaoyuan
                 * currentID = NameComboBox.SelectedValue.ToString();
                 * dataPT.GetBoardPortByPointID(dataPT.GetReadPointID(currentType, currentID), ref BoardNumber, ref RelatedPort);
                 * PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                 * PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                 * PropertyInfo m_DeviceType = t.GetProperty("RelatedDeviceType");
                 * PropertyInfo m_DeviceID = t.GetProperty("ID");
                 * PropertyInfo m_DeviceName = t.GetProperty("DeviceName");
                 *
                 * m_BoardNumber.SetValue(tb, BoardNumber, null);
                 * m_RelatedPort.SetValue(tb, RelatedPort, null);
                 * m_DeviceType.SetValue(tb, currentType, null);
                 * m_DeviceID.SetValue(tb, currentID, null);
                 * m_DeviceName.SetValue(tb, currentName, null);
                 * currentType = "";
                 * currentID = "";
                 * currentName = "";
                 */
            }
            if (t.Name.Equals("levelmeter"))
            {
                Library.Common.levelmeter           tb     = (Library.Common.levelmeter)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);

                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                PropertyInfo m_LevelRange  = t.GetProperty("LevelRange");
                PropertyInfo m_DeviceName  = t.GetProperty("DeviceName");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                //     m_LevelRange.SetValue(tb, currentLevelRange, null);
                m_DeviceName.SetValue(tb, currentName, null);

                currentType = "";
                currentName = "";
            }
            if (t.Name.Equals("statusIndicator"))
            {
                Library.statusIndicator             tb     = (Library.statusIndicator)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                if (RWComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please Select R/W Model", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                //
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");

                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");


                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                m_DeviceName.SetValue(tb, currentName, null);
                //m_DeviceID.SetValue(tb, currentID, null);

                currentType = "";
                //currentID = "";
                currentName = "";
            }
            if (t.Name.Equals("Led"))
            {
                Library.Led tb = (Library.Led)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                string PortData    = "";
                string PortBind    = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                if (RWComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please Select R/W Model", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Read")
                {
                    dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Write")
                {
                    dataPT.GetBoardSendPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort, ref PortData, ref PortBind);
                }
                //
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                //PropertyInfo m_DeviceID = t.GetProperty("ID");
                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");
                PropertyInfo m_PortData   = t.GetProperty("PortData");
                PropertyInfo m_PortBind   = t.GetProperty("PortBind");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                //m_DeviceID.SetValue(tb, currentID, null);
                m_DeviceName.SetValue(tb, currentName, null);
                m_PortData.SetValue(tb, PortData, null);
                m_PortBind.SetValue(tb, PortBind, null);
                currentType = "";
                //currentID = "";
                currentName = "";
                PortData    = "";
                PortBind    = "";
            }

            if (t.Name.Equals("SendButton"))
            {
                Library.SendButton tb = (Library.SendButton)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                string PortData    = "";
                string PortBind    = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                if (RWComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please Select R/W Model", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Read")
                {
                    dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Write")
                {
                    dataPT.GetBoardSendPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort, ref PortData, ref PortBind);
                }
                //
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                //PropertyInfo m_DeviceID = t.GetProperty("ID");
                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");
                PropertyInfo m_PortData   = t.GetProperty("PortData");
                PropertyInfo m_PortBind   = t.GetProperty("PortBind");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                //m_DeviceID.SetValue(tb, currentID, null);
                m_DeviceName.SetValue(tb, currentName, null);
                m_PortData.SetValue(tb, PortData, null);
                m_PortBind.SetValue(tb, PortBind, null);
                currentType = "";
                //currentID = "";
                currentName = "";
                PortData    = "";
                PortBind    = "";
            }
            if (t.Name.Equals("Regenerator1"))
            {
                Library.LDDS.Regenerator1           tb     = (Library.LDDS.Regenerator1)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);

                dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");

                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");

                m_BoardNumber.SetValue(tb, BoardNumber, null);

                m_DeviceName.SetValue(tb, currentName, null);
                currentType = "";
                currentName = "";
            }
            if (t.Name.Equals("Regenerator3"))
            {
                Library.LDDS.Regenerator3           tb     = (Library.LDDS.Regenerator3)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);

                dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");

                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");

                m_BoardNumber.SetValue(tb, BoardNumber, null);

                m_DeviceName.SetValue(tb, currentName, null);
                currentType = "";
                currentName = "";
            }
            if (t.Name.Equals("Dehumidifier1"))
            {
                Library.LDDS.Dehumidifier1          tb     = (Library.LDDS.Dehumidifier1)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);

                dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");

                PropertyInfo m_DeviceName = t.GetProperty("DeviceName");

                m_BoardNumber.SetValue(tb, BoardNumber, null);

                m_DeviceName.SetValue(tb, currentName, null);
                currentType = "";
                currentName = "";
            }
            if (t.Name.Equals("ButtonCheck"))
            {
                Library.Common.ButtonCheck          tb     = (Library.Common.ButtonCheck)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                string PortData    = "";
                string PortBind    = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                if (RWComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please Select R/W Model", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Read")
                {
                    dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Write")
                {
                    dataPT.GetBoardSendPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort, ref PortData, ref PortBind);
                }
                //
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                PropertyInfo m_DeviceName  = t.GetProperty("DeviceName");
                PropertyInfo m_PortData    = t.GetProperty("PortData");
                PropertyInfo m_PortBind    = t.GetProperty("PortBind");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                //m_DeviceID.SetValue(tb, currentID, null);
                m_DeviceName.SetValue(tb, currentName, null);
                m_PortData.SetValue(tb, PortData, null);
                m_PortBind.SetValue(tb, PortBind, null);
                currentType = "";
                currentName = "";
                PortData    = "";
                PortBind    = "";
            }
            if (t.Name.Equals("ButtonCheckFun"))
            {
                Library.Common.ButtonCheckFun       tb     = (Library.Common.ButtonCheckFun)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                string PortData    = "";
                string PortBind    = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                if (RWComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please Select R/W Model", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Read")
                {
                    dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                }
                else if (RWComboBox.SelectedValue.ToString() == "Write")
                {
                    dataPT.GetBoardSendPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort, ref PortData, ref PortBind);
                }
                //
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                PropertyInfo m_DeviceName  = t.GetProperty("DeviceName");
                PropertyInfo m_PortData    = t.GetProperty("PortData");
                PropertyInfo m_PortBind    = t.GetProperty("PortBind");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                //m_DeviceID.SetValue(tb, currentID, null);
                m_DeviceName.SetValue(tb, currentName, null);
                m_PortData.SetValue(tb, PortData, null);
                m_PortBind.SetValue(tb, PortBind, null);
                currentType = "";
                currentName = "";
                PortData    = "";
                PortBind    = "";
            }
            if (t.Name.Equals("RunState"))
            {
                Library.Common.RunState             tb     = (Library.Common.RunState)currentObj;
                DataBus.DataAccess.CData_PointTable dataPT = new DataBus.DataAccess.CData_PointTable();
                string BoardNumber = "";
                string RelatedPort = "";
                if (TypeComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please select a Type!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (NameComboBox.SelectedItem == null)
                {
                    MessageBox.Show("Please select a name!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                currentType = TypeComboBox.SelectedValue.ToString();
                currentName = NameComboBox.GetItemText(NameComboBox.SelectedItem);
                if (RWComboBox.SelectedValue == null)
                {
                    MessageBox.Show("Please Select R/W Model", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    dataPT.GetBoardPortByNameType(currentName, currentType, ref BoardNumber, ref RelatedPort);
                }
                PropertyInfo m_BoardNumber = t.GetProperty("BoardNumber");
                PropertyInfo m_RelatedPort = t.GetProperty("RelatedPort");
                PropertyInfo m_DeviceType  = t.GetProperty("RelatedDeviceType");
                PropertyInfo m_DeviceName  = t.GetProperty("DeviceName");

                m_BoardNumber.SetValue(tb, BoardNumber, null);
                m_RelatedPort.SetValue(tb, RelatedPort, null);
                m_DeviceType.SetValue(tb, currentType, null);
                m_DeviceName.SetValue(tb, currentName, null);
                currentType = "";
                currentName = "";
            }
        }