private void UpdateInfo(String msg, UTIL.InfoType iType = UTIL.InfoType.message) { if (updateInfo != null) { updateInfo(msg, iType); } }
private void UpdateInfo(string msg = "", UTIL.InfoType iType = UTIL.InfoType.message, bool async = false) { if (Dispatcher.FromThread(Thread.CurrentThread) == null) { if (async) { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => UpdateInfo(msg, iType, async))); return; } else { Application.Current.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => UpdateInfo(msg, iType, async))); return; } } // Update UI is allowed here switch (iType) { case UTIL.InfoType.message: statusBar.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x7A, 0xCC)); break; case UTIL.InfoType.alert: statusBar.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xCA, 0x51, 0x00)); break; case UTIL.InfoType.error: statusBar.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00)); break; } statusInfoTextBlock.Text = msg; }
protected void UpdateInfo(string msg = "", UTIL.InfoType iType = UTIL.InfoType.message, bool async = false) { updateInfo?.Invoke(msg, iType, async); }
private void UpdateInfoCallback(string msg, UTIL.InfoType iType) { UpdateInfo(msg, iType, false); }
public static void UpdateInfo(StatusBar sb, System.Windows.Controls.TextBlock tb, string msg, UTIL.InfoType iType = UTIL.InfoType.message, bool async = false) { if (System.Windows.Threading.Dispatcher.FromThread(System.Threading.Thread.CurrentThread) == null) { if (async) { System.Windows.Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => UpdateInfo(sb, tb, msg, iType, async))); } else { System.Windows.Application.Current.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => UpdateInfo(sb, tb, msg, iType, async))); } return; } switch (iType) { case UTIL.InfoType.message: sb.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x7A, 0xCC)); break; case UTIL.InfoType.alert: sb.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xCA, 0x51, 0x00)); break; case UTIL.InfoType.error: sb.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00)); break; } tb.Text = msg; return; }