|
1 | | -using WinRT.Interop; |
2 | | - |
3 | | -namespace DevWinUI; |
| 1 | +namespace DevWinUI; |
4 | 2 | public static class MessageBox |
5 | 3 | { |
| 4 | + /// <summary> |
| 5 | + /// Displays a message box with specified options and returns the user's response. |
| 6 | + /// </summary> |
| 7 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 8 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 9 | + /// <param name="title">Sets the title of the message box window.</param> |
| 10 | + /// <param name="messageBoxStyle">Determines the style and buttons that will be available in the message box.</param> |
| 11 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
6 | 12 | public static MessageBoxResult Show(Microsoft.UI.Xaml.Window window, string message, string title, MessageBoxStyle messageBoxStyle) |
7 | 13 | { |
8 | 14 | return Show(WindowNative.GetWindowHandle(window), message, title, messageBoxStyle); |
9 | 15 | } |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// Displays a message box with specified options and returns the user's response. |
| 19 | + /// </summary> |
| 20 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 21 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 22 | + /// <param name="title">Sets the title of the message box window.</param> |
| 23 | + /// <param name="messageBoxStyle">Determines the style and buttons that will be available in the message box.</param> |
| 24 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
10 | 25 | public static MessageBoxResult Show(IntPtr hwnd, string message, string title, MessageBoxStyle messageBoxStyle) |
11 | 26 | { |
12 | 27 | Windows.Win32.UI.WindowsAndMessaging.MESSAGEBOX_STYLE mbStyle = 0; |
@@ -120,81 +135,210 @@ public static MessageBoxResult Show(IntPtr hwnd, string message, string title, M |
120 | 135 | } |
121 | 136 | } |
122 | 137 |
|
| 138 | + /// <summary> |
| 139 | + /// Displays a message box with a specified message and title in the context of a given window. |
| 140 | + /// </summary> |
| 141 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 142 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 143 | + /// <param name="title">Sets the title of the message box window.</param> |
| 144 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
123 | 145 | public static MessageBoxResult Show(Microsoft.UI.Xaml.Window window, string message, string title) |
124 | 146 | { |
125 | 147 | return Show(WindowNative.GetWindowHandle(window), message, title); |
126 | 148 | } |
| 149 | + |
| 150 | + /// <summary> |
| 151 | + /// Displays a message box with an OK button to the user. |
| 152 | + /// </summary> |
| 153 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 154 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 155 | + /// <param name="title">Sets the title of the message box window.</param> |
| 156 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
127 | 157 | public static MessageBoxResult Show(IntPtr hwnd, string message, string title) |
128 | 158 | { |
129 | 159 | return Show(hwnd, message, title, MessageBoxStyle.Ok); |
130 | 160 | } |
131 | 161 |
|
| 162 | + /// <summary> |
| 163 | + /// Displays a message box in the specified window with a given message and style. |
| 164 | + /// </summary> |
| 165 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 166 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 167 | + /// <param name="messageBoxStyle">Determines the style and buttons that will be available in the message box.</param> |
| 168 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
132 | 169 | public static MessageBoxResult Show(Microsoft.UI.Xaml.Window window, string message, MessageBoxStyle messageBoxStyle) |
133 | 170 | { |
134 | 171 | return Show(WindowNative.GetWindowHandle(window), message, messageBoxStyle); |
135 | 172 | } |
| 173 | + |
| 174 | + /// <summary> |
| 175 | + /// Displays a message box with specified text and style. It also includes the product name in the message box. |
| 176 | + /// </summary> |
| 177 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 178 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 179 | + /// <param name="messageBoxStyle">Determines the style and buttons that will be available in the message box.</param> |
| 180 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
136 | 181 | public static MessageBoxResult Show(IntPtr hwnd, string message, MessageBoxStyle messageBoxStyle) |
137 | 182 | { |
138 | 183 | return Show(hwnd, message, ProcessInfoHelper.ProductName, messageBoxStyle); |
139 | 184 | } |
140 | 185 |
|
| 186 | + /// <summary> |
| 187 | + /// Displays a message box in the specified window with a given message. |
| 188 | + /// </summary> |
| 189 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 190 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 191 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
141 | 192 | public static MessageBoxResult Show(Microsoft.UI.Xaml.Window window, string message) |
142 | 193 | { |
143 | 194 | return Show(WindowNative.GetWindowHandle(window), message); |
144 | 195 | } |
| 196 | + |
| 197 | + /// <summary> |
| 198 | + /// Displays a message box with a specified message and an OK button. |
| 199 | + /// </summary> |
| 200 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 201 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 202 | + /// <returns>Returns the result of the message box interaction.</returns> |
145 | 203 | public static MessageBoxResult Show(IntPtr hwnd, string message) |
146 | 204 | { |
147 | 205 | return Show(hwnd, message, ProcessInfoHelper.ProductName, MessageBoxStyle.Ok); |
148 | 206 | } |
149 | 207 |
|
| 208 | + /// <summary> |
| 209 | + /// Displays an information message box in the specified window. |
| 210 | + /// </summary> |
| 211 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 212 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 213 | + /// <param name="title">Sets the title of the message box window.</param> |
| 214 | + /// <returns>Returns the result of the message box interaction.</returns> |
150 | 215 | public static MessageBoxResult ShowInformation(Microsoft.UI.Xaml.Window window, string message, string title) |
151 | 216 | { |
152 | 217 | return ShowInformation(WindowNative.GetWindowHandle(window), message, title); |
153 | 218 | } |
| 219 | + |
| 220 | + /// <summary> |
| 221 | + /// Displays an information message box with an OK button and an information icon. |
| 222 | + /// </summary> |
| 223 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 224 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 225 | + /// <param name="title">Sets the title of the message box window.</param> |
| 226 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
154 | 227 | public static MessageBoxResult ShowInformation(IntPtr hwnd, string message, string title) |
155 | 228 | { |
156 | 229 | return Show(hwnd, message, title, MessageBoxStyle.Ok | MessageBoxStyle.IconInformation); |
157 | 230 | } |
158 | 231 |
|
| 232 | + /// <summary> |
| 233 | + /// Displays an information message box in the specified window. |
| 234 | + /// </summary> |
| 235 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 236 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 237 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
159 | 238 | public static MessageBoxResult ShowInformation(Microsoft.UI.Xaml.Window window, string message) |
160 | 239 | { |
161 | 240 | return ShowInformation(WindowNative.GetWindowHandle(window), message); |
162 | 241 | } |
| 242 | + |
| 243 | + /// <summary> |
| 244 | + /// Displays an information message box to the user with an OK button and an information icon. |
| 245 | + /// </summary> |
| 246 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 247 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 248 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
163 | 249 | public static MessageBoxResult ShowInformation(IntPtr hwnd, string message) |
164 | 250 | { |
165 | 251 | return Show(hwnd, message, ProcessInfoHelper.ProductName, MessageBoxStyle.Ok | MessageBoxStyle.IconInformation); |
166 | 252 | } |
167 | 253 |
|
| 254 | + /// <summary> |
| 255 | + /// Displays an error message in a message box associated with a specified window. |
| 256 | + /// </summary> |
| 257 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 258 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 259 | + /// <param name="title">Sets the title of the message box window.</param> |
| 260 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
168 | 261 | public static MessageBoxResult ShowError(Microsoft.UI.Xaml.Window window, string message, string title) |
169 | 262 | { |
170 | 263 | return ShowError(WindowNative.GetWindowHandle(window), message, title); |
171 | 264 | } |
| 265 | + |
| 266 | + /// <summary> |
| 267 | + /// Displays an error message box with a specified message and title. |
| 268 | + /// </summary> |
| 269 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 270 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 271 | + /// <param name="title">Sets the title of the message box window.</param> |
| 272 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
172 | 273 | public static MessageBoxResult ShowError(IntPtr hwnd, string message, string title) |
173 | 274 | { |
174 | 275 | return Show(hwnd, message, title, MessageBoxStyle.Ok | MessageBoxStyle.IconError); |
175 | 276 | } |
| 277 | + |
| 278 | + /// <summary> |
| 279 | + /// Displays an error message in a message box associated with a specified window. |
| 280 | + /// </summary> |
| 281 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 282 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 283 | + /// <returns>Returns the result of the message box interaction.</returns> |
176 | 284 | public static MessageBoxResult ShowError(Microsoft.UI.Xaml.Window window, string message) |
177 | 285 | { |
178 | 286 | return ShowError(WindowNative.GetWindowHandle(window), message); |
179 | 287 | } |
| 288 | + |
| 289 | + /// <summary> |
| 290 | + /// Displays an error message box to the user with an OK button and an error icon. |
| 291 | + /// </summary> |
| 292 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 293 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 294 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
180 | 295 | public static MessageBoxResult ShowError(IntPtr hwnd, string message) |
181 | 296 | { |
182 | 297 | return Show(hwnd, message, ProcessInfoHelper.ProductName, MessageBoxStyle.Ok | MessageBoxStyle.IconError); |
183 | 298 | } |
184 | 299 |
|
| 300 | + /// <summary> |
| 301 | + /// Displays a warning message box in the specified window. It provides a way to show a message with a title to the |
| 302 | + /// user. |
| 303 | + /// </summary> |
| 304 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 305 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 306 | + /// <param name="title">Sets the title of the message box window.</param> |
| 307 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
185 | 308 | public static MessageBoxResult ShowWarning(Microsoft.UI.Xaml.Window window, string message, string title) |
186 | 309 | { |
187 | 310 | return ShowWarning(WindowNative.GetWindowHandle(window), message, title); |
188 | 311 | } |
| 312 | + |
| 313 | + /// <summary> |
| 314 | + /// Displays a warning message box with an OK button and a warning icon. |
| 315 | + /// </summary> |
| 316 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 317 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 318 | + /// <param name="title">Sets the title of the message box window.</param> |
| 319 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
189 | 320 | public static MessageBoxResult ShowWarning(IntPtr hwnd, string message, string title) |
190 | 321 | { |
191 | 322 | return Show(hwnd, message, title, MessageBoxStyle.Ok | MessageBoxStyle.IconWarning); |
192 | 323 | } |
193 | 324 |
|
| 325 | + /// <summary> |
| 326 | + /// Displays a warning message box in the specified window. It utilizes the window handle to present the message. |
| 327 | + /// </summary> |
| 328 | + /// <param name="window">Specifies the owner window of the message box.</param> |
| 329 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 330 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
194 | 331 | public static MessageBoxResult ShowWarning(Microsoft.UI.Xaml.Window window, string message) |
195 | 332 | { |
196 | 333 | return ShowWarning(WindowNative.GetWindowHandle(window), message); |
197 | 334 | } |
| 335 | + |
| 336 | + /// <summary> |
| 337 | + /// Displays a warning message box to the user with an OK button and a warning icon. |
| 338 | + /// </summary> |
| 339 | + /// <param name="hwnd">Specifies the owner window of the message box.</param> |
| 340 | + /// <param name="message">Text that will be shown in the message box.</param> |
| 341 | + /// <returns>Returns the result of the user's interaction with the message box.</returns> |
198 | 342 | public static MessageBoxResult ShowWarning(IntPtr hwnd, string message) |
199 | 343 | { |
200 | 344 | return Show(hwnd, message, ProcessInfoHelper.ProductName, MessageBoxStyle.Ok | MessageBoxStyle.IconWarning); |
|
0 commit comments