public static void SetStatus(string text, Colors color) { try { Bitmap theColor = new Bitmap(P2PVpn.Properties.Resources.Stop_red2); if (color == Colors.Green) { theColor = P2PVpn.Properties.Resources.Accept2; } else if (color == Colors.Red) { theColor = P2PVpn.Properties.Resources.Stop_red2; } else if (color == Colors.Yellow) { theColor = P2PVpn.Properties.Resources.Prohibit2; } if (_statusBar.InvokeRequired) { _statusBar.BeginInvoke(new Action(() => _lblStatusText.Text = text)); _statusBar.BeginInvoke(new Action(() => _lblStatusText.Image = theColor)); } else { _lblStatusText.Text = text; _lblStatusText.Image = theColor; } } catch (ObjectDisposedException ex) { } }
private void fillTrainingList() { if (statusBar.InvokeRequired) { statusBar.BeginInvoke(new Action(fillTrainingList)); } else { tdbMyTrainings.DropDownItems.Clear(); //var myTrainings = ServicesManager.GetService<IMyTrainingFactory>().GetStartedTraining(SessionData); //var myTrainings = MyTraining.GetStartedTrainings(SessionData.ProfileId); //foreach (var myTraining in myTrainings) //{ // ToolStripMenuItem toolStripMenuItem3 = new ToolStripMenuItem(myTraining.Name); // toolStripMenuItem3.Tag = myTraining; // toolStripMenuItem3.Click += new EventHandler(toolStripMenuItem3_Click); // if (MyTrainingId.HasValue) // { // toolStripMenuItem3.Checked = myTraining.Id == MyTrainingId.Value; // } // tdbMyTrainings.DropDownItems.Add(toolStripMenuItem3); //} //TODO:Must be implemented } }
public static void SetControlText(this StatusStrip ctrl, ToolStripStatusLabel lbl, string text, Color color) { if (ctrl.InvokeRequired) { ctrl.BeginInvoke(new Action(() => lbl.Text = text)); ctrl.BeginInvoke(new Action(() => lbl.ForeColor = color)); } else { lbl.Text = text; lbl.ForeColor = color; } }
void ILogHnd.OnLog(string userId, ILogInfo info) { try { // Threadsicherer Aufruf der Listbox Add Methode if (_stp.InvokeRequired) { ILogHnd logHnd = this; DGHnd dg = new DGHnd(logHnd.OnLog); _stp.BeginInvoke(dg, new object[] { userId, info }); } else { switch (info.LogType) { case EnumLogType.Error: { string descr = string.Format("Err: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message); Debug.Fail("WinFormStatusStripLogHnd: " + descr); statusText.Text = "descr"; } break; case EnumLogType.Message: if (ShowMessage) { string descr = string.Format("Msg: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message); Debug.WriteLine("WinFormStatusStripLogHnd: " + descr); statusText.Text = descr; } break; case EnumLogType.Status: if (ShowStatus) { string descr = string.Format("Sta: user= {0}: {1} / {2}", info.LogDate, userId, info.Message); Debug.WriteLine("WinFormStatusStripLogHnd: " + descr); statusText.Text = descr; } break; default: { string descr = string.Format("Unbekannter Logtyp: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message); statusText.Text = descr; Debug.Fail("WinFormStatusStripLogHnd: " + descr); } break; } } } catch (Exception ex) { SelfDeregisterILogHnd(); } }
private void StatusPrompt(string text, Color color, int displayTime = -1) { if (StatusStrip.InvokeRequired) { var del = new Action(() => StatusPrompt(text, color)); StatusStrip.BeginInvoke(del); } else { statusSlider.QueueMessage(text, color, displayTime); } }
internal static void ChangeBackGroundColor(ToolStripStatusLabel lbl, StatusStrip trip, Color color) { if (trip.InvokeRequired) { trip.BeginInvoke(new Action(() => { lbl.BackColor = color; })); } else { lbl.BackColor = color; } }
public static void GetuserInfo(StatusStrip st, ToolStripStatusLabel l1, ToolStripStatusLabel lt, ToolStripStatusLabel l2, ToolStripStatusLabel lt2) { DataTable dt = Common.GetEnteruserInfo(ClsTable.Archid); if (dt == null || dt.Rows.Count <= 0) { return; } try { DataTable dt1 = dt.Select("OneTwoTag=1").CopyToDataTable(); if (dt1 != null || dt1.Rows.Count > 0) { string user1 = ""; string time1 = ""; st.BeginInvoke(new Action(() => { user1 = dt1.Rows[0][0].ToString(); time1 = dt1.Rows[0][1].ToString(); l1.Text = string.Format("一录:{0}", user1); lt.Text = string.Format("一录时间:{0}", time1); })); } DataTable dt2 = dt.Select("OneTwoTag=2").CopyToDataTable(); if (dt2 != null || dt2.Rows.Count > 0) { string user2 = ""; string time2 = ""; st.BeginInvoke(new Action(() => { user2 = dt2.Rows[0][0].ToString(); time2 = dt2.Rows[0][1].ToString(); l2.Text = string.Format("二录:{0}", user2); lt2.Text = string.Format("二录时间:{0}", time2); })); } } catch { } }
internal static void ChangeText(ToolStripStatusLabel lbl, StatusStrip trip, string text, Color forcecolor) { if (trip.InvokeRequired) { trip.BeginInvoke(new Action(() => { lbl.Text = text; lbl.ForeColor = forcecolor; })); } else { lbl.Text = text; lbl.ForeColor = forcecolor; } }
public void MostrarMensaje(object objeto) { StatusStrip msj = (StatusStrip)objeto; while (true) { if (msj.InvokeRequired) { msj.BeginInvoke((MethodInvoker) delegate() { msj.Text = listaMesnajes[mensajeRandom().Next(0, 4)]; }); } Thread.Sleep(3000); } }
private void CarmbiarMensaje(object obj) { //ToolStripLabel modificarLabel = (ToolStripLabel)obj; StatusStrip modificarStrip = (StatusStrip)obj; int contador = 0; while (true) { //if (contador > 4) //contador = 0; /*((MethodInvoker)delegate () * { * modificarLabel.Text = this.MostrarMensaje(); * });*/ if (modificarStrip.InvokeRequired) { modificarStrip.BeginInvoke((MethodInvoker) delegate() { //this.toolStripStatusLabel1.Text = mensajes.ToString(); this.MostrarMensaje(contador); //this.MostrarMensaje(); //this.toolStripStatusLabel1.Text = this.MostrarMensaje(); //modificarStrip.Items.Add(this.MostrarMensaje()); //modificarStrip.Items.Add(mensajes.ToString()); //modificarStrip.Text= this.MostrarMensaje(); }); } else { //modificarStrip.Text = this.MostrarMensaje(); this.MostrarMensaje(contador); //this.MostrarMensaje(); } contador++; if (contador == 6) { contador = 1; } Thread.Sleep(5000); } }
protected override void Append(log4net.Core.LoggingEvent loggingEvent) { if (_status_strip != null && _status_label != null) { Image i = (loggingEvent.Level > log4net.Core.Level.Info) ? Properties.Resources.error : Properties.Resources.ok; if (_status_strip.InvokeRequired) { _status_strip.BeginInvoke(new MethodInvoker(delegate { _status_label.Text = loggingEvent.RenderedMessage; _status_label.Image = i; })); } else { _status_label.Text = loggingEvent.RenderedMessage; _status_label.Image = i; } } }
public void setToolStripText(StatusStrip in_me, ToolStripStatusLabel set_me, String to_me) { if(in_me.InvokeRequired) { in_me.BeginInvoke(new setToolStripTextDelegate(setToolStripText), new Object[] { in_me, set_me, to_me}); } else { lock(in_me) { set_me.Text = to_me; } } }
public void setToolStripImage(StatusStrip in_me, ToolStripStatusLabel set_me, System.Drawing.Image to_me) { if(in_me.InvokeRequired) { in_me.BeginInvoke(new setToolStripImageDelegate(setToolStripImage), new Object[] { in_me, set_me, to_me}); } else { lock(in_me) { set_me.Image = to_me; } } }