コード例 #1
0
ファイル: ConnectLogForm.cs プロジェクト: swcy225/laser
 void ApplyConfig()
 {
     if (currentWrapper == ComWrapper.WrapperType.UsbSerial && CBPort.Text != null && CBSpeed.SelectedItem != null)
     {
         Core.Configure(currentWrapper, CBPort.Text, (int)CBSpeed.SelectedItem);
     }
     else if (currentWrapper == ComWrapper.WrapperType.Telnet || currentWrapper == ComWrapper.WrapperType.LaserWebESP8266)
     {
         Core.Configure(currentWrapper, (string)TxtAddress.Text);
     }
     else if (currentWrapper == ComWrapper.WrapperType.Emulator)
     {
         Core.Configure(currentWrapper);
     }
 }
コード例 #2
0
        private void UpdateConf()
        {
            tableLayoutPanel4.SuspendLayout();
            CBPort.Visible      = CBSpeed.Visible = LblComPort.Visible = LblBaudRate.Visible = (currentWrapper == ComWrapper.WrapperType.UsbSerial);
            TxtAddress.Visible  = LblAddress.Visible = (currentWrapper == ComWrapper.WrapperType.Telnet || currentWrapper == ComWrapper.WrapperType.LaserWebESP8266);
            LblAddress.Text     = (currentWrapper == ComWrapper.WrapperType.Telnet ? "IP:PORT" : "Socket URL");
            TxtEmulator.Visible = LblEmulator.Visible = (currentWrapper == ComWrapper.WrapperType.Emulator);
            tableLayoutPanel4.ResumeLayout();

            if (currentWrapper == ComWrapper.WrapperType.UsbSerial && CBPort.SelectedItem != null && CBSpeed.SelectedItem != null)
            {
                Core.Configure(currentWrapper, (string)CBPort.SelectedItem, (int)CBSpeed.SelectedItem);
            }
            else if (currentWrapper == ComWrapper.WrapperType.Telnet || currentWrapper == ComWrapper.WrapperType.LaserWebESP8266)
            {
                Core.Configure(currentWrapper, (string)TxtAddress.Text);
            }
            else if (currentWrapper == ComWrapper.WrapperType.Emulator)
            {
                Core.Configure(currentWrapper);
            }

            if (CBSpeed.SelectedItem != null)
            {
                Settings.SetObject("Serial Speed", CBSpeed.SelectedItem);
            }

            if (TxtAddress.Text != "")
            {
                if (currentWrapper == ComWrapper.WrapperType.Telnet)
                {
                    Settings.SetObject("Telnet Address", TxtAddress.Text);
                }
                else if (currentWrapper == ComWrapper.WrapperType.LaserWebESP8266)
                {
                    Settings.SetObject("Websocket URL", TxtAddress.Text);
                }
            }

            Settings.Save();
        }