示例#1
0
        /// <summary>
        /// 切换Tab
        /// </summary>
        /// <param name="tab"></param>
        private void SelectedTab(TabPage tab)
        {
            Text = "IoTClient Tool - " + tab.Name;
            SaveTabName(tab.Name);
            if (tab.Controls.Count <= 0)
            {
                switch (tab.Name)
                {
                case "ModBusTcp":
                    var modBusTcp = new ModBusTcpControl();
                    modBusTcp.Dock = DockStyle.Fill;
                    tab.Controls.Add(modBusTcp);
                    break;

                case "ModBusRtu":
                    var modBusRtu = new ModBusRtuControl();
                    modBusRtu.Dock = DockStyle.Fill;
                    tab.Controls.Add(modBusRtu);
                    break;

                case "Siemens":
                    var siemens = new SiemensControl();
                    siemens.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemens);
                    break;

                case "BACnet":
                    var bacnet = new BACnetControl();
                    bacnet.Dock = DockStyle.Fill;
                    tab.Controls.Add(bacnet);
                    break;

                case "Ports":
                    var ports = new PortsControl();
                    ports.Dock = DockStyle.Fill;
                    tab.Controls.Add(ports);
                    break;
                }
            }
            else
            {
                switch (tab.Controls[0].Name)
                {
                case nameof(PortsControl):
                    var portsControl = tab.Controls[0] as PortsControl;
                    portsControl?.UpdatePortNames();
                    break;

                case nameof(ModBusRtuControl):
                    var modBusRtuControl = tab.Controls[0] as ModBusRtuControl;
                    modBusRtuControl?.UpdatePortNames();
                    break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// 切换Tab
        /// </summary>
        /// <param name="tab"></param>
        private void SelectedTab(TabPage tab)
        {
            Text = "IoTClient Tool - " + tab.Text?.Trim();
            SaveTabName(tab.Name);
            if (tab.Controls.Count <= 0)
            {
                switch (tab.Name)
                {
                case "ModBusTcp":
                    var modBusTcp = new ModBusTcpControl();
                    modBusTcp.Dock = DockStyle.Fill;
                    tab.Controls.Add(modBusTcp);
                    break;

                case "ModBusRtu":
                    var modBusRtu = new ModBusRtuControl();
                    modBusRtu.Dock = DockStyle.Fill;
                    tab.Controls.Add(modBusRtu);
                    break;

                case "ModBusAscii":
                    var modBusAscii = new ModBusAsciiControl();
                    modBusAscii.Dock = DockStyle.Fill;
                    tab.Controls.Add(modBusAscii);
                    break;

                case "Siemens":
                    var siemens = new SiemensControl();
                    siemens.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemens);
                    break;

                case "SiemensS7300":
                    var siemensS7_300 = new SiemensS7_300Control();
                    siemensS7_300.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_300);
                    break;

                case "BACnet":
                    var bacnet = new BACnetControl();
                    bacnet.Dock = DockStyle.Fill;
                    tab.Controls.Add(bacnet);
                    break;

                case "Ports":
                    var ports = new PortsControl();
                    ports.Dock = DockStyle.Fill;
                    tab.Controls.Add(ports);
                    break;

                case "MitsubishiMC":
                    var mitsubishiMC = new MitsubishiMCControl();
                    mitsubishiMC.Dock = DockStyle.Fill;
                    tab.Controls.Add(mitsubishiMC);
                    break;

                case "OmronFinsTcp":
                    var omronFinsTcp = new OmronFinsTcpControl();
                    omronFinsTcp.Dock = DockStyle.Fill;
                    tab.Controls.Add(omronFinsTcp);
                    break;

                case "Other":
                    var otherControl = new OtherControl();
                    otherControl.Dock = DockStyle.Fill;
                    tab.Controls.Add(otherControl);
                    break;
                }
            }
            else
            {
                switch (tab.Controls[0].Name)
                {
                case nameof(PortsControl):
                    var portsControl = tab.Controls[0] as PortsControl;
                    portsControl?.UpdatePortNames();
                    break;

                case nameof(ModBusRtuControl):
                    var modBusRtuControl = tab.Controls[0] as ModBusRtuControl;
                    modBusRtuControl?.UpdatePortNames();
                    break;
                }
            }
        }