├── .gitattributes ├── .gitignore ├── README.md ├── build ├── WPFCustomMessageBox.nuspec └── build-release.cmd └── source ├── CustomMessageBoxDemo ├── App.xaml ├── App.xaml.cs ├── CustomMessageBox Demo.csproj ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── app.config ├── WPFCustomMessageBox.sln └── WPFCustomMessageBox ├── App.xaml ├── App.xaml.cs ├── CustomMessageBox.cs ├── CustomMessageBoxWindow.xaml ├── CustomMessageBoxWindow.xaml.cs ├── MessageBoxData.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Util.cs ├── WPFCustomMessageBox.csproj └── blankicon.ico /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | 84 | # Windows Azure Build Output 85 | csx 86 | *.build.csdef 87 | 88 | # Windows Store app package directory 89 | AppPackages/ 90 | 91 | # Others 92 | [Bb]in 93 | [Oo]bj 94 | sql 95 | TestResults 96 | [Tt]est[Rr]esult* 97 | *.Cache 98 | ClientBin 99 | [Ss]tyle[Cc]op.* 100 | ~$* 101 | *.dbmdl 102 | Generated_Code #added for RIA/Silverlight projects 103 | 104 | # Backup & report files from converting an old project file to a newer 105 | # Visual Studio version. Backup files are not needed, because we have git ;-) 106 | _UpgradeReport_Files/ 107 | Backup*/ 108 | UpgradeLog*.XML -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WPFCustomMessageBox 2 | ===================== 3 | 4 | *WPFCustomMessageBox* is a WPF clone of the native Windows/.NET MessageBox with extra features like custom button text. 5 | 6 | ![WPFCustomMessageBox example screenshot](http://i.stack.imgur.com/AQgEj.png) 7 | 8 | I created this library because I wanted to use verbs for my MessageBox buttons to [help users better understand the functionality of the buttons](http://ux.stackexchange.com/a/9960/12349) - which isn't possible in the standard Windows MessageBox. With this library, you can offer your users button descriptions like `Save/Don't Save` or `Shutdown Reactor/Eject Spent Fuel Rods` rather than the standard `OK/Cancel` or `Yes/No` (although you can still use those too, if you like). 9 | 10 | The WPFCustomMessageBox message boxes return [standard .NET MessageBoxResults](http://msdn.microsoft.com/en-us/library/system.windows.messageboxresult%28v=vs.100%29.aspx). 11 | 12 | ## Downloading and Installing ## 13 | 14 | [WPFCustomMessageBox is available via NuGet](https://www.nuget.org/packages/WPFCustomMessageBox/). 15 | 16 | ## Usage ## 17 | 18 | This documentation is still in progress, so in the meantime you can explore the `CustomMessageBoxDemo` project which should have a variety of demos. 19 | 20 | WPFCustomMessageBox uses static methods just like the standard .NET MessageBox, so you can plug-and-play the new library without modifying any code. When you want to add custom text, just use the special methods outlined below. 21 | 22 | **Standard .NET Message Box** 23 | 24 | 25 | ```csharp 26 | MessageBox.Show("Hello World!", "This is the title of the MessageBox", MessageBoxButton.OKCancel); 27 | ``` 28 | 29 | **WPFCustomMessageBox Equivalent** 30 | 31 | 32 | ```csharp 33 | using WPFCustomMessageBox; 34 | 35 | CustomMessageBox.Show("Hello World!", "This is the title of the MessageBox", MessageBoxButton.OKCancel); 36 | ``` 37 | 38 | **Adding custom button text to WPFCustomMessageBox** 39 | 40 | ```csharp 41 | using WPFCustomMessageBox; 42 | 43 | CustomMessageBox.ShowOKCancel( 44 | "Are you sure you want to eject the nuclear fuel rods?", 45 | "Confirm Fuel Ejection", 46 | "Eject Fuel Rods", 47 | "Don't do it!"); 48 | ``` 49 | 50 | **Custom Button Methods** 51 | 52 | The WPFCustomMessageBox library provides customizable equivalents of all .NET MessageBox button types: 53 | 54 | * `CustomMessageBox.Show()` - Standard MessageBox 55 | * `CustomMessageBox.ShowOK()` - MessageBox with single customizable "OK" button. Returns `MessageBoxResult.OK`. 56 | * `CustomMessageBox.ShowOKCancel()` - MessageBox with customizable "OK" and "Cancel" buttons. Returns either `MessageBoxResult.OK` or `MessageBoxResult.Cancel`. 57 | * `CustomMessageBox.ShowYesNo()` - MessageBox with customizable "Yes" and "No" buttons. Returns either `MessageBoxResult.Yes` or `MessageBoxResult.No`. 58 | * `CustomMessageBox.ShowYesNoCancel()` - MessageBox with customizable "Yes", "No", and "Cancel" buttons. Returns either `MessageBoxResult.Yes`, `MessageBoxResult.No`, or `MessageBoxResult.Cancel`. 59 | 60 | ## Todo ## 61 | 62 | * i18n support (especially for languages that read right-to-left) 63 | 64 | ## License ## 65 | 66 | **The MIT License** 67 | 68 | Copyright (c) 2013 Evan Wondrasek / Apricity Software LLC 69 | 70 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 71 | 72 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 73 | 74 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 75 | -------------------------------------------------------------------------------- /build/WPFCustomMessageBox.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WPFCustomMessageBox 5 | 1.0.7 6 | WPF Custom MessageBox 7 | Evan Wondrasek / Apricity Software LLC 8 | https://github.com/evanwon/WPFCustomMessageBox/blob/master/README.md 9 | false 10 | A WPF clone of the native Windows/.NET MessageBox with extra features like custom button text. 11 | 12 | Added XML documentation file for IntelliSense 13 | Evan Wondrasek / Apricity Software LLC 14 | en-US 15 | wpf messagebox 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /build/build-release.cmd: -------------------------------------------------------------------------------- 1 | :: http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx 2 | 3 | @ECHO OFF 4 | 5 | SET msbuild="%ProgramFiles(x86)%\MSBuild\12.0\Bin\msbuild.exe" 6 | 7 | :: delete existing build 8 | del "..\source\WPFCustomMessageBox\bin\Release\" /q /s 9 | 10 | IF '%1'=='' (SET configuration=Release) ELSE (SET configuration=%1) 11 | IF '%2'=='' (SET platform="Any CPU") ELSE (SET platform=%2) 12 | 13 | %msbuild% "../source/WPFCustomMessageBox.sln" /t:Rebuild /nologo /property:Platform=%platform% /property:Configuration=%configuration% /property:DebugSymbols=false /property:DebugType=None /property:AllowedReferenceRelatedFileExtensions=- /verbosity:minimal /flp:verbosity=normal;logfile=build-release.log 14 | 15 | IF NOT ERRORLEVEL 0 EXIT /B %ERRORLEVEL% -------------------------------------------------------------------------------- /source/CustomMessageBoxDemo/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /source/CustomMessageBoxDemo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Windows; 7 | 8 | namespace CustomMessageBoxDemo 9 | { 10 | /// 11 | /// Interaction logic for App.xaml 12 | /// 13 | public partial class App : Application 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /source/CustomMessageBoxDemo/CustomMessageBox Demo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {BEB8F894-9C79-4D30-8061-C5570C1B159D} 9 | WinExe 10 | Properties 11 | CustomMessageBoxDemo 12 | CustomMessageBoxDemo 13 | v4.0 14 | Client 15 | 512 16 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 4 18 | 19 | 20 | x86 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | x86 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | AnyCPU 40 | bin\Debug\ 41 | 42 | 43 | AnyCPU 44 | bin\Release\ 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 4.0 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | MSBuild:Compile 64 | Designer 65 | 66 | 67 | MSBuild:Compile 68 | Designer 69 | 70 | 71 | App.xaml 72 | Code 73 | 74 | 75 | MainWindow.xaml 76 | Code 77 | 78 | 79 | 80 | 81 | Code 82 | 83 | 84 | True 85 | True 86 | Resources.resx 87 | 88 | 89 | True 90 | Settings.settings 91 | True 92 | 93 | 94 | ResXFileCodeGenerator 95 | Resources.Designer.cs 96 | 97 | 98 | 99 | SettingsSingleFileGenerator 100 | Settings.Designer.cs 101 | 102 | 103 | 104 | 105 | 106 | {ED02D418-7C0E-4E6C-99A9-BE4357122AE7} 107 | WPFCustomMessageBox 108 | 109 | 110 | 111 | 118 | -------------------------------------------------------------------------------- /source/CustomMessageBoxDemo/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | 43 | 47 | 48 | 49 | 50 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/CustomMessageBoxWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Windows; 3 | 4 | namespace WPFCustomMessageBox 5 | { 6 | /// 7 | /// Interaction logic for ModalDialog.xaml 8 | /// 9 | internal partial class CustomMessageBoxWindow : Window 10 | { 11 | #region Properties 12 | 13 | internal string Caption 14 | { 15 | get 16 | { 17 | return this.Title; 18 | } 19 | set 20 | { 21 | this.Title = value; 22 | } 23 | } 24 | 25 | internal string Message 26 | { 27 | get 28 | { 29 | return this.TextBlock_Message.Text; 30 | } 31 | set 32 | { 33 | this.TextBlock_Message.Text = value; 34 | } 35 | } 36 | 37 | internal string OkButtonText 38 | { 39 | get 40 | { 41 | return this.Label_Ok.Content.ToString(); 42 | } 43 | set 44 | { 45 | this.Label_Ok.Content = value.TryAddKeyboardAccellerator(); 46 | } 47 | } 48 | 49 | internal string CancelButtonText 50 | { 51 | get 52 | { 53 | return this.Label_Cancel.Content.ToString(); 54 | } 55 | set 56 | { 57 | this.Label_Cancel.Content = value.TryAddKeyboardAccellerator(); 58 | } 59 | } 60 | 61 | internal string YesButtonText 62 | { 63 | get 64 | { 65 | return this.Label_Yes.Content.ToString(); 66 | } 67 | set 68 | { 69 | this.Label_Yes.Content = value.TryAddKeyboardAccellerator(); 70 | } 71 | } 72 | 73 | internal string NoButtonText 74 | { 75 | get 76 | { 77 | return this.Label_No.Content.ToString(); 78 | } 79 | set 80 | { 81 | this.Label_No.Content = value.TryAddKeyboardAccellerator(); 82 | } 83 | } 84 | 85 | public MessageBoxResult Result { get; set; } 86 | 87 | #endregion 88 | 89 | #region Constructor 90 | 91 | internal CustomMessageBoxWindow(string message, string caption, MessageBoxButton button, MessageBoxImage image) 92 | { 93 | this.InitializeComponent(); 94 | 95 | this.Message = message; 96 | this.Caption = caption; 97 | this.Image_MessageBox.Visibility = Visibility.Collapsed; 98 | 99 | this.DisplayImage(image); 100 | this.DisplayButtons(button); 101 | } 102 | 103 | #endregion 104 | 105 | #region Methods 106 | 107 | private void DisplayButtons(MessageBoxButton button) 108 | { 109 | switch (button) 110 | { 111 | case MessageBoxButton.OKCancel: 112 | // Hide all but OK, Cancel 113 | this.Button_OK.Visibility = System.Windows.Visibility.Visible; 114 | this.Button_OK.Focus(); 115 | this.Button_Cancel.Visibility = System.Windows.Visibility.Visible; 116 | 117 | this.Button_Yes.Visibility = System.Windows.Visibility.Collapsed; 118 | this.Button_No.Visibility = System.Windows.Visibility.Collapsed; 119 | break; 120 | 121 | case MessageBoxButton.YesNo: 122 | // Hide all but Yes, No 123 | this.Button_Yes.Visibility = System.Windows.Visibility.Visible; 124 | this.Button_Yes.Focus(); 125 | this.Button_No.Visibility = System.Windows.Visibility.Visible; 126 | 127 | this.Button_OK.Visibility = System.Windows.Visibility.Collapsed; 128 | this.Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; 129 | break; 130 | 131 | case MessageBoxButton.YesNoCancel: 132 | // Hide only OK 133 | this.Button_Yes.Visibility = System.Windows.Visibility.Visible; 134 | this.Button_Yes.Focus(); 135 | this.Button_No.Visibility = System.Windows.Visibility.Visible; 136 | this.Button_Cancel.Visibility = System.Windows.Visibility.Visible; 137 | 138 | this.Button_OK.Visibility = System.Windows.Visibility.Collapsed; 139 | break; 140 | 141 | default: 142 | // Hide all but OK 143 | this.Button_OK.Visibility = System.Windows.Visibility.Visible; 144 | this.Button_OK.Focus(); 145 | 146 | this.Button_Yes.Visibility = System.Windows.Visibility.Collapsed; 147 | this.Button_No.Visibility = System.Windows.Visibility.Collapsed; 148 | this.Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; 149 | break; 150 | } 151 | } 152 | 153 | private void DisplayImage(MessageBoxImage image) 154 | { 155 | Icon icon; 156 | 157 | switch (image) 158 | { 159 | case MessageBoxImage.None: 160 | return; 161 | 162 | case MessageBoxImage.Exclamation: // Enumeration value 48 - also covers "Warning" 163 | icon = SystemIcons.Exclamation; 164 | break; 165 | 166 | case MessageBoxImage.Error: // Enumeration value 16, also covers "Hand" and "Stop" 167 | icon = SystemIcons.Hand; 168 | break; 169 | 170 | case MessageBoxImage.Information: // Enumeration value 64 - also covers "Asterisk" 171 | icon = SystemIcons.Information; 172 | break; 173 | 174 | case MessageBoxImage.Question: 175 | icon = SystemIcons.Question; 176 | break; 177 | 178 | default: 179 | icon = SystemIcons.Information; 180 | break; 181 | } 182 | 183 | this.Image_MessageBox.Source = icon.ToImageSource(); 184 | this.Image_MessageBox.Visibility = Visibility.Visible; 185 | } 186 | 187 | private void Button_OK_Click(object sender, RoutedEventArgs e) 188 | { 189 | this.Result = MessageBoxResult.OK; 190 | this.Close(); 191 | } 192 | 193 | private void Button_Cancel_Click(object sender, RoutedEventArgs e) 194 | { 195 | this.Result = MessageBoxResult.Cancel; 196 | this.Close(); 197 | } 198 | 199 | private void Button_Yes_Click(object sender, RoutedEventArgs e) 200 | { 201 | this.Result = MessageBoxResult.Yes; 202 | this.Close(); 203 | } 204 | 205 | private void Button_No_Click(object sender, RoutedEventArgs e) 206 | { 207 | this.Result = MessageBoxResult.No; 208 | this.Close(); 209 | } 210 | 211 | #endregion 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/MessageBoxData.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Windows; 3 | 4 | namespace WPFCustomMessageBox 5 | { 6 | internal class MessageBoxData 7 | { 8 | #region Properties 9 | 10 | public Window Owner { get; set; } 11 | 12 | public string Message { get; set; } = ""; 13 | 14 | public string Caption { get; set; } = "Message"; 15 | 16 | public MessageBoxButton Buttons { get; set; } = MessageBoxButton.OK; 17 | 18 | public MessageBoxImage Image { get; set; } = MessageBoxImage.None; 19 | 20 | public string YesButtonCaption { get; set; } 21 | 22 | public string NoButtonCaption { get; set; } 23 | 24 | public string CancelButtonCaption { get; set; } 25 | 26 | public string OkButtonCaption { get; set; } 27 | 28 | public MessageBoxResult Result { get; set; } = MessageBoxResult.None; 29 | 30 | #endregion 31 | 32 | #region Methods 33 | 34 | /// 35 | /// Displays a message box that is defined by the properties of this class. 36 | /// In case the current thread is not a STA thread already, 37 | /// a new STA thread is being created and the MessageBox is being displayed from there. 38 | /// 39 | /// 40 | public MessageBoxResult ShowMessageBox() 41 | { 42 | if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) 43 | { 44 | this.ShowMessageBoxSTA(); 45 | } 46 | else 47 | { 48 | var thread = new Thread(this.ShowMessageBoxSTA); 49 | thread.SetApartmentState(ApartmentState.STA); 50 | thread.Start(); 51 | thread.Join(); 52 | } 53 | 54 | return this.Result; 55 | } 56 | 57 | private void ShowMessageBoxSTA() 58 | { 59 | var msg = new CustomMessageBoxWindow(this.Message, this.Caption, this.Buttons, this.Image); 60 | 61 | msg.YesButtonText = this.YesButtonCaption ?? msg.YesButtonText; 62 | msg.NoButtonText = this.NoButtonCaption ?? msg.NoButtonText; 63 | msg.CancelButtonText = this.CancelButtonCaption ?? msg.CancelButtonText; 64 | msg.OkButtonText = this.OkButtonCaption ?? msg.OkButtonText; 65 | msg.Owner = this.Owner ?? msg.Owner; 66 | 67 | msg.ShowDialog(); 68 | 69 | this.Result = msg.Result; 70 | } 71 | 72 | #endregion 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WPFCustomMessageBox")] 11 | [assembly: AssemblyDescription("A WPF clone of the native Windows MessageBox with extra customizations like custom button text.")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WPFCustomMessageBox")] 15 | [assembly: AssemblyCopyright("Copyright © 2013 Evan Wondrasek / Apricity Software LLC")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.7.*")] 55 | //[assembly: AssemblyFileVersion("1.0.5.0")] 56 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WPFCustomMessageBox.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFCustomMessageBox.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WPFCustomMessageBox.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/Util.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // TODO: Update copyright text. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace WPFCustomMessageBox 8 | { 9 | using System.Drawing; 10 | using System.Windows; 11 | using System.Windows.Interop; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | 15 | /// 16 | /// TODO: Update summary. 17 | /// 18 | internal static class Util 19 | { 20 | internal static ImageSource ToImageSource(this Icon icon) 21 | { 22 | ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon( 23 | icon.Handle, 24 | Int32Rect.Empty, 25 | BitmapSizeOptions.FromEmptyOptions()); 26 | 27 | return imageSource; 28 | } 29 | 30 | /// 31 | /// Keyboard Accellerators are used in Windows to allow easy shortcuts to controls like Buttons and 32 | /// MenuItems. These allow users to press the Alt key, and a shortcut key will be highlighted on the 33 | /// control. If the user presses that key, that control will be activated. 34 | /// This method checks a string if it contains a keyboard accellerator. If it doesn't, it adds one to the 35 | /// beginning of the string. If there are two strings with the same accellerator, Windows handles it. 36 | /// The keyboard accellerator character for WPF is underscore (_). It will not be visible. 37 | /// 38 | /// 39 | /// 40 | internal static string TryAddKeyboardAccellerator(this string input) 41 | { 42 | const string accellerator = "_"; // This is the default WPF accellerator symbol - used to be & in WinForms 43 | 44 | // If it already contains an accellerator, do nothing 45 | if (input.Contains(accellerator)) return input; 46 | 47 | return accellerator + input; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/WPFCustomMessageBox.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {ED02D418-7C0E-4E6C-99A9-BE4357122AE7} 9 | Library 10 | Properties 11 | WPFCustomMessageBox 12 | WPFCustomMessageBox 13 | v4.0 14 | Client 15 | 512 16 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 4 18 | 19 | 20 | x86 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | x86 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | 41 | 42 | blankicon.ico 43 | 44 | 45 | AnyCPU 46 | bin\Debug\ 47 | bin\Debug\WPFCustomMessageBox.XML 48 | 49 | 50 | AnyCPU 51 | bin\Release\ 52 | bin\Release\WPFCustomMessageBox.XML 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 4.0 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | CustomMessageBoxWindow.xaml 69 | 70 | 71 | 72 | 73 | 74 | Designer 75 | MSBuild:Compile 76 | 77 | 78 | 79 | 80 | Code 81 | 82 | 83 | True 84 | True 85 | Resources.resx 86 | 87 | 88 | True 89 | Settings.settings 90 | True 91 | 92 | 93 | ResXFileCodeGenerator 94 | Resources.Designer.cs 95 | 96 | 97 | SettingsSingleFileGenerator 98 | Settings.Designer.cs 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 113 | -------------------------------------------------------------------------------- /source/WPFCustomMessageBox/blankicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evanwon/WPFCustomMessageBox/b1ac17557accbd09649c9b3c0d5eca42e15bccc1/source/WPFCustomMessageBox/blankicon.ico --------------------------------------------------------------------------------