diff --git a/README.md b/README.md index 777ba4a..a472b28 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ WpfMessageBox is a WPF message box implementation, aimed to be visually balanced between the default WPF style and the native .NET MessageBox. It offers the following features: -* Returns the standard .NET [MessageBoxResult](https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboxresult)s. -* Uses the standard MessageBox [icons](https://docs.microsoft.com/en-us/windows/desktop/uxguide/vis-std-icons). +* Returns an equivalent of the standard .NET [MessageBoxResult](https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboxresult)s. +* Uses an equivalent of the standard MessageBox [icons](https://docs.microsoft.com/en-us/windows/desktop/uxguide/vis-std-icons). * Ability to define custom buttons text. * Optional header text. * Optional TextBox. @@ -19,23 +19,24 @@ WpfMessageBox is a WPF message box implementation, aimed to be visually balanced ## Usage 1. Install through [Nuget](https://www.nuget.org/packages/WpfMessageBox) -2. WpfMessageBox uses static method like the standard .NET MessageBox: +2. WpfMessageBox uses static methods like the standard .NET MessageBox: - ``` + ```csharp using WpfMessageBoxLibrary; - MessageBoxResult result = WpfMessageBox.Show("Some text", "Some title", MessageBoxButton.OK, MessageBoxImage.Exclamation); + WpfMessageBoxResult result = WpfMessageBox.Show("Some text", "Some title", WpfMessageBoxButton.OK, WpfMessageBoxImage.Exclamation); ``` + 3. In order to use the extra features offered by WpfMessageBox, you need to initialize a new `WpfMessageBoxProperties` which will hold the desired properties, then use the relevant static method: - ``` + ```csharp using WpfMessageBoxLibrary; var msgProperties = new WpfMessageBoxProperties() { - Button = MessageBoxButton.OKCancel, + Button = WpfMessageBoxButton.OKCancel, ButtonOkText = "Set name", CheckBoxText = "Don't ask again", - Image = MessageBoxImage.Exclamation, + Image = WpfMessageBoxImage.Exclamation, Header = "No name defined", IsCheckBoxChecked = true, IsCheckBoxVisible = true, @@ -44,12 +45,12 @@ WpfMessageBox is a WPF message box implementation, aimed to be visually balanced Title = "A nice example", }; - MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); + WpfMessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties); ``` 4. The `WpfMessageBoxProperties` object allows you to retrieve the `TextBox` and `CheckBox` values after the user closed the message box: - ``` + ```csharp bool checkBoxChecked = msgProperties.IsCheckBoxChecked; string textBoxContent = msgProperties.TextBoxText; ``` @@ -63,3 +64,8 @@ See the [changelog](CHANGELOG.md). ## License WpfMessageBox is licensed under the MIT license - see the [LICENSE](LICENSE) file for details. + +## Credits + +Some icons by [Yusuke Kamiyamane](http://p.yusukekamiyamane.com) licensed under a [Creative Commons Attribution 3.0 License](https://creativecommons.org/licenses/by/3.0). + diff --git a/docs/images/Screenshot-custom-buttons.png b/docs/images/Screenshot-custom-buttons.png index 46b8b4f..18148c2 100644 Binary files a/docs/images/Screenshot-custom-buttons.png and b/docs/images/Screenshot-custom-buttons.png differ diff --git a/docs/images/Screenshot-full.png b/docs/images/Screenshot-full.png index cd89c4c..5f54d03 100644 Binary files a/docs/images/Screenshot-full.png and b/docs/images/Screenshot-full.png differ diff --git a/src/Demo/WindowMain.xaml.cs b/src/Demo/WindowMain.xaml.cs index 1e5f3af..200153f 100644 --- a/src/Demo/WindowMain.xaml.cs +++ b/src/Demo/WindowMain.xaml.cs @@ -46,12 +46,12 @@ private void ButtonWpfMsgBoxAllFeatures_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.YesNoCancel, + Button = WpfMessageBoxButton.YesNoCancel, ButtonCancelText = "Cancel, cancel!", ButtonNoText = "Please no", ButtonYesText = "Yes _Sir", CheckBoxText = "I've pre-checked this for you", - Image = MessageBoxImage.Error, + Image = WpfMessageBoxImage.Error, Header = "Here we have an example of a very very very very very very very very very very very very very very very very very long instruction text.", IsCheckBoxChecked = true, IsCheckBoxVisible = true, @@ -69,11 +69,11 @@ private void ButtonWpfMsgBoxCustomButtons_Click(object sender, RoutedEventArgs e { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.YesNoCancel, + Button = WpfMessageBoxButton.YesNoCancel, ButtonCancelText = "Cancel, cancel!", ButtonNoText = "Please no", ButtonYesText = "Yes _Sir", - Image = MessageBoxImage.Information, + Image = WpfMessageBoxImage.Information, Text = "Some text", Title = "Some title", }; @@ -86,9 +86,9 @@ private void ButtonWpfMsgBoxLongInstruction_Click(object sender, RoutedEventArgs { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.OK, + Button = WpfMessageBoxButton.OK, Header = "Here we have an example of a very very very very very very very very very very very very very very very very very long instruction text.", - Image = MessageBoxImage.Information, + Image = WpfMessageBoxImage.Information, Text = "Some text", Title = "Some title", }; @@ -99,7 +99,7 @@ private void ButtonWpfMsgBoxLongInstruction_Click(object sender, RoutedEventArgs private void ButtonWpfMsgBoxLongText_Click(object sender, RoutedEventArgs e) { - var result = WpfMessageBox.Show(this, GetLongSampleText(), "Some title", MessageBoxButton.YesNoCancel, MessageBoxImage.Error); + var result = WpfMessageBox.Show(this, GetLongSampleText(), "Some title", WpfMessageBoxButton.YesNoCancel, WpfMessageBoxImage.Error); DisplayResult(result); } @@ -107,10 +107,10 @@ private void ButtonWpfMsgBoxNiceExample_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.OKCancel, + Button = WpfMessageBoxButton.OKCancel, ButtonOkText = "Set name", CheckBoxText = "Don't ask again", - Image = MessageBoxImage.Exclamation, + Image = WpfMessageBoxImage.Exclamation, Header = "No name defined", IsCheckBoxChecked = true, IsCheckBoxVisible = true, @@ -127,7 +127,7 @@ private void ButtonWpfMsgBoxWithCheckBox_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.OKCancel, + Button = WpfMessageBoxButton.OKCancel, CheckBoxText = "I've pre-checked this for you", IsCheckBoxChecked = true, IsCheckBoxVisible = true, @@ -143,9 +143,9 @@ private void ButtonWpfMsgBoxWithHeader_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.OK, + Button = WpfMessageBoxButton.OK, Header = "Some header", - Image = MessageBoxImage.Exclamation, + Image = WpfMessageBoxImage.Exclamation, Text = "Some text", Title = "Some title", }; @@ -156,19 +156,19 @@ private void ButtonWpfMsgBoxWithHeader_Click(object sender, RoutedEventArgs e) private void ButtonWpfMsgBoxWithIcon_Click(object sender, RoutedEventArgs e) { - var result = WpfMessageBox.Show(this, "Some text", "Some title", MessageBoxButton.OK, MessageBoxImage.Exclamation); + var result = WpfMessageBox.Show(this, "Some text", "Some title", WpfMessageBoxButton.OK, WpfMessageBoxImage.Exclamation); DisplayResult(result); } private void ButtonWpfMsgBoxWithoutTitle_Click(object sender, RoutedEventArgs e) { - var result = WpfMessageBox.Show(this, "Some text", "", MessageBoxButton.OKCancel); + var result = WpfMessageBox.Show(this, "Some text", "", WpfMessageBoxButton.OKCancel); DisplayResult(result); } private void ButtonWpfMsgBoxWithText_Click(object sender, RoutedEventArgs e) { - var result = WpfMessageBox.Show(this, "Some text", "Some title", MessageBoxButton.YesNoCancel); + var result = WpfMessageBox.Show(this, "Some text", "Some title", WpfMessageBoxButton.YesNoCancel); DisplayResult(result); } @@ -176,7 +176,7 @@ private void ButtonWpfMsgBoxWithTextBox_Click(object sender, RoutedEventArgs e) { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.OKCancel, + Button = WpfMessageBoxButton.OKCancel, IsTextBoxVisible = true, Text = "Some text", TextBoxText = "Pre-defined text", @@ -191,7 +191,7 @@ private void ButtonWpfMsgBoxWithTextBoxAndCheckBox_Click(object sender, RoutedEv { var msgProperties = new WpfMessageBoxProperties { - Button = MessageBoxButton.OKCancel, + Button = WpfMessageBoxButton.OKCancel, CheckBoxText = "I've pre-checked this for you", IsCheckBoxChecked = true, IsCheckBoxVisible = true, @@ -206,10 +206,15 @@ private void ButtonWpfMsgBoxWithTextBoxAndCheckBox_Click(object sender, RoutedEv private void DisplayResult(MessageBoxResult result) { - WpfMessageBox.Show(this, "Result is: DialogResult." + result, "Result", MessageBoxButton.OK, MessageBoxImage.Information); + WpfMessageBox.Show(this, "Result is: DialogResult." + result, "Result", WpfMessageBoxButton.OK, WpfMessageBoxImage.Information); } - private void DisplayResult(MessageBoxResult result, WpfMessageBoxProperties msgProperties) + private void DisplayResult(WpfMessageBoxResult result) + { + WpfMessageBox.Show(this, "Result is: DialogResult." + result, "Result", WpfMessageBoxButton.OK, WpfMessageBoxImage.Information); + } + + private void DisplayResult(WpfMessageBoxResult result, WpfMessageBoxProperties msgProperties) { WpfMessageBox.Show( this, diff --git a/src/WpfMessageBox.sln.DotSettings b/src/WpfMessageBox.sln.DotSettings new file mode 100644 index 0000000..8c8be0e --- /dev/null +++ b/src/WpfMessageBox.sln.DotSettings @@ -0,0 +1,3 @@ + + ERROR + \ No newline at end of file diff --git a/src/WpfMessageBox/Core/WindowMain.xaml.cs b/src/WpfMessageBox/Core/WindowMain.xaml.cs index 6e843b7..ac127d3 100644 --- a/src/WpfMessageBox/Core/WindowMain.xaml.cs +++ b/src/WpfMessageBox/Core/WindowMain.xaml.cs @@ -1,5 +1,4 @@ using System; -using System.Drawing; using System.Windows; using System.Windows.Input; @@ -76,7 +75,7 @@ public string Message } } - public MessageBoxResult Result { get; set; } + public WpfMessageBoxResult Result { get; set; } public string TextBoxText { @@ -84,7 +83,7 @@ public string TextBoxText set => TextBox.Text = value; } - public WindowMain(string message, MessageBoxButton button, MessageBoxImage image) + public WindowMain(string message, WpfMessageBoxButton button, WpfMessageBoxImage image) { InitializeComponent(); @@ -117,51 +116,51 @@ protected override void OnSourceInitialized(EventArgs e) private void ButtonCancel_Click(object sender, RoutedEventArgs e) { - Result = MessageBoxResult.Cancel; + Result = WpfMessageBoxResult.Cancel; Close(); } private void ButtonNo_Click(object sender, RoutedEventArgs e) { - Result = MessageBoxResult.No; + Result = WpfMessageBoxResult.No; Close(); } private void ButtonOk_Click(object sender, RoutedEventArgs e) { - Result = MessageBoxResult.OK; + Result = WpfMessageBoxResult.OK; Close(); } private void ButtonYes_Click(object sender, RoutedEventArgs e) { - Result = MessageBoxResult.Yes; + Result = WpfMessageBoxResult.Yes; Close(); } - private void DisplayButtons(MessageBoxButton button) + private void DisplayButtons(WpfMessageBoxButton button) { switch (button) { - case MessageBoxButton.OK: + case WpfMessageBoxButton.OK: ButtonCancel.Visibility = Visibility.Collapsed; ButtonNo.Visibility = Visibility.Collapsed; ButtonOk.Visibility = Visibility.Visible; ButtonYes.Visibility = Visibility.Collapsed; break; - case MessageBoxButton.OKCancel: + case WpfMessageBoxButton.OKCancel: ButtonCancel.Visibility = Visibility.Visible; ButtonNo.Visibility = Visibility.Collapsed; ButtonOk.Visibility = Visibility.Visible; ButtonYes.Visibility = Visibility.Collapsed; break; - case MessageBoxButton.YesNo: + case WpfMessageBoxButton.YesNo: ButtonCancel.Visibility = Visibility.Collapsed; ButtonNo.Visibility = Visibility.Visible; ButtonOk.Visibility = Visibility.Collapsed; ButtonYes.Visibility = Visibility.Visible; break; - case MessageBoxButton.YesNoCancel: + case WpfMessageBoxButton.YesNoCancel: ButtonCancel.Visibility = Visibility.Visible; ButtonNo.Visibility = Visibility.Visible; ButtonOk.Visibility = Visibility.Collapsed; @@ -172,51 +171,52 @@ private void DisplayButtons(MessageBoxButton button) } } - private void DisplayImage(MessageBoxImage image) + private void DisplayImage(WpfMessageBoxImage image) { switch (image) { - case MessageBoxImage.Information: - // Also covers MessageBoxImage.Asterisk - ImageIcon.Source = SystemIcons.Information.ToImageSource(); + case WpfMessageBoxImage.Information: + ImageIcon.Source = WpfMessageBoxLibrary.Resources.ImageInformation; break; - case MessageBoxImage.Error: - // Also covers MessageBoxImage.Hand Also covers MessageBoxImage.Stop - ImageIcon.Source = SystemIcons.Error.ToImageSource(); + case WpfMessageBoxImage.Error: + ImageIcon.Source = WpfMessageBoxLibrary.Resources.ImageCrossCircle; break; - case MessageBoxImage.Warning: - // Also covers MessageBoxImage.Exclamation - ImageIcon.Source = SystemIcons.Warning.ToImageSource(); + case WpfMessageBoxImage.Exclamation: + ImageIcon.Source = WpfMessageBoxLibrary.Resources.ImageExclamation; break; - case MessageBoxImage.Question: - ImageIcon.Source = SystemIcons.Question.ToImageSource(); + case WpfMessageBoxImage.Question: + ImageIcon.Source = WpfMessageBoxLibrary.Resources.ImageQuestion; break; - default: - // Also covers MessageBoxImage.None + case WpfMessageBoxImage.Validation: + ImageIcon.Source = WpfMessageBoxLibrary.Resources.ImageTick; + break; + case WpfMessageBoxImage.None: ImageIcon.Source = null; break; + default: + throw new NotImplementedException(); } ImageIcon.Visibility = ImageIcon.Source == null ? Visibility.Collapsed : Visibility.Visible; } - private void SetDefaultAndCancelButtons(MessageBoxButton button) + private void SetDefaultAndCancelButtons(WpfMessageBoxButton button) { switch (button) { - case MessageBoxButton.OK: + case WpfMessageBoxButton.OK: ButtonOk.IsDefault = true; ButtonOk.IsCancel = true; break; - case MessageBoxButton.OKCancel: + case WpfMessageBoxButton.OKCancel: ButtonOk.IsDefault = true; ButtonCancel.IsCancel = true; break; - case MessageBoxButton.YesNo: + case WpfMessageBoxButton.YesNo: ButtonYes.IsDefault = true; ButtonNo.IsCancel = true; break; - case MessageBoxButton.YesNoCancel: + case WpfMessageBoxButton.YesNoCancel: ButtonYes.IsDefault = true; ButtonCancel.IsCancel = true; break; diff --git a/src/WpfMessageBox/Core/WpfMessageBox.cs b/src/WpfMessageBox/Core/WpfMessageBox.cs index 9db6fc5..0aa1bd5 100644 --- a/src/WpfMessageBox/Core/WpfMessageBox.cs +++ b/src/WpfMessageBox/Core/WpfMessageBox.cs @@ -1,5 +1,7 @@ using System.Windows; +// ReSharper disable UnusedMethodReturnValue.Global +// ReSharper disable UnusedMember.Global // ReSharper disable once CheckNamespace namespace WpfMessageBoxLibrary { @@ -12,10 +14,10 @@ public static class WpfMessageBox /// Displays a message box with the specified text. /// /// The text to display in the message box. - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(string text) + /// One of the values. + public static WpfMessageBoxResult Show(string text) { - var msg = new WindowMain(text, MessageBoxButton.OK, MessageBoxImage.None); + var msg = new WindowMain(text, WpfMessageBoxButton.OK, WpfMessageBoxImage.None); msg.ShowDialog(); return msg.Result; } @@ -25,10 +27,10 @@ public static MessageBoxResult Show(string text) /// /// A Window that represents the owner window of the message box. /// The text to display in the message box. - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(Window owner, string text) + /// One of the values. + public static WpfMessageBoxResult Show(Window owner, string text) { - var msg = new WindowMain(text, MessageBoxButton.OK, MessageBoxImage.None) + var msg = new WindowMain(text, WpfMessageBoxButton.OK, WpfMessageBoxImage.None) { Owner = owner, }; @@ -41,10 +43,10 @@ public static MessageBoxResult Show(Window owner, string text) /// /// The text to display in the message box. /// The text to display in the title bar of the message box. - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(string text, string title) + /// One of the values. + public static WpfMessageBoxResult Show(string text, string title) { - var msg = new WindowMain(text, MessageBoxButton.OK, MessageBoxImage.None) + var msg = new WindowMain(text, WpfMessageBoxButton.OK, WpfMessageBoxImage.None) { Title = title, }; @@ -58,10 +60,10 @@ public static MessageBoxResult Show(string text, string title) /// A Window that represents the owner window of the message box. /// The text to display in the message box. /// The text to display in the title bar of the message box. - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(Window owner, string text, string title) + /// One of the values. + public static WpfMessageBoxResult Show(Window owner, string text, string title) { - var msg = new WindowMain(text, MessageBoxButton.OK, MessageBoxImage.None) + var msg = new WindowMain(text, WpfMessageBoxButton.OK, WpfMessageBoxImage.None) { Owner = owner, Title = title, @@ -76,12 +78,12 @@ public static MessageBoxResult Show(Window owner, string text, string title) /// The text to display in the message box. /// The text to display in the title bar of the message box. /// - /// One of the MessageBoxButton values that specifies which button to display in the message box. + /// One of the values that specifies which button to display in the message box. /// - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(string text, string title, MessageBoxButton button) + /// One of the values. + public static WpfMessageBoxResult Show(string text, string title, WpfMessageBoxButton button) { - var msg = new WindowMain(text, button, MessageBoxImage.None) + var msg = new WindowMain(text, button, WpfMessageBoxImage.None) { Title = title, }; @@ -97,12 +99,12 @@ public static MessageBoxResult Show(string text, string title, MessageBoxButton /// The text to display in the message box. /// The text to display in the title bar of the message box. /// - /// One of the MessageBoxButton values that specifies which button to display in the message box. + /// One of the values that specifies which button to display in the message box. /// - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(Window owner, string text, string title, MessageBoxButton button) + /// One of the values. + public static WpfMessageBoxResult Show(Window owner, string text, string title, WpfMessageBoxButton button) { - var msg = new WindowMain(text, button, MessageBoxImage.None) + var msg = new WindowMain(text, button, WpfMessageBoxImage.None) { Owner = owner, Title = title, @@ -117,13 +119,13 @@ public static MessageBoxResult Show(Window owner, string text, string title, Mes /// The text to display in the message box. /// The text to display in the title bar of the message box. /// - /// One of the MessageBoxButton values that specifies which button to display in the message box. + /// One of the values that specifies which button to display in the message box. /// /// - /// One of the MessageBoxImage values that specifies which image to display in the message box. + /// One of the values that specifies which image to display in the message box. /// - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(string text, string title, MessageBoxButton button, MessageBoxImage image) + /// One of the values. + public static WpfMessageBoxResult Show(string text, string title, WpfMessageBoxButton button, WpfMessageBoxImage image) { var msg = new WindowMain(text, button, image) { @@ -141,13 +143,13 @@ public static MessageBoxResult Show(string text, string title, MessageBoxButton /// The text to display in the message box. /// The text to display in the title bar of the message box. /// - /// One of the MessageBoxButton values that specifies which button to display in the message box. + /// One of the values that specifies which button to display in the message box. /// /// - /// One of the MessageBoxImage values that specifies which image to display in the message box. + /// One of the values that specifies which image to display in the message box. /// - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(Window owner, string text, string title, MessageBoxButton button, MessageBoxImage image) + /// One of the values. + public static WpfMessageBoxResult Show(Window owner, string text, string title, WpfMessageBoxButton button, WpfMessageBoxImage image) { var msg = new WindowMain(text, button, image) { @@ -162,8 +164,8 @@ public static MessageBoxResult Show(Window owner, string text, string title, Mes /// Displays a message box with the specified properties. /// /// The WpfMessageBoxProperties to apply to the message box. - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(ref WpfMessageBoxProperties properties) + /// One of the values. + public static WpfMessageBoxResult Show(ref WpfMessageBoxProperties properties) { var msg = new WindowMain(properties.Text, properties.Button, properties.Image) { @@ -193,8 +195,8 @@ public static MessageBoxResult Show(ref WpfMessageBoxProperties properties) /// /// A Window that represents the owner window of the message box. /// The WpfMessageBoxProperties to apply to the message box. - /// One of the MessageBoxResult values. - public static MessageBoxResult Show(Window owner, ref WpfMessageBoxProperties properties) + /// One of the values. + public static WpfMessageBoxResult Show(Window owner, ref WpfMessageBoxProperties properties) { var msg = new WindowMain(properties.Text, properties.Button, properties.Image) { diff --git a/src/WpfMessageBox/Core/WpfMessageBoxButton.cs b/src/WpfMessageBox/Core/WpfMessageBoxButton.cs new file mode 100644 index 0000000..cfdd594 --- /dev/null +++ b/src/WpfMessageBox/Core/WpfMessageBoxButton.cs @@ -0,0 +1,21 @@ +// ReSharper disable once CheckNamespace +// ReSharper disable InconsistentNaming + +namespace WpfMessageBoxLibrary +{ + /// Specifies the buttons that are displayed on a message box. + public enum WpfMessageBoxButton + { + /// The message box displays an OK button. + OK, + + /// The message box displays OK and Cancel buttons. + OKCancel, + + /// The message box displays Yes, No, and Cancel buttons. + YesNoCancel, + + /// The message box displays Yes and No buttons. + YesNo, + } +} diff --git a/src/WpfMessageBox/Core/WpfMessageBoxImage.cs b/src/WpfMessageBox/Core/WpfMessageBoxImage.cs new file mode 100644 index 0000000..0bac963 --- /dev/null +++ b/src/WpfMessageBox/Core/WpfMessageBoxImage.cs @@ -0,0 +1,26 @@ +// ReSharper disable once CheckNamespace + +namespace WpfMessageBoxLibrary +{ + /// Specifies the icon that is displayed by a message box. + public enum WpfMessageBoxImage + { + /// The message box contains no symbols. + None, + + /// The message box contains a symbol consisting of white X in a circle with a red background. + Error, + + /// The message box contains a symbol consisting of a question mark in a circle. + Question, + + /// The message box contains a symbol consisting of an exclamation point in a triangle with a yellow background. + Exclamation, + + /// The message box contains a symbol consisting of a lowercase letter i in a circle. + Information, + + /// The message box contains a symbol consisting of a green tick. + Validation, + } +} diff --git a/src/WpfMessageBox/Core/WpfMessageBoxProperties.cs b/src/WpfMessageBox/Core/WpfMessageBoxProperties.cs index 5e18943..07acf9a 100644 --- a/src/WpfMessageBox/Core/WpfMessageBoxProperties.cs +++ b/src/WpfMessageBox/Core/WpfMessageBoxProperties.cs @@ -1,6 +1,5 @@ -using System.Windows; +// ReSharper disable once CheckNamespace -// ReSharper disable once CheckNamespace namespace WpfMessageBoxLibrary { /// @@ -11,7 +10,7 @@ public sealed class WpfMessageBoxProperties /// /// Gets or sets the buttons used. /// - public MessageBoxButton Button { get; set; } + public WpfMessageBoxButton Button { get; set; } /// /// Gets or sets the "Cancel" button text. @@ -46,7 +45,7 @@ public sealed class WpfMessageBoxProperties /// /// Gets or sets the image. /// - public MessageBoxImage Image { get; set; } + public WpfMessageBoxImage Image { get; set; } /// /// Gets or sets a value indicating whether the checkbox should be checked by default. @@ -88,9 +87,9 @@ public WpfMessageBoxProperties() ButtonNoText = "_No"; ButtonOkText = "_OK"; ButtonYesText = "_Yes"; - Button = MessageBoxButton.OK; + Button = WpfMessageBoxButton.OK; CheckBoxText = ""; - Image = MessageBoxImage.None; + Image = WpfMessageBoxImage.None; Header = ""; IsCheckBoxChecked = false; IsCheckBoxVisible = false; diff --git a/src/WpfMessageBox/Core/WpfMessageBoxResult.cs b/src/WpfMessageBox/Core/WpfMessageBoxResult.cs new file mode 100644 index 0000000..fa26823 --- /dev/null +++ b/src/WpfMessageBox/Core/WpfMessageBoxResult.cs @@ -0,0 +1,24 @@ +// ReSharper disable once CheckNamespace +// ReSharper disable InconsistentNaming + +namespace WpfMessageBoxLibrary +{ + /// Specifies which message box button that a user clicks. + public enum WpfMessageBoxResult + { + /// The message box returns no result. + None, + + /// The result value of the message box is OK. + OK, + + /// The result value of the message box is Cancel. + Cancel, + + /// The result value of the message box is Yes. + Yes, + + /// The result value of the message box is No. + No, + } +} diff --git a/src/WpfMessageBox/Helpers/Extensions.cs b/src/WpfMessageBox/Helpers/Extensions.cs index 48b97d8..0ba97e1 100644 --- a/src/WpfMessageBox/Helpers/Extensions.cs +++ b/src/WpfMessageBox/Helpers/Extensions.cs @@ -1,10 +1,5 @@ -using System.Drawing; -using System.Windows; -using System.Windows.Interop; -using System.Windows.Media; -using System.Windows.Media.Imaging; +// ReSharper disable once CheckNamespace -// ReSharper disable once CheckNamespace namespace WpfMessageBoxLibrary { internal static class Extensions @@ -25,15 +20,5 @@ public static string AddMnemonic(this string input) return accelerator + input; } - - /// - /// Tranforms the specified Icon instance to an ImageSource. - /// - /// The Icon to transform. - public static ImageSource ToImageSource(this Icon icon) - { - ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); - return imageSource; - } } } diff --git a/src/WpfMessageBox/Resources/Resources.cs b/src/WpfMessageBox/Resources/Resources.cs new file mode 100644 index 0000000..f8f7457 --- /dev/null +++ b/src/WpfMessageBox/Resources/Resources.cs @@ -0,0 +1,17 @@ +using System; +using System.Windows.Media.Imaging; + +// ReSharper disable once CheckNamespace +namespace WpfMessageBoxLibrary +{ + internal static class Resources + { + private const string RESOURCES_ROOT_PATH = "pack://application:,,,/WpfMessageBox;component/Resources"; + + public static BitmapImage ImageCrossCircle => new BitmapImage(new Uri($"{RESOURCES_ROOT_PATH}/cross-circle.png")); + public static BitmapImage ImageExclamation => new BitmapImage(new Uri($"{RESOURCES_ROOT_PATH}/exclamation.png")); + public static BitmapImage ImageInformation => new BitmapImage(new Uri($"{RESOURCES_ROOT_PATH}/information.png")); + public static BitmapImage ImageQuestion => new BitmapImage(new Uri($"{RESOURCES_ROOT_PATH}/question.png")); + public static BitmapImage ImageTick => new BitmapImage(new Uri($"{RESOURCES_ROOT_PATH}/tick.png")); + } +} diff --git a/src/WpfMessageBox/Resources/cross-circle.png b/src/WpfMessageBox/Resources/cross-circle.png new file mode 100644 index 0000000..5cdf6ea Binary files /dev/null and b/src/WpfMessageBox/Resources/cross-circle.png differ diff --git a/src/WpfMessageBox/Resources/exclamation.png b/src/WpfMessageBox/Resources/exclamation.png new file mode 100644 index 0000000..721ba1e Binary files /dev/null and b/src/WpfMessageBox/Resources/exclamation.png differ diff --git a/src/WpfMessageBox/Resources/information.png b/src/WpfMessageBox/Resources/information.png new file mode 100644 index 0000000..5d353a1 Binary files /dev/null and b/src/WpfMessageBox/Resources/information.png differ diff --git a/src/WpfMessageBox/Resources/question.png b/src/WpfMessageBox/Resources/question.png new file mode 100644 index 0000000..09dc996 Binary files /dev/null and b/src/WpfMessageBox/Resources/question.png differ diff --git a/src/WpfMessageBox/Resources/tick.png b/src/WpfMessageBox/Resources/tick.png new file mode 100644 index 0000000..aeeeee5 Binary files /dev/null and b/src/WpfMessageBox/Resources/tick.png differ diff --git a/src/WpfMessageBox/WpfMessageBox.csproj b/src/WpfMessageBox/WpfMessageBox.csproj index d0245e1..9201c70 100644 --- a/src/WpfMessageBox/WpfMessageBox.csproj +++ b/src/WpfMessageBox/WpfMessageBox.csproj @@ -31,13 +31,13 @@ pre$([System.DateTime]::Now.ToString("yyyyMMdd-HHmmss")) - - - - + + + + \ No newline at end of file