Skip to content

Commit

Permalink
Merge pull request #871 from Krypton-Suite/alpha-fr#866
Browse files Browse the repository at this point in the history
* Implement #866
  • Loading branch information
Smurf-IV authored Dec 17, 2022
2 parents e38898f + 806bd30 commit bfdc09c
Show file tree
Hide file tree
Showing 15 changed files with 410 additions and 241 deletions.
7 changes: 4 additions & 3 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# <img src="https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/Krypton.png"> Standard Toolkit - ChangeLog
# <img src="https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/Krypton.png?raw=true"> Standard Toolkit - ChangeLog

<!--* Added the ability to control the `CueHint` values through `KryptonPalette`-->

=======

## 2023-11-xx - Build 2311 - November 2023
* Implemented [#866](https://github.com/Krypton-Suite/Standard-Toolkit/issues/866), `KryptonMessageBox` Option to use system icons
* New `Application``KryptonMessageBoxIcon` type, specify your application icon to show in the `KryptonMessageBox` (recommended image size is 32 x 32)
* Resolved [#867](https://github.com/Krypton-Suite/Standard-Toolkit/issues/867), KryptonMessageBox does not show help button
* Resolved [#728](https://github.com/Krypton-Suite/Standard-Toolkit/issues/728),
Bring MessageBox States inline with latest .Net 6
* Resolved [#728](https://github.com/Krypton-Suite/Standard-Toolkit/issues/728), Bring MessageBox States inline with latest .Net 6
* Resolved [#861](https://github.com/Krypton-Suite/Standard-Toolkit/issues/861), Ribbon QAT Button downscaled when disabling HiDPI
* Implemented [#854](https://github.com/Krypton-Suite/Standard-Toolkit/issues/854), Please remove "2019" from the build sequence etc.
* Resolved [#848](https://github.com/Krypton-Suite/Standard-Toolkit/issues/848), KryptonTreeView Font Issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public static class KryptonMessageBox
/// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(string text, string caption, bool? showCtrlCopy = null) =>
InternalShow(null, text, caption, KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4,
0, null, showCtrlCopy, null, null, @"", null);
ShowCore(null, text, caption, KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4, 0, null, showCtrlCopy,
null, null, @"", null, null, @"");

/// <summary>
/// Displays a message box in front+center of the application and with the specified text, caption and buttons.
Expand All @@ -44,9 +44,9 @@ public static DialogResult Show(string text, string caption, bool? showCtrlCopy
/// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(string text, bool? showCtrlCopy = null) =>
InternalShow(null, text, @"", KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4,
0, null, showCtrlCopy, false, null, @"", null);
ShowCore(null, text, @"", KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4, 0,
null, showCtrlCopy, false, null, @"", null, null, @"");

/// <summary>
/// Displays a message box in front+center of the specified object and with the specified text, caption, buttons, icon, default button, and options.
Expand All @@ -56,9 +56,8 @@ public static DialogResult Show(string text, bool? showCtrlCopy = null) =>
/// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(IWin32Window owner, string text, bool? showCtrlCopy = null) =>
InternalShow(owner, text, @"", KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4,
0, null, showCtrlCopy, false, null, @"", null);
ShowCore(owner, text, @"", KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4, 0, null, showCtrlCopy, false, null, @"", null, null, @"");

/// <summary>
/// Displays a message box in front+center of the specified object and with the specified text, caption, buttons, icon, default button, and options.
Expand All @@ -69,9 +68,9 @@ public static DialogResult Show(IWin32Window owner, string text, bool? showCtrlC
/// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption, bool? showCtrlCopy = null) =>
InternalShow(owner, text, caption, KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
ShowCore(owner, text, caption, KryptonMessageBoxButtons.OK, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button4,
0, null, showCtrlCopy, false, null, @"", null);
0, null, showCtrlCopy, false, null, @"", null, null, @"");

/// <summary>
/// Displays a message box in front+center of the application and with the specified text, caption and buttons.
Expand All @@ -83,10 +82,10 @@ public static DialogResult Show(IWin32Window owner, string text, string caption,
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(string text, string caption, KryptonMessageBoxButtons buttons,
bool? showCtrlCopy = null) =>
InternalShow(null, text, caption, buttons, KryptonMessageBoxIcon.None,
ShowCore(null, text, caption, buttons, KryptonMessageBoxIcon.None,
KryptonMessageBoxDefaultButton.Button1, 0,
new HelpInfo(@"", 0, null), showCtrlCopy,
null, null, @"", null);
null, null, @"", null, null, @"");

/// <summary>
/// Displays a message box in front+center of the application and with the specified text, caption, buttons, icon, default button, and options.
Expand All @@ -103,6 +102,8 @@ public static DialogResult Show(string text, string caption, KryptonMessageBoxBu
/// <param name="showActionButton">Shows the optional action button.</param>
/// <param name="actionButtonText">The action button text.</param>
/// <param name="actionButtonCommand">The <see cref="KryptonCommand"/> attached to the action button.</param>
/// <param name="applicationImage">The image of the application.</param>
/// <param name="applicationPath">The application path. To be used in conjunction with <see cref="T:KryptonMessageBoxIcon.Application"/> type.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(string text,
string caption,
Expand All @@ -115,12 +116,13 @@ public static DialogResult Show(string text,
bool? showHelpButton = null,
bool? showActionButton = null,
string actionButtonText = @"",
KryptonCommand actionButtonCommand = null)
KryptonCommand actionButtonCommand = null, Image applicationImage = null,
string applicationPath = @"")
=>
InternalShow(null, text, caption, buttons, icon, defaultButton, options,
ShowCore(null, text, caption, buttons, icon, defaultButton, options,
displayHelpButton ? new HelpInfo() : null, showCtrlCopy,
showHelpButton, showActionButton,
actionButtonText, actionButtonCommand);
actionButtonText, actionButtonCommand, applicationImage, applicationPath);


/// <summary>
Expand All @@ -139,6 +141,8 @@ public static DialogResult Show(string text,
/// <param name="showActionButton">Shows the optional action button.</param>
/// <param name="actionButtonText">The action button text.</param>
/// <param name="actionButtonCommand">The <see cref="KryptonCommand"/> attached to the action button.</param>
/// <param name="applicationImage">The image of the application.</param>
/// <param name="applicationPath">The application path. To be used in conjunction with <see cref="T:KryptonMessageBoxIcon.Application"/> type.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(IWin32Window owner, string text,
string caption,
Expand All @@ -151,12 +155,13 @@ public static DialogResult Show(IWin32Window owner, string text,
bool? showHelpButton = null,
bool? showActionButton = null,
string actionButtonText = @"",
KryptonCommand actionButtonCommand = null)
KryptonCommand actionButtonCommand = null, Image applicationImage = null,
string applicationPath = @"")
=>
InternalShow(owner, text, caption, buttons, icon, defaultButton, options,
ShowCore(owner, text, caption, buttons, icon, defaultButton, options,
displayHelpButton ? new HelpInfo() : null, showCtrlCopy,
showHelpButton, showActionButton, actionButtonText,
actionButtonCommand);
actionButtonCommand, applicationImage, applicationPath);

/// <param name="text">The text to display in the message box.</param>
/// <param name="caption" >The text to display in the title bar of the message box. default="string.Empty"</param>
Expand All @@ -172,17 +177,19 @@ public static DialogResult Show(IWin32Window owner, string text,
/// <param name="showActionButton">Shows the optional action button.</param>
/// <param name="actionButtonText">The action button text.</param>
/// <param name="actionButtonCommand">The <see cref="KryptonCommand"/> attached to the action button.</param>
/// <param name="applicationImage">The image of the application.</param>
/// <param name="applicationPath">The application path. To be used in conjunction with <see cref="T:KryptonMessageBoxIcon.Application"/> type.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(string text, string caption, KryptonMessageBoxButtons buttons, KryptonMessageBoxIcon icon, KryptonMessageBoxDefaultButton defaultButton,
MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param, bool? showCtrlCopy = null,
bool? showHelpButton = null,
bool? showActionButton = null,
string actionButtonText = @"",
KryptonCommand actionButtonCommand = null)
=> InternalShow(null, text, caption, buttons, icon, defaultButton, options,
KryptonCommand actionButtonCommand = null, Image applicationImage = null, string applicationPath = @"")
=> ShowCore(null, text, caption, buttons, icon, defaultButton, options,
new HelpInfo(helpFilePath, navigator, param), showCtrlCopy,
showHelpButton, showActionButton, actionButtonText,
actionButtonCommand);
actionButtonCommand, applicationImage, applicationPath);

/// <summary>
/// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator, and Help topic.
Expand All @@ -202,17 +209,19 @@ public static DialogResult Show(string text, string caption, KryptonMessageBoxBu
/// <param name="showActionButton">Shows the optional action button.</param>
/// <param name="actionButtonText">The action button text.</param>
/// <param name="actionButtonCommand">The <see cref="KryptonCommand"/> attached to the action button.</param>
/// <param name="applicationImage">The image of the application.</param>
/// <param name="applicationPath">The application path. To be used in conjunction with <see cref="T:KryptonMessageBoxIcon.Application"/> type.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
public static DialogResult Show(IWin32Window owner, string text, string caption, KryptonMessageBoxButtons buttons, KryptonMessageBoxIcon icon, KryptonMessageBoxDefaultButton defaultButton,
MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param, bool? showCtrlCopy = null,
bool? showHelpButton = null,
bool? showActionButton = null,
string actionButtonText = @"",
KryptonCommand actionButtonCommand = null)
=> InternalShow(owner, text, caption, buttons, icon, defaultButton, options,
KryptonCommand actionButtonCommand = null, Image applicationImage = null, string applicationPath = @"")
=> ShowCore(owner, text, caption, buttons, icon, defaultButton, options,
new HelpInfo(helpFilePath, navigator, param), showCtrlCopy,
showHelpButton, showActionButton, actionButtonText,
actionButtonCommand);
actionButtonCommand, applicationImage, applicationPath);
#endregion

#region Implementation
Expand All @@ -232,8 +241,10 @@ public static DialogResult Show(IWin32Window owner, string text, string caption,
/// <param name="showActionButton">Shows the optional action button.</param>
/// <param name="actionButtonText">The action button text.</param>
/// <param name="actionButtonCommand">The <see cref="KryptonCommand"/> attached to the action button.</param>
/// <param name="applicationImage">The image of the application.</param>
/// <param name="applicationPath">The application path. To be used in conjunction with <see cref="T:KryptonMessageBoxIcon.Application"/> type.</param>
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
private static DialogResult InternalShow(IWin32Window owner,
private static DialogResult ShowCore(IWin32Window owner,
string text, string caption,
KryptonMessageBoxButtons buttons,
KryptonMessageBoxIcon icon,
Expand All @@ -242,14 +253,17 @@ private static DialogResult InternalShow(IWin32Window owner,
HelpInfo helpInfo, bool? showCtrlCopy,
bool? showHelpButton,
bool? showActionButton, string actionButtonText,
KryptonCommand actionButtonCommand)
KryptonCommand actionButtonCommand,
Image applicationImage, string applicationPath)
{
caption = string.IsNullOrEmpty(caption) ? @" " : caption;

IWin32Window showOwner = ValidateOptions(owner, options, helpInfo);

// Show message box window as a modal dialog and then dispose of it afterwards
using KryptonMessageBoxForm kmb = new(showOwner, text, caption, buttons, icon, defaultButton, options, helpInfo, showCtrlCopy, showHelpButton, showActionButton, actionButtonText, actionButtonCommand);
using KryptonMessageBoxForm kmb = new(showOwner, text, caption, buttons, icon, defaultButton, options,
helpInfo, showCtrlCopy, showHelpButton, showActionButton,
actionButtonText, actionButtonCommand, applicationImage, applicationPath);
kmb.StartPosition = showOwner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent;

return kmb.ShowDialog(showOwner);
Expand Down
Loading

0 comments on commit bfdc09c

Please sign in to comment.