public static void ShowSuccess(FrameworkElement owner, string text) { if (owner == null) { MessageBox.Show(text, "Готово!", MessageBoxButton.OK, MessageBoxImage.Information); } else { Window window = (Window)owner.GetRootElement(); MessageBox.Show(window, text, "Готово!", MessageBoxButton.OK, MessageBoxImage.Information); } }
public static void ShowError(FrameworkElement owner, Exception exception, string formatMessage = null, params object[] args) { Log.Error(exception, formatMessage, args); StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(formatMessage)) sb.AppendFormatLine(formatMessage, args); if (exception != null) sb.Append(exception); if (owner == null) { MessageBox.Show(sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } else { Window window = (Window)owner.GetRootElement(); MessageBox.Show(window, sb.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } }