public void SetPercent(int percent) { if (!_toolStrip.InvokeRequired) { _toolStripPercent.Text = String.Format("%{0}", percent); } else { _toolStrip.Invoke(new MethodInvoker(() => SetPercent(percent))); } }
private static void SetTsStatus(string strText) { if (strText == null) { Debug.Assert(false); return; } if (m_tsResultsViewer == null) { Debug.Assert(false); return; } try { ToolStrip pParent = m_tsResultsViewer.Owner; if ((pParent != null) && pParent.InvokeRequired) { pParent.Invoke(new Priv_CfuSsd(CheckForUpdate.SetTsStatusDirect), new object[] { strText }); } else { CheckForUpdate.SetTsStatusDirect(strText); } } catch (Exception) { Debug.Assert(false); } }
private void timeoutTimerHandler(object source, ElapsedEventArgs e) { try { if (TimeoutTimer > 0) { TimeoutTimer -= 1; } else { ModuleTimeOut = true; } if (TimeoutTimer == 25) { DisplayData(MessageType.Info, "Module close to timing out."); } toolStrip1.Invoke(new EventHandler(delegate { barTimeOut.Value = TimeoutTimer; })); Input[6] = Convert.ToDouble(Math.Round(power.BatteryLifePercent * 100, 0)); lblValues[6].Invoke(new EventHandler(delegate { lblValues[6].Text = Convert.ToString(Input[6]) + " %"; })); } catch (Exception ex) { DisplayData(MessageType.Error, "Timeout timer: " + ex.Message); } }
void watcher_Changed(object sender, FileSystemEventArgs e) { //do some extra checking as this event can be fired multiple times (e.g. N++ file save does it) if (lastLoadingTimestamp != File.GetLastWriteTime(file)) { lastLoadingTimestamp = File.GetLastWriteTime(file); control.Invoke((Action)Load); } }
public static void Render(LogStatsDal dal, LiveViewOptions options, LayoutStyle layoutStyle) { Initialize(); List <DbccLogInfoItem> vlfs; try { vlfs = dal.ReadDbccLogInfo(null, true, options.ForceDbccLoginfo); } catch (Exception ex) { try { RenderException(options, ex); } catch { // Intentionally swallow any exceptions. } return; } using (Bitmap bitmap = CreateImage(vlfs, options, layoutStyle)) { if (options.DisplaySurface.InvokeRequired) { options.DisplaySurface.Invoke(new Action <LiveViewOptions, Bitmap>(SetImage), options, bitmap); } else { SetImage(options, bitmap); } } long totalLogSize = vlfs.Sum(v => v.FileSize); string displaySize = Utilities.FriendlySize(totalLogSize); DatabaseInfo dbInfo = dal.GetCurrentDatabaseInfo(); string statusMessage = $"Instance: {dal.InstanceName}; Database: {dal.DatabaseName}; Recovery model: {dbInfo.RecoveryModelDescription}; Log size: {displaySize}; VLFs: {vlfs.Count}; Wait: {dbInfo.LogReuseWaitDescription}; Last refresh: {DateTime.Now:HH:mm:ss}"; ToolStrip toolStrip = options.StatusLabel.GetCurrentParent(); if (toolStrip != null) { if (toolStrip.InvokeRequired) { toolStrip.Invoke(new Action <LiveViewOptions, string>(SetStatus), options, statusMessage); } else { SetStatus(options, statusMessage); } } }
private void InvokeSetEnable(ToolStrip strip, ToolStripItem btn, bool isEnabled) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { btn.Enabled = isEnabled; }); } else { btn.Enabled = isEnabled; } }
private void InvokeSetText(ToolStrip strip, ToolStripButton btn, string text) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { btn.Text = text; }); } else { btn.Text = text; } }
private void InvokeSetText(ToolStrip strip, ToolStripLabel lbl, string text) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { lbl.Text = text; }); } else { lbl.Text = text; } }
private void InvokeSetColorMode(ToolStrip strip, ToolStripLabel lbl, Color foreColor) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { lbl.ForeColor = foreColor; }); } else { lbl.ForeColor = foreColor; } }
private void InvokeSetVisibleState(ToolStrip strip, ToolStripItem item, bool isVisible) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { item.Visible = isVisible; }); } else { item.Visible = isVisible; } }
private void InvokeSetEnabledState(ToolStrip strip, ToolStripItem item, bool enabled) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { item.Enabled = enabled; }); } else { item.Enabled = enabled; } }
private void InvokeSetChecked(ToolStrip strip, ToolStripButton btn, bool isChecked) { if (strip.InvokeRequired) { strip.Invoke((MethodInvoker) delegate { btn.Checked = isChecked; }); } else { btn.Checked = isChecked; } }
public void SetStatusTextThreadSafe(ToolStrip control, string text) { if (control.InvokeRequired) { control.Invoke(new SetStatusTextThreadSafeDelegate(SetStatusTextThreadSafe), new object[] { control, text }); } else { statusBarStatus.Text = text; } }
void CleanToolstrip(ToolStrip ts) { if (ts.InvokeRequired) { ts.Invoke(new CleanToolstripDelegate(CleanToolStripFunction), ts); } else { CleanToolStripFunction(ts); } }
private void UpdateUI(RSSItem item) { ToolStrip parent = this.Parent as ToolStrip; if (parent != null && parent.InvokeRequired) { parent.Invoke(new UpdateUIDelegate(DirectUpdateUI), new object[] { item }); } else { this.DirectUpdateUI(item); } }
public void PrintTextInToolStripStatusLabel(ToolStrip toolstrip, string text) { if (toolstrip.InvokeRequired) { object[] args = new object[] { toolstrip, text }; PrintTextInToolStripStatusLabelDelegate pt = new PrintTextInToolStripStatusLabelDelegate(PrintTextInToolStripStatusLabel); toolstrip.Invoke(pt, args); } else { toolstrip.Text = text; } }
public static void InvokeIfRequired(Action action, ToolStrip toolStrip) { if (action == null || toolStrip == null) { throw new ArgumentNullException(); } if (toolStrip.InvokeRequired) { toolStrip.Invoke(action); } else { action(); } }
/// <summary> /// Enables and disables menus based on the bound MySQL instance's connection status. /// </summary> /// <param name="refreshing">Flag indicating if the instance is refreshing its status.</param> public void Update(bool refreshing) { ToolStrip menu = InstanceMenuItem.GetCurrentParent(); if (menu == null) { return; } if (menu.InvokeRequired) { menu.Invoke(new MethodInvoker(() => Update(refreshing))); } else { InstanceMenuItem.Text = BoundInstance.HostIdentifier + (refreshing ? Resources.RefreshingStatusText : " - " + BoundInstance.ConnectionStatusText); switch (BoundInstance.ConnectionStatus) { case MySqlWorkbenchConnection.ConnectionStatusType.AcceptingConnections: InstanceMenuItem.Image = Resources.NotifierIconRunning; break; case MySqlWorkbenchConnection.ConnectionStatusType.RefusingConnections: InstanceMenuItem.Image = Resources.NotifierIconStopped; break; case MySqlWorkbenchConnection.ConnectionStatusType.Unknown: InstanceMenuItem.Image = Resources.NotifierIcon; break; } if (SqlEditorMenuItem != null) { SqlEditorMenuItem.Enabled = MySqlWorkbench.AllowsExternalConnectionsManagement && BoundInstance.WorkbenchConnection != null; } if (ConfigureMenuItem != null) { ConfigureMenuItem.Enabled = BoundInstance.WorkbenchServer != null; } } }
public static void MenuSetText(ToolStripTextBox item, string value) { ToolStrip par = item.GetCurrentParent(); if (par.InvokeRequired) { MethodInvoker delcall = () => { MenuSetText(item, value); }; try { par.Invoke(delcall); } catch { } } else { item.Text = value; } }
public static void MenuSetCheckedState(ToolStripMenuItem item, bool check) { ToolStrip par = item.Owner; // GetCurrentParent(); if (par.InvokeRequired) { MethodInvoker delcall = () => { MenuSetCheckedState(item, check); }; try { par.Invoke(delcall); } catch (Exception ex) { ex.ToDummy(); } } else { item.Checked = check; } }
public static void MenuSetState(ToolStripMenuItem item, bool enabled) { ToolStrip par = item.Owner;; if (par.InvokeRequired) { MethodInvoker delcall = () => { MenuSetState(item, enabled); }; try { par.Invoke(delcall); } catch (Exception ex) { ex.ToDummy(); } } else { item.Enabled = enabled; } }
public static void invokeOnThread(this ToolStrip toolStrip, Action codeToInvoke) { try { if (toolStrip.InvokeRequired) { toolStrip.Invoke(new EventHandler((sender, e) => { invokeThread(codeToInvoke); })); } else { codeToInvoke(); } } catch (Exception ex) { ex.log("[in invokeOnThread]"); } }
public void SetStatusProgressThreadSafe(ToolStrip control, string field, int value) { if (control.InvokeRequired) { control.Invoke(new SetStatusProgressThreadSafeDelegate(SetStatusProgressThreadSafe), new object[] { control, field, value }); } else { switch (field) { case "Value": statusBarProgress.Value = value; break; case "Maximum": statusBarProgress.Maximum = value; break; case "Visible": statusBarProgress.Visible = Convert.ToBoolean(value); break; } } }