public static bool?ShowModal(DependencyObject sender, string Caption, string Title = "", bool CancelButton = false, bool YesNoButtons = false) { bool?result = null; WPRMsgBox messageBox = new() { Title = Title, Caption = Caption, CancelButtonVisible = CancelButton, YesNoButtonsVisible = YesNoButtons }; Window owner = sender is Window w ? w : sender.FindVisualParent <Window>(); WPRDialogPanel panel = FindDialogPanel(owner); Window dlg = new() { WindowStartupLocation = WindowStartupLocation.CenterOwner, Owner = owner, Content = messageBox, Style = (Style)Application.Current.Resources["WPRModalWindow"] }; messageBox.DialogResult += B => { result = B; dlg.Close(); }; panel?.Show(null, true); dlg.ShowDialog(); panel?.Hide(); return(result); } #endregion #region Information /// <summary>Показать информационное окно</summary> public static void Information(DependencyObject sender, string Caption, Action Callback = null)
private static void Show(DependencyObject sender, string Caption, string Title, Action <bool?> Callback, bool CancelButton, bool YesNoButtons) { // Ищем панель WPRDialogPanel panel = FindDialogPanel(sender); WPRMsgBox messageBox = new() { Title = Title, Caption = Caption, CancelButtonVisible = CancelButton, YesNoButtonsVisible = YesNoButtons }; // При клике по кнопке мессаджа закрыть окно и вернуть прозрачность как была messageBox.DialogResult += (b) => { panel.Hide(); Callback?.Invoke(b); }; panel.Show(messageBox, true); }
public static void InputText(DependencyObject sender, string Title, Action <bool, string> Callback, string DefaultValue, Predicate <string> ValidationRule, string ValidationErrorMessage = "Неверное значение") { // Ищем панель WPRDialogPanel panel = FindDialogPanel(sender); WPRInputBox inputBox = new() { Title = Title, TextValue = DefaultValue, ValidationPredicate = ValidationRule, ErrorMessage = ValidationErrorMessage }; // При клике по кнопке мессаджа закрыть окно и вернуть прозрачность как была inputBox.DialogResult += (b) => { panel.Hide(); Callback?.Invoke(b == true, inputBox.TextValue); }; panel.Show(inputBox, true); } #endregion }