/// <summary> /// returns a <see cref="BitmapImage"/> which is provided by a viable input <see cref="BlurryDialogIcon"/> value /// </summary> /// <param name="icon">the demanded icon identifier of enum type <see cref="BlurryDialogIcon"/></param> /// <returns> /// <see cref="BitmapImage"/> corresponding to an input identifier of type <see cref="BlurryDialogIcon"/> /// returns null if no icon is demanded /// </returns> internal static BitmapImage GetDialogImage(this BlurryDialogIcon icon) { switch (icon) { case BlurryDialogIcon.None: return(null); case BlurryDialogIcon.Question: return(RelativeQuestionIcon.GetImageSource(Dialog)); case BlurryDialogIcon.Information: return(RelativeInformationIcon.GetImageSource(Dialog)); case BlurryDialogIcon.Warning: return(RelativeWarningIcon.GetImageSource(Dialog)); case BlurryDialogIcon.Error: return(RelativeErrorIcon.GetImageSource(Dialog)); default: throw new ArgumentOutOfRangeException(nameof(icon), icon, null); } }
/// <summary> /// Displays a message box in front of the specified window. The message box displays /// a message, title bar caption, button, and icon; and returns a result. /// </summary> /// <param name="owner">A <see cref="Window"/> that represents the owner window of the message box.</param> /// <param name="messageBoxText">A <see cref="string"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="string"/> that specifies the title bar caption to display.</param> /// <param name="button">A <see cref="BlurryDialogButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="BlurryDialogIcon"/> value that specifies the icon to display.</param> /// <param name="strength"> Determines the opacity of the window which is set to 0.75 by default and may not exceed 1</param> /// <returns>A <see cref="BlurryDialogResult"/> value that specifies which message box button is clicked by the user.</returns> public static BlurryDialogResult Show(Window owner, string messageBoxText, string caption, BlurryDialogButton button, BlurryDialogIcon icon, double?strength = null) { var result = BlurryDialogResult.None; var dialog = new BlurryDialogWindow { Title = caption, DialogIcon = icon, DialogMessage = messageBoxText, Button = button, Owner = owner, Strength = strength ?? ColorHelper.GetStrength(owner) }; dialog.ResultAquired += (sender, args) => { dialog.Close(); result = args.Result; }; dialog.ShowDialog(); return(result); }
/// <summary> /// Displays a message box in front of the specified window. The message box displays /// a message, title bar caption, button, and icon; and returns a result. /// </summary> /// <param name="owner">A <see cref="Window"/> that represents the owner window of the message box.</param> /// <param name="messageBoxText">A <see cref="string"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="string"/> that specifies the title bar caption to display.</param> /// <param name="button">A <see cref="BlurryDialogButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="BlurryDialogIcon"/> value that specifies the icon to display.</param> /// <param name="strength"> Determines the opacity of the window which is set to 0.75 by default and may not exceed 1</param> /// <returns>A <see cref="BlurryDialogResult"/> value that specifies which message box button is clicked by the user.</returns> public static BlurryDialogResult Show(Window owner, string messageBoxText, string caption, BlurryDialogButton button, BlurryDialogIcon icon, double strength = Strength) { var result = BlurryDialogResult.None; var dialog = new BlurBehindDialogWindow { Title = caption, DialogIcon = icon, DialogMessage = messageBoxText, Button = button, Owner = owner, Strength = strength, BlurDuration = BlurDuration, UnblurDuration = UnblurDuration, BlurRadius = BlurRadius }; dialog.ResultAquired += (sender, args) => { dialog.Close(); result = args.Result; }; dialog.ShowDialog(); return(result); }
/// <summary> /// sets the ImageSource of <see cref="Icon"/> to a value corresponding to a /// chosen value <see cref="DialogIcon"/> using <see cref="IconHelper.GetDialogImage"/> /// </summary> /// <param name="value">a chosen value of enum <see cref="BlurryDialogIcon"/></param> private void SetDialogIconSource(BlurryDialogIcon value) { Icon = value.GetDialogImage(); }
/// <summary> /// Displays a message box that has a message, title bar caption, button, and icon; /// and returns a result. /// </summary> /// <param name="messageBoxText">A <see cref="string"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="string"/> that specifies the title bar caption to display.</param> /// <param name="button">A <see cref="BlurryDialogButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="BlurryDialogIcon"/> value that specifies the icon to display.</param> /// <param name="strength"> Determines the opacity of the window which is set to 0.75 by default and may not exceed 1</param> /// <returns>A <see cref="BlurryDialogResult"/> value that specifies which message box button is clicked by the user.</returns> public static BlurryDialogResult Show(string messageBoxText, string caption, BlurryDialogButton button, BlurryDialogIcon icon, double?strength = null) { var result = BlurryDialogResult.None; var dialog = new BlurBehindDialogWindow { Title = caption, DialogIcon = icon, DialogMessage = messageBoxText, Button = button, Owner = Application.Current.MainWindow, Strength = strength ?? ColorHelper.GetStrength(), BlurDuration = BlurDuration, UnblurDuration = UnblurDuration, BlurRadius = BlurRadius }; dialog.ResultAquired += (sender, args) => { dialog.Close(); result = args.Result; }; dialog.ShowDialog(); return(result); }