private void StatusChange(WorkerStatus Status, string stMessage) { WorkerStatusEventArgs e = new WorkerStatusEventArgs(); e.Status = Status; e.Message = stMessage; CurrentStatus = Status; if (StatusChanged != null) { StatusChanged(this, e); } }
void mw_StatusChanged(object sender, WorkerStatusEventArgs e) { Invoke((MethodInvoker) delegate { lvLog.Items.Add(e.Message); Color c = Color.Brown; if (e.Status == WorkerStatus.Start) { pbConnecting.Image = Properties.Resources.connecting; DisableAllButtons(); } if ((e.Status == WorkerStatus.FatalError) || (e.Status == WorkerStatus.CompleteAll)) { pbConnecting.Image = Properties.Resources.riseupvpn_64x64; EnableAllButtons(); } switch (e.Status) { case WorkerStatus.Start: c = Color.LightSteelBlue; break; case WorkerStatus.Process: c = Color.DarkGray; break; case WorkerStatus.Complete: c = Color.MediumSeaGreen; break; case WorkerStatus.CompleteAll: c = Color.LimeGreen; break; case WorkerStatus.NotComplete: c = Color.Yellow; break; case WorkerStatus.FatalError: c = Color.Red; break; case WorkerStatus.Wait: c = Color.White; break; } lvLog.Items[lvLog.Items.Count - 1].ForeColor = c; lvLog.TopItem = lvLog.Items[lvLog.Items.Count - 1]; }); }