Пример #1
0
 private void CanMoveControl_PointerMoved(object sender, PointerRoutedEventArgs e)
 {
     if (sender is FrameworkElement uie)
     {
         var point = e.GetCurrentPoint(uie);
         if (point.Properties.IsLeftButtonPressed)
         {
             var x = Canvas.GetLeft(OtherControl);
             var y = Canvas.GetTop(OtherControl);
             x += point.Position.X - TmpPoint.X;
             y += point.Position.Y - TmpPoint.Y;
             OtherControl.SetValue(Canvas.LeftProperty, x);
             OtherControl.SetValue(Canvas.TopProperty, y);
         }
     }
 }
Пример #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;
                }
            }
        }
Пример #3
0
 public void TestPositiveCategories()
 {
     Assert.AreEqual(UppercaseLetter.ToString(), UnicodeCategory(Categories.UppercaseLetter).ToString());
     Assert.AreEqual(LowercaseLetter.ToString(), UnicodeCategory(Categories.LowercaseLetter).ToString());
     Assert.AreEqual(TitlecaseLetter.ToString(), UnicodeCategory(Categories.TitlecaseLetter).ToString());
     Assert.AreEqual(ModifierLetter.ToString(), UnicodeCategory(Categories.ModifierLetter).ToString());
     Assert.AreEqual(OtherLetter.ToString(), UnicodeCategory(Categories.OtherLetter).ToString());
     Assert.AreEqual(Letter.ToString(), UnicodeCategory(Categories.Letter).ToString());
     Assert.AreEqual(NonspacingMark.ToString(), UnicodeCategory(Categories.NonspacingMark).ToString());
     Assert.AreEqual(SpacingCombiningMark.ToString(), UnicodeCategory(Categories.SpacingCombiningMark).ToString());
     Assert.AreEqual(EnclosingMark.ToString(), UnicodeCategory(Categories.EnclosingMark).ToString());
     Assert.AreEqual(Mark.ToString(), UnicodeCategory(Categories.Mark).ToString());
     Assert.AreEqual(DecimalDigitNumber.ToString(), UnicodeCategory(Categories.DecimalDigitNumber).ToString());
     Assert.AreEqual(LetterNumber.ToString(), UnicodeCategory(Categories.LetterNumber).ToString());
     Assert.AreEqual(OtherNumber.ToString(), UnicodeCategory(Categories.OtherNumber).ToString());
     Assert.AreEqual(Number.ToString(), UnicodeCategory(Categories.Number).ToString());
     Assert.AreEqual(ConnectorPunctuation.ToString(), UnicodeCategory(Categories.ConnectorPunctuation).ToString());
     Assert.AreEqual(DashPunctuation.ToString(), UnicodeCategory(Categories.DashPunctuation).ToString());
     Assert.AreEqual(OpenPunctuation.ToString(), UnicodeCategory(Categories.OpenPunctuation).ToString());
     Assert.AreEqual(ClosePunctuation.ToString(), UnicodeCategory(Categories.ClosePunctuation).ToString());
     Assert.AreEqual(InitialquotePunctuation.ToString(), UnicodeCategory(Categories.InitialquotePunctuation).ToString());
     Assert.AreEqual(FinalquotePunctuation.ToString(), UnicodeCategory(Categories.FinalquotePunctuation).ToString());
     Assert.AreEqual(OtherPunctuation.ToString(), UnicodeCategory(Categories.OtherPunctuation).ToString());
     Assert.AreEqual(Punctuation.ToString(), UnicodeCategory(Categories.Punctuation).ToString());
     Assert.AreEqual(MathSymbol.ToString(), UnicodeCategory(Categories.MathSymbol).ToString());
     Assert.AreEqual(CurrencySymbol.ToString(), UnicodeCategory(Categories.CurrencySymbol).ToString());
     Assert.AreEqual(ModifierSymbol.ToString(), UnicodeCategory(Categories.ModifierSymbol).ToString());
     Assert.AreEqual(OtherSymbol.ToString(), UnicodeCategory(Categories.OtherSymbol).ToString());
     Assert.AreEqual(Patterns.Unicode.Symbol.ToString(), UnicodeCategory(Categories.Symbol).ToString());
     Assert.AreEqual(SpaceSeparator.ToString(), UnicodeCategory(Categories.SpaceSeparator).ToString());
     Assert.AreEqual(LineSeparator.ToString(), UnicodeCategory(Categories.LineSeparator).ToString());
     Assert.AreEqual(ParagraphSeparator.ToString(), UnicodeCategory(Categories.ParagraphSeparator).ToString());
     Assert.AreEqual(Separator.ToString(), UnicodeCategory(Categories.Separator).ToString());
     Assert.AreEqual(Format.ToString(), UnicodeCategory(Categories.Format).ToString());
     Assert.AreEqual(Surrogate.ToString(), UnicodeCategory(Categories.Surrogate).ToString());
     Assert.AreEqual(PrivateUse.ToString(), UnicodeCategory(Categories.PrivateUse).ToString());
     Assert.AreEqual(NotAssigned.ToString(), UnicodeCategory(Categories.NotAssigned).ToString());
     Assert.AreEqual(OtherControl.ToString(), UnicodeCategory(Categories.OtherControl).ToString());
     Assert.AreEqual(Control.ToString(), UnicodeCategory(Categories.Control).ToString());
     Assert.AreEqual(BasicLatin.ToString(), UnicodeCategory(Categories.BasicLatin).ToString());
     Assert.AreEqual(Latin_1Supplement.ToString(), UnicodeCategory(Categories.Latin_1Supplement).ToString());
     Assert.AreEqual(LatinExtended_A.ToString(), UnicodeCategory(Categories.LatinExtended_A).ToString());
     Assert.AreEqual(LatinExtended_B.ToString(), UnicodeCategory(Categories.LatinExtended_B).ToString());
     Assert.AreEqual(IPAExtensions.ToString(), UnicodeCategory(Categories.IPAExtensions).ToString());
     Assert.AreEqual(SpacingModifierLetters.ToString(), UnicodeCategory(Categories.SpacingModifierLetters).ToString());
     Assert.AreEqual(CombiningDiacriticalMarks.ToString(), UnicodeCategory(Categories.CombiningDiacriticalMarks).ToString());
     Assert.AreEqual(Greek.ToString(), UnicodeCategory(Categories.Greek).ToString());
     Assert.AreEqual(GreekandCoptic.ToString(), UnicodeCategory(Categories.GreekandCoptic).ToString());
     Assert.AreEqual(Cyrillic.ToString(), UnicodeCategory(Categories.Cyrillic).ToString());
     Assert.AreEqual(CyrillicSupplement.ToString(), UnicodeCategory(Categories.CyrillicSupplement).ToString());
     Assert.AreEqual(Armenian.ToString(), UnicodeCategory(Categories.Armenian).ToString());
     Assert.AreEqual(Hebrew.ToString(), UnicodeCategory(Categories.Hebrew).ToString());
     Assert.AreEqual(Arabic.ToString(), UnicodeCategory(Categories.Arabic).ToString());
     Assert.AreEqual(Syriac.ToString(), UnicodeCategory(Categories.Syriac).ToString());
     Assert.AreEqual(Thaana.ToString(), UnicodeCategory(Categories.Thaana).ToString());
     Assert.AreEqual(Devanagari.ToString(), UnicodeCategory(Categories.Devanagari).ToString());
     Assert.AreEqual(Bengali.ToString(), UnicodeCategory(Categories.Bengali).ToString());
     Assert.AreEqual(Gurmukhi.ToString(), UnicodeCategory(Categories.Gurmukhi).ToString());
     Assert.AreEqual(Gujarati.ToString(), UnicodeCategory(Categories.Gujarati).ToString());
     Assert.AreEqual(Oriya.ToString(), UnicodeCategory(Categories.Oriya).ToString());
     Assert.AreEqual(Tamil.ToString(), UnicodeCategory(Categories.Tamil).ToString());
     Assert.AreEqual(Telugu.ToString(), UnicodeCategory(Categories.Telugu).ToString());
     Assert.AreEqual(Kannada.ToString(), UnicodeCategory(Categories.Kannada).ToString());
     Assert.AreEqual(Malayalam.ToString(), UnicodeCategory(Categories.Malayalam).ToString());
     Assert.AreEqual(Sinhala.ToString(), UnicodeCategory(Categories.Sinhala).ToString());
     Assert.AreEqual(Thai.ToString(), UnicodeCategory(Categories.Thai).ToString());
     Assert.AreEqual(Lao.ToString(), UnicodeCategory(Categories.Lao).ToString());
     Assert.AreEqual(Tibetan.ToString(), UnicodeCategory(Categories.Tibetan).ToString());
     Assert.AreEqual(Myanmar.ToString(), UnicodeCategory(Categories.Myanmar).ToString());
     Assert.AreEqual(Georgian.ToString(), UnicodeCategory(Categories.Georgian).ToString());
     Assert.AreEqual(HangulJamo.ToString(), UnicodeCategory(Categories.HangulJamo).ToString());
     Assert.AreEqual(Ethiopic.ToString(), UnicodeCategory(Categories.Ethiopic).ToString());
     Assert.AreEqual(Cherokee.ToString(), UnicodeCategory(Categories.Cherokee).ToString());
     Assert.AreEqual(UnifiedCanadianAboriginalSyllabics.ToString(), UnicodeCategory(Categories.UnifiedCanadianAboriginalSyllabics).ToString());
     Assert.AreEqual(Ogham.ToString(), UnicodeCategory(Categories.Ogham).ToString());
     Assert.AreEqual(Runic.ToString(), UnicodeCategory(Categories.Runic).ToString());
     Assert.AreEqual(Tagalog.ToString(), UnicodeCategory(Categories.Tagalog).ToString());
     Assert.AreEqual(Hanunoo.ToString(), UnicodeCategory(Categories.Hanunoo).ToString());
     Assert.AreEqual(Buhid.ToString(), UnicodeCategory(Categories.Buhid).ToString());
     Assert.AreEqual(Tagbanwa.ToString(), UnicodeCategory(Categories.Tagbanwa).ToString());
     Assert.AreEqual(Khmer.ToString(), UnicodeCategory(Categories.Khmer).ToString());
     Assert.AreEqual(Mongolian.ToString(), UnicodeCategory(Categories.Mongolian).ToString());
     Assert.AreEqual(Limbu.ToString(), UnicodeCategory(Categories.Limbu).ToString());
     Assert.AreEqual(TaiLe.ToString(), UnicodeCategory(Categories.TaiLe).ToString());
     Assert.AreEqual(KhmerSymbols.ToString(), UnicodeCategory(Categories.KhmerSymbols).ToString());
     Assert.AreEqual(PhoneticExtensions.ToString(), UnicodeCategory(Categories.PhoneticExtensions).ToString());
     Assert.AreEqual(LatinExtendedAdditional.ToString(), UnicodeCategory(Categories.LatinExtendedAdditional).ToString());
     Assert.AreEqual(GreekExtended.ToString(), UnicodeCategory(Categories.GreekExtended).ToString());
     Assert.AreEqual(GeneralPunctuation.ToString(), UnicodeCategory(Categories.GeneralPunctuation).ToString());
     Assert.AreEqual(SuperscriptsandSubscripts.ToString(), UnicodeCategory(Categories.SuperscriptsandSubscripts).ToString());
     Assert.AreEqual(CurrencySymbols.ToString(), UnicodeCategory(Categories.CurrencySymbols).ToString());
     Assert.AreEqual(CombiningDiacriticalMarksforSymbols.ToString(), UnicodeCategory(Categories.CombiningDiacriticalMarksforSymbols).ToString());
     Assert.AreEqual(CombiningMarksforSymbols.ToString(), UnicodeCategory(Categories.CombiningMarksforSymbols).ToString());
     Assert.AreEqual(LetterlikeSymbols.ToString(), UnicodeCategory(Categories.LetterlikeSymbols).ToString());
     Assert.AreEqual(NumberForms.ToString(), UnicodeCategory(Categories.NumberForms).ToString());
     Assert.AreEqual(Arrows.ToString(), UnicodeCategory(Categories.Arrows).ToString());
     Assert.AreEqual(MathematicalOperators.ToString(), UnicodeCategory(Categories.MathematicalOperators).ToString());
     Assert.AreEqual(MiscellaneousTechnical.ToString(), UnicodeCategory(Categories.MiscellaneousTechnical).ToString());
     Assert.AreEqual(ControlPictures.ToString(), UnicodeCategory(Categories.ControlPictures).ToString());
     Assert.AreEqual(OpticalCharacterRecognition.ToString(), UnicodeCategory(Categories.OpticalCharacterRecognition).ToString());
     Assert.AreEqual(EnclosedAlphanumerics.ToString(), UnicodeCategory(Categories.EnclosedAlphanumerics).ToString());
     Assert.AreEqual(BoxDrawing.ToString(), UnicodeCategory(Categories.BoxDrawing).ToString());
     Assert.AreEqual(BlockElements.ToString(), UnicodeCategory(Categories.BlockElements).ToString());
     Assert.AreEqual(GeometricShapes.ToString(), UnicodeCategory(Categories.GeometricShapes).ToString());
     Assert.AreEqual(MiscellaneousSymbols.ToString(), UnicodeCategory(Categories.MiscellaneousSymbols).ToString());
     Assert.AreEqual(Dingbats.ToString(), UnicodeCategory(Categories.Dingbats).ToString());
     Assert.AreEqual(MiscellaneousMathematicalSymbols_A.ToString(), UnicodeCategory(Categories.MiscellaneousMathematicalSymbols_A).ToString());
     Assert.AreEqual(SupplementalArrows_A.ToString(), UnicodeCategory(Categories.SupplementalArrows_A).ToString());
     Assert.AreEqual(BraillePatterns.ToString(), UnicodeCategory(Categories.BraillePatterns).ToString());
     Assert.AreEqual(SupplementalArrows_B.ToString(), UnicodeCategory(Categories.SupplementalArrows_B).ToString());
     Assert.AreEqual(MiscellaneousMathematicalSymbols_B.ToString(), UnicodeCategory(Categories.MiscellaneousMathematicalSymbols_B).ToString());
     Assert.AreEqual(SupplementalMathematicalOperators.ToString(), UnicodeCategory(Categories.SupplementalMathematicalOperators).ToString());
     Assert.AreEqual(MiscellaneousSymbolsandArrows.ToString(), UnicodeCategory(Categories.MiscellaneousSymbolsandArrows).ToString());
     Assert.AreEqual(CJKRadicalsSupplement.ToString(), UnicodeCategory(Categories.CJKRadicalsSupplement).ToString());
     Assert.AreEqual(KangxiRadicals.ToString(), UnicodeCategory(Categories.KangxiRadicals).ToString());
     Assert.AreEqual(IdeographicDescriptionCharacters.ToString(), UnicodeCategory(Categories.IdeographicDescriptionCharacters).ToString());
     Assert.AreEqual(CJKSymbolsandPunctuation.ToString(), UnicodeCategory(Categories.CJKSymbolsandPunctuation).ToString());
     Assert.AreEqual(Hiragana.ToString(), UnicodeCategory(Categories.Hiragana).ToString());
     Assert.AreEqual(Katakana.ToString(), UnicodeCategory(Categories.Katakana).ToString());
     Assert.AreEqual(Bopomofo.ToString(), UnicodeCategory(Categories.Bopomofo).ToString());
     Assert.AreEqual(HangulCompatibilityJamo.ToString(), UnicodeCategory(Categories.HangulCompatibilityJamo).ToString());
     Assert.AreEqual(Kanbun.ToString(), UnicodeCategory(Categories.Kanbun).ToString());
     Assert.AreEqual(BopomofoExtended.ToString(), UnicodeCategory(Categories.BopomofoExtended).ToString());
     Assert.AreEqual(KatakanaPhoneticExtensions.ToString(), UnicodeCategory(Categories.KatakanaPhoneticExtensions).ToString());
     Assert.AreEqual(EnclosedCJKLettersandMonths.ToString(), UnicodeCategory(Categories.EnclosedCJKLettersandMonths).ToString());
     Assert.AreEqual(CJKCompatibility.ToString(), UnicodeCategory(Categories.CJKCompatibility).ToString());
     Assert.AreEqual(CJKUnifiedIdeographsExtensionA.ToString(), UnicodeCategory(Categories.CJKUnifiedIdeographsExtensionA).ToString());
     Assert.AreEqual(YijingHexagramSymbols.ToString(), UnicodeCategory(Categories.YijingHexagramSymbols).ToString());
     Assert.AreEqual(CJKUnifiedIdeographs.ToString(), UnicodeCategory(Categories.CJKUnifiedIdeographs).ToString());
     Assert.AreEqual(YiSyllables.ToString(), UnicodeCategory(Categories.YiSyllables).ToString());
     Assert.AreEqual(YiRadicals.ToString(), UnicodeCategory(Categories.YiRadicals).ToString());
     Assert.AreEqual(HangulSyllables.ToString(), UnicodeCategory(Categories.HangulSyllables).ToString());
     Assert.AreEqual(HighSurrogates.ToString(), UnicodeCategory(Categories.HighSurrogates).ToString());
     Assert.AreEqual(HighPrivateUseSurrogates.ToString(), UnicodeCategory(Categories.HighPrivateUseSurrogates).ToString());
     Assert.AreEqual(LowSurrogates.ToString(), UnicodeCategory(Categories.LowSurrogates).ToString());
     Assert.AreEqual(PrivateUseArea.ToString(), UnicodeCategory(Categories.PrivateUseArea).ToString());
     Assert.AreEqual(CJKCompatibilityIdeographs.ToString(), UnicodeCategory(Categories.CJKCompatibilityIdeographs).ToString());
     Assert.AreEqual(LettericPresentationForms.ToString(), UnicodeCategory(Categories.LettericPresentationForms).ToString());
     Assert.AreEqual(ArabicPresentationForms_A.ToString(), UnicodeCategory(Categories.ArabicPresentationForms_A).ToString());
     Assert.AreEqual(VariationSelectors.ToString(), UnicodeCategory(Categories.VariationSelectors).ToString());
     Assert.AreEqual(CombiningHalfMarks.ToString(), UnicodeCategory(Categories.CombiningHalfMarks).ToString());
     Assert.AreEqual(CJKCompatibilityForms.ToString(), UnicodeCategory(Categories.CJKCompatibilityForms).ToString());
     Assert.AreEqual(SmallFormVariants.ToString(), UnicodeCategory(Categories.SmallFormVariants).ToString());
     Assert.AreEqual(ArabicPresentationForms_B.ToString(), UnicodeCategory(Categories.ArabicPresentationForms_B).ToString());
     Assert.AreEqual(HalfwidthandFullwidthForms.ToString(), UnicodeCategory(Categories.HalfwidthandFullwidthForms).ToString());
     Assert.AreEqual(Specials.ToString(), UnicodeCategory(Categories.Specials).ToString());
 }
