private static void RunMethod(Action action, string successfulMessage) { try { action(); if (!string.IsNullOrEmpty(successfulMessage)) { ShowMessageBox.Information(successfulMessage); } } catch (Exception exception) { ShowMessageBox.Error(exception.Message); } }
public static void TrueDialogResult <TWindow>(TWindow window) where TWindow : Window, IWindowWithChecking { var errors = window.GetErrors().ToArray(); if (errors.Any()) { ShowMessageBox.Error(string.Join("\n", errors)); return; } SafeRunMethod.WithoutReturn(() => { window.ActionBeforeTrueDialogResultClose(); window.DialogResult = true; window.Close(); }); }
public static void TrueDialogResult <TWindow>(TWindow window) where TWindow : Window, IProxyWindow { if (window.IsReadOnly) { window.Close(); return; } var errors = window.GetErrors().ToArray(); if (errors.Any()) { ShowMessageBox.Error(string.Join("\n", errors)); } else { window.WriteProxy(); window.DialogResult = true; window.Close(); } }