private void SetStatusFilmATraiter(string message) { try { if (_statusLabel.GetCurrentParent().InvokeRequired) { if (!_statusLabel.IsDisposed) { _statusLabel.GetCurrentParent().Invoke(new SetStatusDelegate(SetStatusFilmATraiter), new object[] { message }); } } else { if (message?.Length > 0) { _statusLabel.Visible = true; _statusLabel.Text = message; } else { _statusLabel.Visible = false; } } } catch (Exception) { } }
/// <summary> /// Set the status text label, if it's given. /// </summary> public void UpdateStatus(string text) { if (progressLabel != null) { progressLabel.GetCurrentParent().Invoke((MethodInvoker) delegate { progressLabel.Text = text; }); lastLazyStatus = DateTime.Now; } }
public static void SetLabelText(ToolStripStatusLabel l, string text) { if (l.GetCurrentParent().InvokeRequired) { _ = l.GetCurrentParent().Invoke(new MethodInvoker(delegate { l.Text = text; })); } else { l.Text = text; } }
protected virtual void RunOnUiThread(Delegate method) { if (toolStripStatusLabel.GetCurrentParent().InvokeRequired) { toolStripStatusLabel.GetCurrentParent().Invoke(method); } else { method(); } }
public static void UpdateToolStripStatus(ToolStripStatusLabel label, string value) { if (label.GetCurrentParent().InvokeRequired) { var d = new StatusDelegate(UpdateToolStripStatus); label.GetCurrentParent().Invoke(d, label, value); } else { if (value.Length > 50) { value = "..." + value.Substring(value.Length - 50); } label.Text = value; } }
public static void InitializeStatus(ToolStripStatusLabel toolStripStatusLabel1) { thistoolStripStatusLabel1 = toolStripStatusLabel1; var t = toolStripStatusLabel1.GetCurrentParent(); t.LayoutStyle = ToolStripLayoutStyle.Flow; }
public static void UpdateToolStripStatus(ToolStripStatusLabel _Label, string _Value) { if (_Label.GetCurrentParent().InvokeRequired) { StatusDelegate d = new StatusDelegate(UpdateToolStripStatus); _Label.GetCurrentParent().Invoke(d, new object[] { _Label, _Value }); } else { if (_Value.Length > 50) { _Value = "..." + _Value.Substring(_Value.Length - 50); } _Label.Text = _Value; } }
private void UpdateConnectStatus(bool bConnectOK) { Action action = () => { if (bConnectOK) { toolStripBarCode.BackColor = Color.Green; } else { toolStripBarCode.BackColor = Color.Yellow; } }; toolStripBarCode.GetCurrentParent().Invoke(action); }
public static void Status(string msg, Color?color = null, params object[] args) { var parent = thistoolStripStatusLabel1?.GetCurrentParent(); // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (parent == null) { return; } if (parent.InvokeRequired) { parent.Invoke(new StringArgReturningVoidDelegate(Status), new object[] { msg, color, args }); } else { if (msg.Contains("Error")) { color = Color.Red; } if (thistoolStripStatusLabel1 == null) { MessageBox.Show("Please add My.InitStatus(toolStripStatusLabel1) in your Form_Load event."); return; } if (args.Length > 0) { msg = String.Format(msg, args); } if (thistoolStripStatusLabel1.BackColor == SystemColors.Control || color == SystemColors.Control) { thistoolStripStatusLabel1.Text = msg; thistoolStripStatusLabel1.BackColor = color ?? SystemColors.Control; } if (msg.Length > 0 && !msg.StartsWith(" ")) { My.Log(msg); } } }
private static void SetStatusLabel(String status) { StatusLabel.Text = status + "..."; StatusLabel.GetCurrentParent().Refresh(); }