Пример #4
0
        /// <summary>
        /// 切换Tab
        /// </summary>
        /// <param name="tab"></param>
        private void SelectedTab(TabPage tab)
        {
            Text = "IoTClient Tool - " + tab.Name?.Trim();

            switch (tab.Name)
            {
            case "三菱_MC_Qna_3E":
                Text = "IoTClient Tool - 三菱MC Qna-3E";
                break;

            case "三菱_MC_A_1E":
                Text = "IoTClient Tool - 三菱MC A-1E";
                break;

            case "OmronFinsTcp":
                Text = "IoTClient Tool - 欧姆龙Fins";
                break;

            case "ModbusRtuOverTcp":
                Text = "IoTClient Tool - ModbusRtu Over Tcp [串口透传 即:用Tcp的方式发送Rtu格式报文]";
                break;

            case "ABCIP":
                Text = "IoTClient Tool - 罗克韦尔 Allen-Bradley CIP Beta";
                break;
            }

            SaveTabName(tab.Name);
            if (tab.Controls.Count <= 0)
            {
                switch (tab.Name)
                {
                case "ModbusTcp":
                    var modbusTcp = new ModbusTcpControl(false);
                    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 "ModbusRtuOverTcp":
                    var modbusTcpOverTcp = new ModbusTcpControl(true);
                    modbusTcpOverTcp.Dock = DockStyle.Fill;
                    tab.Controls.Add(modbusTcpOverTcp);
                    break;

                case "ModbusAscii":
                    var ModbusAscii = new ModbusAsciiControl();
                    ModbusAscii.Dock = DockStyle.Fill;
                    tab.Controls.Add(ModbusAscii);
                    break;

                case "西门子S7200Smart":
                    var siemens = new SiemensControl(SiemensVersion.S7_200Smart);
                    siemens.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemens);
                    break;

                case "西门子S7200":
                    var siemens200 = new SiemensControl(SiemensVersion.S7_200);
                    siemens200.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemens200);
                    break;

                case "西门子S7300":
                    var siemensS7_300 = new SiemensControl(SiemensVersion.S7_300);
                    siemensS7_300.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_300);
                    break;

                case "西门子S7400":
                    var siemensS7_400 = new SiemensControl(SiemensVersion.S7_400);
                    siemensS7_400.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_400);
                    break;

                case "西门子S71200":
                    var siemensS7_1200 = new SiemensControl(SiemensVersion.S7_1200);
                    siemensS7_1200.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_1200);
                    break;

                case "西门子S71500":
                    var siemensS7_1500 = new SiemensControl(SiemensVersion.S7_1500);
                    siemensS7_1500.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_1500);
                    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 "三菱_MC_Qna_3E":
                    var mitsubishiMC = new MitsubishiMCControl(MitsubishiVersion.Qna_3E);
                    mitsubishiMC.Dock = DockStyle.Fill;
                    tab.Controls.Add(mitsubishiMC);
                    break;

                case "三菱_MC_A_1E":
                    var mitsubishiA1E = new MitsubishiMCControl(MitsubishiVersion.A_1E);
                    mitsubishiA1E.Dock = DockStyle.Fill;
                    tab.Controls.Add(mitsubishiA1E);
                    break;

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

                case "ABCIP":
                    var allenBradley = new AllenBradleyControl();
                    allenBradley.Dock = DockStyle.Fill;
                    tab.Controls.Add(allenBradley);
                    break;

                case "MQTT":
                    var mqtt = new MQTTControl();
                    mqtt.Dock = DockStyle.Fill;
                    tab.Controls.Add(mqtt);
                    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;
                    //tab 切换会覆盖选中的端口
                    //modbusRtuControl?.UpdatePortNames();
                    break;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 切换Tab
        /// </summary>
        /// <param name="tab"></param>
        private void SelectedTab(TabPage tab)
        {
            Text = "IoTClient Tool - " + tab.Name?.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 "SiemensS7200Smart":
                    var siemens = new SiemensControl(SiemensVersion.S7_200Smart);
                    siemens.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemens);
                    break;

                case "SiemensS7200":
                    var siemens200 = new SiemensControl(SiemensVersion.S7_200);
                    siemens200.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemens200);
                    break;

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

                case "SiemensS7400":
                    var siemensS7_400 = new SiemensControl(SiemensVersion.S7_400);
                    siemensS7_400.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_400);
                    break;

                case "SiemensS71200":
                    var siemensS7_1200 = new SiemensControl(SiemensVersion.S7_1200);
                    siemensS7_1200.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_1200);
                    break;

                case "SiemensS71500":
                    var siemensS7_1500 = new SiemensControl(SiemensVersion.S7_1500);
                    siemensS7_1500.Dock = DockStyle.Fill;
                    tab.Controls.Add(siemensS7_1500);
                    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 "三菱_MC_Qna_3E":
                    var mitsubishiMC = new MitsubishiMCControl(MitsubishiVersion.Qna_3E);
                    mitsubishiMC.Dock = DockStyle.Fill;
                    tab.Controls.Add(mitsubishiMC);
                    break;

                case "三菱_MC_A_1E":
                    var mitsubishiA1E = new MitsubishiMCControl(MitsubishiVersion.A_1E);
                    mitsubishiA1E.Dock = DockStyle.Fill;
                    tab.Controls.Add(mitsubishiA1E);
                    break;

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

                case "MQTT":
                    var mqtt = new MQTTControl();
                    mqtt.Dock = DockStyle.Fill;
                    tab.Controls.Add(mqtt);
                    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;
                }
            }
        }