public static void ShowProgress(string title, string message, bool indeterminate, Action<BackgroundWorker, object> workerMethod, object parameter = null) { App.Instance.Dispatcher.Invoke(() => { var window = new MessageWindow(); window.Title = title; window.lblText.Text = message; window._worker = new BackgroundWorker(); window._worker.WorkerReportsProgress = true; window._worker.WorkerSupportsCancellation = false; window._worker.DoWork += (o, e) => workerMethod(window._worker, parameter); if (!indeterminate) { window._worker.ProgressChanged += new ProgressChangedEventHandler(window.Worker_ProgressChanged); } else { window.progress.IsIndeterminate = true; } window._worker.RunWorkerCompleted += (sender, args) => window.Close(); window.progressPanel.Visibility = Visibility.Visible; window.buttonsPanel.Visibility = Visibility.Collapsed; App.Instance.MainModel.ShowDialog(window); }); }
public static MessageBoxResult Show(string title, string message, MessageBoxButton buttons, Brush titleColor = null) { var window = new MessageWindow(); window.Title = title; window.lblText.Text = message; if (titleColor != null) window.Background = titleColor; window.SetButtons(buttons); App.Instance.MainModel.ShowDialog(window); return window._result; }
public static void ShowLink(bool isError, string title, string message, string url, string linkText = null) { App.Instance.Dispatcher.Invoke(() => { var window = new MessageWindow(); window.Title = title; window.lblText.Text = message; if (isError) window.Background = Brushes.Tomato; if (string.IsNullOrWhiteSpace(linkText)) linkText = url; window.linkPanel.Visibility = Visibility.Visible; window.hyperlink.Inlines.Add(linkText); window.hyperlink.NavigateUri = new Uri(url); window.hyperlink.RequestNavigate += (s, e) => { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true; }; window.SetButtons(MessageBoxButton.OK); App.Instance.MainModel.ShowDialog(window); }); }