diff --git a/MahApps.Metro/Controls/Dialogs/DialogManager.cs b/MahApps.Metro/Controls/Dialogs/DialogManager.cs index 8fd63b039d..be37ba50e9 100644 --- a/MahApps.Metro/Controls/Dialogs/DialogManager.cs +++ b/MahApps.Metro/Controls/Dialogs/DialogManager.cs @@ -24,7 +24,7 @@ public static class DialogManager public static Task ShowInputAsync(this MetroWindow window, string title, string message, MetroDialogSettings settings = null) { window.Dispatcher.VerifyAccess(); - return window.ShowOverlayAsync().ContinueWith(z => + return HandleOverlayOnShow(settings, window).ContinueWith(z => { return (Task)window.Dispatcher.Invoke(new Func>(() => { @@ -70,7 +70,7 @@ public static Task ShowInputAsync(this MetroWindow window, string title, window.metroDialogContainer.Children.Remove(dialog); //remove the dialog from the container - return window.HideOverlayAsync(); + return HandleOverlayOnHide(settings, window); //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect }))).ContinueWith(y3 => y).Unwrap(); @@ -91,7 +91,7 @@ public static Task ShowInputAsync(this MetroWindow window, string title, public static Task ShowMessageAsync(this MetroWindow window, string title, string message, MessageDialogStyle style = MessageDialogStyle.Affirmative, MetroDialogSettings settings = null) { window.Dispatcher.VerifyAccess(); - return window.ShowOverlayAsync().ContinueWith(z => + return HandleOverlayOnShow(settings, window).ContinueWith(z => { return (Task)window.Dispatcher.Invoke(new Func>(() => { @@ -138,7 +138,7 @@ public static Task ShowMessageAsync(this MetroWindow window window.metroDialogContainer.Children.Remove(dialog); //remove the dialog from the container - return window.HideOverlayAsync(); + return HandleOverlayOnHide(settings, window); //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect }))).ContinueWith(y3 => y).Unwrap(); @@ -148,6 +148,7 @@ public static Task ShowMessageAsync(this MetroWindow window })); }).Unwrap(); } + /// /// Creates a ProgressDialog inside of the current window. /// @@ -160,7 +161,7 @@ public static Task ShowProgressAsync(this MetroWindow { window.Dispatcher.VerifyAccess(); - return window.ShowOverlayAsync().ContinueWith(z => + return HandleOverlayOnShow(settings, window).ContinueWith(z => { return ((Task)window.Dispatcher.Invoke(new Func>(() => { @@ -207,7 +208,7 @@ public static Task ShowProgressAsync(this MetroWindow window.metroDialogContainer.Children.Remove(dialog); //remove the dialog from the container - return window.HideOverlayAsync(); + return HandleOverlayOnHide(settings, window); //window.overlayBox.Visibility = System.Windows.Visibility.Hidden; //deactive the overlay effect })); }).Unwrap(); @@ -217,6 +218,15 @@ public static Task ShowProgressAsync(this MetroWindow }).Unwrap(); } + private static Task HandleOverlayOnHide(MetroDialogSettings settings, MetroWindow window) + { + return (settings == null || settings.UseAnimations ? window.HideOverlayAsync() : Task.Factory.StartNew(() => window.Dispatcher.Invoke(new Action(() => window.HideOverlay())))); + } + private static Task HandleOverlayOnShow(MetroDialogSettings settings, MetroWindow window) + { + return (settings == null || settings.UseAnimations ? window.ShowOverlayAsync() : Task.Factory.StartNew(() => window.Dispatcher.Invoke(new Action(() => window.ShowOverlay())))); + } + /// /// Adds a Metro Dialog instance to the specified window and makes it visible. /// diff --git a/MahApps.Metro/Controls/Dialogs/InputDialog.cs b/MahApps.Metro/Controls/Dialogs/InputDialog.cs index cd641ffdff..d9790adde6 100644 --- a/MahApps.Metro/Controls/Dialogs/InputDialog.cs +++ b/MahApps.Metro/Controls/Dialogs/InputDialog.cs @@ -104,6 +104,7 @@ private void Dialog_Loaded(object sender, RoutedEventArgs e) { case MetroDialogColorScheme.Accented: this.PART_NegativeButton.Style = this.FindResource("HighlightedSquareButtonStyle") as Style; + PART_TextBox.SetResourceReference(ForegroundProperty, "BlackColorBrush"); break; default: break; diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index 6fa182ddd6..0f1712bcd6 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -341,6 +341,18 @@ public bool IsOverlayVisible() { return overlayBox.Visibility == Visibility.Visible && overlayBox.Opacity >= 0.7; } + public void ShowOverlay() + { + overlayBox.Visibility = Visibility.Visible; + //overlayBox.Opacity = 0.7; + overlayBox.SetCurrentValue(Grid.OpacityProperty, 0.7); + } + public void HideOverlay() + { + //overlayBox.Opacity = 0.0; + overlayBox.SetCurrentValue(Grid.OpacityProperty, 0.0); + overlayBox.Visibility = System.Windows.Visibility.Hidden; + } /// /// Initializes a new instance of the MahApps.Metro.Controls.MetroWindow class. diff --git a/MahApps.Metro/Themes/Dialogs/InputDialog.xaml b/MahApps.Metro/Themes/Dialogs/InputDialog.xaml index fecce082d0..6698d6970d 100644 --- a/MahApps.Metro/Themes/Dialogs/InputDialog.xaml +++ b/MahApps.Metro/Themes/Dialogs/InputDialog.xaml @@ -19,7 +19,7 @@ TextWrapping="Wrap" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Dialogs:InputDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}" />