private void SetButtonStatus() { if (_arduinoComm.Connected) { ConnectStateLbl.Text = "Connected"; ConnectStateLbl.ForeColor = Color.Green; ConnectBtn.Text = "Disconnect"; } else { ConnectStateLbl.Text = "Disconnected"; ConnectStateLbl.ForeColor = Color.Black; ConnectBtn.Text = "Connect"; } DetectBtn.Enabled = !_arduinoComm.Connected; ConnectBtn.Enabled = ComPortCb.SelectedItem != null; ConnectBtn.Refresh(); UpdateSketchBtn.Enabled = ComPortCb.SelectedItem != null /*&& _arduinoComm.Connected*/ && !_writeActive && !_readActive; UpdateSketchBtn.Refresh(); WriteTcrtBtn.Enabled = _arduinoComm.Connected && !_readActive; WriteTcrtBtn.Refresh(); ReadTcrtBtn.Enabled = _arduinoComm.Connected && !_writeActive; ReadTcrtBtn.Refresh(); }
private void MainForm_Load(object sender, EventArgs e) { if (isDataExist == true) { ConnectBtn.PerformClick(); } }
void StopGame() { HostBtn.Disabled = false; NameEdit.Editable = true; HostEdit.Editable = true; ConnectBtn.Show(); DisconnectBtn.Hide(); Game.Stop(); }
private void DefaultBtn_Click(object sender, EventArgs e) { var serverInfo = ConfigurationManager.GetSection("mongoServerInfo") as System.Collections.Specialized.NameValueCollection; DbAddressTxt.Text = serverInfo["ServerAddr"].ToString(); DbNameTxt.Text = serverInfo["DBName"].ToString(); CollectionNameTxt.Text = serverInfo["CollectionName"].ToString(); PortTxt.Text = serverInfo["Port"].ToString(); ConnectBtn.Focus(); }
private void Disconnect() { _logging.Info(MODUL_NAME, "Disconnect", $"Disconnect from {_arduinoComm.CurrentComPortName}"); _arduinoComm.DeInit(); ConnectBtn.Text = "Connect"; ConnectBtn.ForeColor = Color.Black; ConnectBtn.Refresh(); SetButtonStatus(); }
private async void ConnectBtn_Click(object sender, EventArgs e) { if (_selectedComPort == null) { return; } _logging.Info(MODUL_NAME, "ConnectBtn_Click", $"Connecting to {_arduinoComm.CurrentParameter}"); FlasherVersionTb.Text = ""; TapecartVersionTb.Text = ""; if (_arduinoComm.Connected) { _arduinoComm.DeInit(); ConnectBtn.Text = "Connect"; ConnectBtn.ForeColor = Color.Black; SetButtonStatus(); DetectBtn.Enabled = true; ConnectBtn.Enabled = true; return; } DetectBtn.Enabled = false; ConnectBtn.Enabled = false; string btnText = ConnectBtn.Text; ConnectBtn.Text = "Connecting..."; ConnectStateLbl.Text = ""; ConnectBtn.Refresh(); bool success = false; await Task.Run(() => { success = Connect(); }); if (success) { _logging.Info(MODUL_NAME, "ConnectBtn_Click", $"Connected"); } else { _arduinoComm.DeInit(); } SetButtonStatus(); SketchVersion latest = _sketchList.GetLatestVersion(_currentSketchVersion); if (latest != null) { AskForSketchUpdate(latest); } }
private void UpdateButtonStatus(bool enabled, string text) { if (ConnectBtn.InvokeRequired) { ConnectBtn.Invoke(new Action <bool, string>(UpdateButtonStatus), enabled, text); } else { ConnectBtn.Enabled = enabled; ConnectBtn.Text = text; } }
void ReleaseDesignerOutlets() { if (ConnectBtn != null) { ConnectBtn.Dispose(); ConnectBtn = null; } if (DebugLbl != null) { DebugLbl.Dispose(); DebugLbl = null; } if (ScreenBtn != null) { ScreenBtn.Dispose(); ScreenBtn = null; } if (ScreenshotView != null) { ScreenshotView.Dispose(); ScreenshotView = null; } if (ScrenShotImageView != null) { ScrenShotImageView.Dispose(); ScrenShotImageView = null; } if (URL_textfield != null) { URL_textfield.Dispose(); URL_textfield = null; } if (VideoContentView != null) { VideoContentView.Dispose(); VideoContentView = null; } }
/// <summary> /// Handles the Click event of the ConnectBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void ConnectBtn_Click(object sender, EventArgs e) { var msg = ru ? "Соединиться" : "Connect"; if (Client.IsConnected) { Client.Disconnect(); LedConnect.ImageIndex = 0; ConnectBtn.Invk(t => t.Text = msg); return; } IPaddress = SrvName.Text; try { Port = decimal.ToInt32(PortNum.Value); } catch (Exception ex) { Port = Globals.Port; } Client.Connect(IPaddress, Port); if (Client.IsConnected) { LedConnect.ImageIndex = 1; ConnectBtn.Invk(t => t.Text = ru ? "Отсоединиться" : "Disconnect"); Client.SendInfo("I'm test client for MainC"); Client.AskServerState(); msg += ru ? " - соединение успешно" : " is connected"; Console.WriteLine(msg); } else { msg += " не доступен"; Console.WriteLine(msg); MessageBox.Show(msg, ru ? "Предупреждение" : "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }