diff --git a/Documents/Help/Changelog.md b/Documents/Help/Changelog.md index 769fd2edf..53461492c 100644 --- a/Documents/Help/Changelog.md +++ b/Documents/Help/Changelog.md @@ -1,13 +1,14 @@ -# Standard Toolkit - ChangeLog +# Standard Toolkit - ChangeLog ======= ## 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 diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs index d5757101e..e8b6d48b0 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonMessageBox.cs @@ -33,9 +33,9 @@ public static class KryptonMessageBox /// Show extraText in title. If null(default) then only when Warning or Error icon is used. /// One of the System.Windows.Forms.DialogResult values. 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, @""); /// /// Displays a message box in front+center of the application and with the specified text, caption and buttons. @@ -44,9 +44,9 @@ public static DialogResult Show(string text, string caption, bool? showCtrlCopy /// Show extraText in title. If null(default) then only when Warning or Error icon is used. /// One of the System.Windows.Forms.DialogResult values. 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, @""); /// /// Displays a message box in front+center of the specified object and with the specified text, caption, buttons, icon, default button, and options. @@ -56,9 +56,8 @@ public static DialogResult Show(string text, bool? showCtrlCopy = null) => /// Show extraText in title. If null(default) then only when Warning or Error icon is used. /// One of the System.Windows.Forms.DialogResult values. 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, @""); /// /// Displays a message box in front+center of the specified object and with the specified text, caption, buttons, icon, default button, and options. @@ -69,9 +68,9 @@ public static DialogResult Show(IWin32Window owner, string text, bool? showCtrlC /// Show extraText in title. If null(default) then only when Warning or Error icon is used. /// One of the System.Windows.Forms.DialogResult values. 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, @""); /// /// Displays a message box in front+center of the application and with the specified text, caption and buttons. @@ -83,10 +82,10 @@ public static DialogResult Show(IWin32Window owner, string text, string caption, /// One of the System.Windows.Forms.DialogResult values. 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, @""); /// /// Displays a message box in front+center of the application and with the specified text, caption, buttons, icon, default button, and options. @@ -103,6 +102,8 @@ public static DialogResult Show(string text, string caption, KryptonMessageBoxBu /// Shows the optional action button. /// The action button text. /// The attached to the action button. + /// The image of the application. + /// The application path. To be used in conjunction with type. /// One of the System.Windows.Forms.DialogResult values. public static DialogResult Show(string text, string caption, @@ -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); /// @@ -139,6 +141,8 @@ public static DialogResult Show(string text, /// Shows the optional action button. /// The action button text. /// The attached to the action button. + /// The image of the application. + /// The application path. To be used in conjunction with type. /// One of the System.Windows.Forms.DialogResult values. public static DialogResult Show(IWin32Window owner, string text, string caption, @@ -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); /// The text to display in the message box. /// The text to display in the title bar of the message box. default="string.Empty" @@ -172,17 +177,19 @@ public static DialogResult Show(IWin32Window owner, string text, /// Shows the optional action button. /// The action button text. /// The attached to the action button. + /// The image of the application. + /// The application path. To be used in conjunction with type. /// One of the System.Windows.Forms.DialogResult values. 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); /// /// 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. @@ -202,17 +209,19 @@ public static DialogResult Show(string text, string caption, KryptonMessageBoxBu /// Shows the optional action button. /// The action button text. /// The attached to the action button. + /// The image of the application. + /// The application path. To be used in conjunction with type. /// One of the System.Windows.Forms.DialogResult values. 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 @@ -232,8 +241,10 @@ public static DialogResult Show(IWin32Window owner, string text, string caption, /// Shows the optional action button. /// The action button text. /// The attached to the action button. + /// The image of the application. + /// The application path. To be used in conjunction with type. /// One of the System.Windows.Forms.DialogResult values. - private static DialogResult InternalShow(IWin32Window owner, + private static DialogResult ShowCore(IWin32Window owner, string text, string caption, KryptonMessageBoxButtons buttons, KryptonMessageBoxIcon icon, @@ -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); diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs index 37bbaf4aa..2e4d3aca1 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs @@ -24,8 +24,10 @@ internal partial class KryptonMessageBoxForm : KryptonForm private readonly bool _showHelpButton; private readonly string _text; private readonly string _caption; + private readonly string _applicationPath; private readonly KryptonMessageBoxButtons _buttons; private readonly KryptonMessageBoxIcon _kryptonMessageBoxIcon; + private readonly Image _applicationImage; private readonly KryptonMessageBoxDefaultButton _defaultButton; private readonly MessageBoxOptions _options; // https://github.com/Krypton-Suite/Standard-Toolkit/issues/313 @@ -55,7 +57,7 @@ internal KryptonMessageBoxForm(IWin32Window showOwner, string text, string capti KryptonMessageBoxDefaultButton defaultButton, MessageBoxOptions options, HelpInfo helpInfo, bool? showCtrlCopy, bool? showHelpButton, bool? showActionButton, string actionButtonText, - KryptonCommand actionButtonCommand) + KryptonCommand actionButtonCommand, Image applicationImage, string applicationPath) { // Store incoming values _text = text; @@ -66,10 +68,12 @@ internal KryptonMessageBoxForm(IWin32Window showOwner, string text, string capti _options = options; _helpInfo = helpInfo; _showOwner = showOwner; - _showHelpButton = showHelpButton ?? (helpInfo!=null); + _showHelpButton = showHelpButton ?? (helpInfo != null); _showActionButton = showActionButton ?? false; _actionButtonText = actionButtonText ?? string.Empty; _actionButtonCommand = actionButtonCommand; + _applicationImage = applicationImage; + _applicationPath = applicationPath ?? @""; // Create the form contents InitializeComponent(); @@ -127,31 +131,36 @@ private void UpdateIcon() { switch (_kryptonMessageBoxIcon) { - default: case KryptonMessageBoxIcon.None: // Windows XP and before will Beep, Vista and above do not! if (OS_MAJOR_VERSION < 6) { SystemSounds.Beep.Play(); } - + break; + case KryptonMessageBoxIcon.Hand: + _messageIcon.Image = MessageBoxResources.Hand; + SystemSounds.Hand.Play(); + break; + case KryptonMessageBoxIcon.SystemHand: + _messageIcon.Image = SystemIcons.Hand.ToBitmap(); + SystemSounds.Hand.Play(); break; case KryptonMessageBoxIcon.Question: _messageIcon.Image = MessageBoxResources.Question; SystemSounds.Question.Play(); break; - case KryptonMessageBoxIcon.Exclamation: - case KryptonMessageBoxIcon.Information: - _messageIcon.Image = MessageBoxResources.Information; - SystemSounds.Asterisk.Play(); + case KryptonMessageBoxIcon.SystemQuestion: + _messageIcon.Image = SystemIcons.Question.ToBitmap(); + SystemSounds.Question.Play(); break; - case KryptonMessageBoxIcon.Warning: + case KryptonMessageBoxIcon.Exclamation: _messageIcon.Image = MessageBoxResources.Warning; SystemSounds.Exclamation.Play(); break; - case KryptonMessageBoxIcon.Error: - _messageIcon.Image = MessageBoxResources.Critical; - SystemSounds.Hand.Play(); + case KryptonMessageBoxIcon.SystemExclamation: + _messageIcon.Image = SystemIcons.Warning.ToBitmap(); + SystemSounds.Exclamation.Play(); break; case KryptonMessageBoxIcon.Asterisk: if (OSUtilities.IsWindowsEleven) @@ -164,13 +173,25 @@ private void UpdateIcon() } SystemSounds.Asterisk.Play(); break; - case KryptonMessageBoxIcon.Hand: - _messageIcon.Image = MessageBoxResources.Hand; - SystemSounds.Hand.Play(); + case KryptonMessageBoxIcon.SystemAsterisk: + _messageIcon.Image = SystemIcons.Asterisk.ToBitmap(); + SystemSounds.Asterisk.Play(); break; case KryptonMessageBoxIcon.Stop: _messageIcon.Image = MessageBoxResources.Stop; - SystemSounds.Hand.Play(); + SystemSounds.Asterisk.Play(); + break; + case KryptonMessageBoxIcon.Error: + _messageIcon.Image = MessageBoxResources.Critical; + SystemSounds.Asterisk.Play(); + break; + case KryptonMessageBoxIcon.Warning: + _messageIcon.Image = MessageBoxResources.Warning; + SystemSounds.Exclamation.Play(); + break; + case KryptonMessageBoxIcon.Information: + _messageIcon.Image = MessageBoxResources.Information; + SystemSounds.Asterisk.Play(); break; case KryptonMessageBoxIcon.Shield: if (OSUtilities.IsWindowsEleven) @@ -189,12 +210,12 @@ private void UpdateIcon() case KryptonMessageBoxIcon.WindowsLogo: // Because Windows 11 displays a generic application icon, // we need to rely on a image instead - if (Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 22000) + if (OSUtilities.IsWindowsEleven) { _messageIcon.Image = MessageBoxResources.Windows11; } // Windows 10 - else if (Environment.OSVersion.Version.Major == 10 && Environment.OSVersion.Version.Build <= 19045 /* RTM - 22H2 */) + else if (OSUtilities.IsWindowsTen) { _messageIcon.Image = MessageBoxResources.Windows_8_and_10_Logo; } @@ -202,7 +223,27 @@ private void UpdateIcon() { _messageIcon.Image = SystemIcons.WinLogo.ToBitmap(); } + break; + case KryptonMessageBoxIcon.Application: + if (_applicationImage != null) + { + _messageIcon.Image = _applicationImage; + } + else if (!string.IsNullOrEmpty(_applicationPath)) + { + Image sourceImage = GraphicsExtensions.ExtractIconFromFilePath(_applicationPath).ToBitmap(); + Image scaledImage = GraphicsExtensions.ScaleImage(sourceImage, new Size(32, 32)); + _messageIcon.Image = scaledImage; + } + else + { + // Fall back to defaults + _messageIcon.Image = SystemIcons.Application.ToBitmap(); + } + break; + case KryptonMessageBoxIcon.SystemApplication: + _messageIcon.Image = SystemIcons.Application.ToBitmap(); break; } diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/AssemblyUtilities.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/AssemblyUtilities.cs new file mode 100644 index 000000000..3a5198086 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/AssemblyUtilities.cs @@ -0,0 +1,53 @@ +#region BSD License +/* + * + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + #region Enumerations + + #endregion + + #region Class: AssemblyUtilities + + public class AssemblyUtilities + { + //https://www.meziantou.net/getting-the-date-of-build-of-a-dotnet-assembly-at-runtime.htm + public static DateTime GetLinkerTimestampUTC(Assembly assembly) + { + var location = assembly.Location; + + return GetLinkerTimestampUTC(location); + } + + public static DateTime GetLinkerTimestampUTC(string filePath) + { + const int PE_HEADER_OFFSET = 60; + + const int LINKER_TIMESTAMP_OFFSET = 8; + + var byteBuffer = new byte[2048]; + + using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + file.Read(byteBuffer, 0, byteBuffer.Length); + } + + var headerPosition = BitConverter.ToInt32(byteBuffer, PE_HEADER_OFFSET); + + var secondsSinceUNIXTimeStart = BitConverter.ToInt32(byteBuffer, headerPosition + LINKER_TIMESTAMP_OFFSET); + + var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + return dateTime.AddSeconds(secondsSinceUNIXTimeStart); + } + } + + #endregion +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/General.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/General.cs deleted file mode 100644 index 13c8926c5..000000000 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/General.cs +++ /dev/null @@ -1,143 +0,0 @@ -#region BSD License -/* - * - * Original BSD 3-Clause License (https://github.com/ComponentFactory/Krypton/blob/master/LICENSE) - * © Component Factory Pty Ltd, 2006 - 2016, (Version 4.5.0.0) All rights reserved. - * - * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) - * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. - * - */ -#endregion - -namespace Krypton.Toolkit -{ - #region Enumerations - - /// Specifies constants defining which buttons to display on a . - public enum KryptonMessageBoxButtons - { - /// - /// Specifies that the message box contains an OK button. - /// - OK = MessageBoxButtons.OK, - - /// - /// Specifies that the message box contains OK and Cancel buttons. - /// - OKCancel = MessageBoxButtons.OKCancel, - - /// - /// Specifies that the message box contains Abort, Retry, and Ignore buttons. - /// - AbortRetryIgnore = MessageBoxButtons.AbortRetryIgnore, - - /// - /// Specifies that the message box contains Yes, No, and Cancel buttons. - /// - YesNoCancel = MessageBoxButtons.YesNoCancel, - - /// - /// Specifies that the message box contains Yes and No buttons. - /// - YesNo = MessageBoxButtons.YesNo, - - /// - /// Specifies that the message box contains Retry and Cancel buttons. - /// - RetryCancel = MessageBoxButtons.RetryCancel, - - /// - /// Specifies that the message box contains Cancel, Try Again, and Continue buttons. - /// -#if NET60_OR_GREATER - CancelTryContinue = MessageBoxButtons.CancelTryContinue -#else - CancelTryContinue = 0x00000006 -#endif - } - - - /// Specifies constants defining the default button on a . - public enum KryptonMessageBoxDefaultButton - { - /// The first button on the message box is the default button. - Button1 = 0, - /// The second button on the message box is the default button. - Button2 = 256, - /// The third button on the message box is the default button. - Button3 = 512, - /// Specifies that the Help button on the message box should be the default button. - Button4 = 768, - /// The accelerator button. - Button5 = 1024 - } - - /// Specifies a custom color preview shape for a . - public enum KryptonColorButtonCustomColorPreviewShape - { - Circle = 0, - Square = 1, - RoundedSquare = 2, - None = 3 - } - - /// Positions the title on a . - public enum KryptonFormTitleStyle - { - /// Positions the title to the left (Windows 95 - 7/10/11 style). - Classic = 0, - /// Positions the title to the center (Windows 8/8.1 style). - Modern = 1, - /// Positions the title, based on OS settings. - Inherit = 2 - } - - /// The type. - public enum KryptonInputBoxType - { - /// Use a date and time input style. - DateAndTime = 0, - /// The default WinForms style. - Default = 1 - } - - #endregion - - #region Class: AssemblyUtilities - - public class AssemblyUtilities - { - //https://www.meziantou.net/getting-the-date-of-build-of-a-dotnet-assembly-at-runtime.htm - public static DateTime GetLinkerTimestampUTC(Assembly assembly) - { - var location = assembly.Location; - - return GetLinkerTimestampUTC(location); - } - - public static DateTime GetLinkerTimestampUTC(string filePath) - { - const int PE_HEADER_OFFSET = 60; - - const int LINKER_TIMESTAMP_OFFSET = 8; - - var byteBuffer = new byte[2048]; - - using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - file.Read(byteBuffer, 0, byteBuffer.Length); - } - - var headerPosition = BitConverter.ToInt32(byteBuffer, PE_HEADER_OFFSET); - - var secondsSinceUNIXTimeStart = BitConverter.ToInt32(byteBuffer, headerPosition + LINKER_TIMESTAMP_OFFSET); - - var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - return dateTime.AddSeconds(secondsSinceUNIXTimeStart); - } - } - - #endregion -} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs index e31516cf9..aba6840d1 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs @@ -1,8 +1,5 @@ #region BSD License /* - * - * Original BSD 3-Clause License (https://github.com/ComponentFactory/Krypton/blob/master/LICENSE) - * © Component Factory Pty Ltd, 2006 - 2016, (Version 4.5.0.0) All rights reserved. * * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. @@ -19,7 +16,7 @@ public static class GraphicsExtensions static GraphicsExtensions() { - + } #endregion @@ -58,6 +55,9 @@ public static Icon ExtractIconFromFilePath(string executablePath) return result; } + /// + /// + /// public enum SystemIconSize { Small = 0, @@ -128,40 +128,5 @@ public enum IconType public static Image SetIcon(Image image, Size size) => (Image)new Bitmap(image, size); } - public enum KryptonMessageBoxIcon - { - /// Specify no icon. - None = 0, - /// Specify a hand icon. - Hand = 1, - /// Specify a question icon. - Question = 2, - /// Specify a exclamation icon. - Exclamation = 3, - /// Specify a asterisk icon. - Asterisk = 4, - /// Specify a stop icon. - Stop = 5, - /// Specify a error icon. - Error = 6, - /// Specify a warning icon. - Warning = 7, - /// Specify a information icon. - Information = 8, - /// Specify a UAC shield icon. - Shield = 9, - /// Specify a Windows logo icon. - WindowsLogo = 10 - } - - public enum IconType - { - Warning = 101, - Help = 102, - Error = 103, - Info = 104, - Shield = 106 - } - - #endregion + #endregion } \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/IconType.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/IconType.cs new file mode 100644 index 000000000..497437489 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/IconType.cs @@ -0,0 +1,20 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + public enum IconType + { + Warning = 101, + Help = 102, + Error = 103, + Info = 104, + Shield = 106 + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs index 44533bd28..fc9c0db25 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/ImageNativeMethods.cs @@ -1,8 +1,5 @@ #region BSD License /* - * - * Original BSD 3-Clause License (https://github.com/ComponentFactory/Krypton/blob/master/LICENSE) - * © Component Factory Pty Ltd, 2006 - 2016, (Version 4.5.0.0) All rights reserved. * * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonColorButtonCustomColorPreviewShape.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonColorButtonCustomColorPreviewShape.cs new file mode 100644 index 000000000..af69bff31 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonColorButtonCustomColorPreviewShape.cs @@ -0,0 +1,20 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Specifies a custom color preview shape for a . + public enum KryptonColorButtonCustomColorPreviewShape + { + Circle = 0, + Square = 1, + RoundedSquare = 2, + None = 3 + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonFormTitleStyle.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonFormTitleStyle.cs new file mode 100644 index 000000000..47c18d43d --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonFormTitleStyle.cs @@ -0,0 +1,24 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Positions the title on a . + public enum KryptonFormTitleStyle + { + /// Positions the title to the left (Windows 95 - 7/10/11 style). + Classic = 0, + + /// Positions the title to the center (Windows 8/8.1 style). + Modern = 1, + + /// Positions the title, based on OS settings. + Inherit = 2 + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonInputBoxType.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonInputBoxType.cs new file mode 100644 index 000000000..591d70641 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonInputBoxType.cs @@ -0,0 +1,21 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// The type. + public enum KryptonInputBoxType + { + /// Use a date and time input style. + DateAndTime = 0, + + /// The default WinForms style. + Default = 1 + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxButtons.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxButtons.cs new file mode 100644 index 000000000..7626ab35a --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxButtons.cs @@ -0,0 +1,54 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Specifies constants defining which buttons to display on a . + public enum KryptonMessageBoxButtons + { + /// + /// Specifies that the message box contains an OK button. + /// + OK = MessageBoxButtons.OK, + + /// + /// Specifies that the message box contains OK and Cancel buttons. + /// + OKCancel = MessageBoxButtons.OKCancel, + + /// + /// Specifies that the message box contains Abort, Retry, and Ignore buttons. + /// + AbortRetryIgnore = MessageBoxButtons.AbortRetryIgnore, + + /// + /// Specifies that the message box contains Yes, No, and Cancel buttons. + /// + YesNoCancel = MessageBoxButtons.YesNoCancel, + + /// + /// Specifies that the message box contains Yes and No buttons. + /// + YesNo = MessageBoxButtons.YesNo, + + /// + /// Specifies that the message box contains Retry and Cancel buttons. + /// + RetryCancel = MessageBoxButtons.RetryCancel, + + /// + /// Specifies that the message box contains Cancel, Try Again, and Continue buttons. + /// +#if NET60_OR_GREATER + CancelTryContinue = MessageBoxButtons.CancelTryContinue +#else + CancelTryContinue = 0x00000006 +#endif + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxDefaultButton.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxDefaultButton.cs new file mode 100644 index 000000000..dcd4a3726 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxDefaultButton.cs @@ -0,0 +1,30 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Specifies constants defining the default button on a . + public enum KryptonMessageBoxDefaultButton + { + /// The first button on the message box is the default button. + Button1 = 0, + + /// The second button on the message box is the default button. + Button2 = 256, + + /// The third button on the message box is the default button. + Button3 = 512, + + /// Specifies that the Help button on the message box should be the default button. + Button4 = 768, + + /// The accelerator button. + Button5 = 1024 + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxIcon.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxIcon.cs new file mode 100644 index 000000000..f9fd49e18 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/KryptonMessageBoxIcon.cs @@ -0,0 +1,78 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner(aka Wagnerp) & Simon Coghlan(aka Smurf-IV), et al. 2017 - 2023. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit +{ + /// Specifies the icon type for . + public enum KryptonMessageBoxIcon + { + /// Specify no icon. + None = 0, + + /// Specify a hand icon. + Hand = 1, + + /// Specify the system hand icon. + SystemHand = MessageBoxIcon.Hand, + + /// Specify a question icon. + Question = 2, + + /// Specify the system question icon. + SystemQuestion = MessageBoxIcon.Question, + + /// Specify a exclamation icon. + Exclamation = 3, + + /// Specify the system exclamation icon. + SystemExclamation = MessageBoxIcon.Exclamation, + + /// Specify a asterisk icon. + Asterisk = 4, + + /// Specify the system asterisk icon. + SystemAsterisk = MessageBoxIcon.Asterisk, + + /// Specify a stop icon. + Stop = 5, + + /// Specify the system stop icon. + SystemStop = MessageBoxIcon.Stop, + + /// Specify a error icon. + Error = 6, + + /// Specify the system error icon. + SystemError = MessageBoxIcon.Error, + + /// Specify a warning icon. + Warning = 7, + + /// Specify the system warning icon. + SystemWarning = MessageBoxIcon.Warning, + + /// Specify a information icon. + Information = 8, + + /// Specify the system information icon. + SystemInformation = MessageBoxIcon.Information, + + /// Specify a UAC shield icon. + Shield = 9, + + /// Specify a Windows logo icon. + WindowsLogo = 10, + + /// Specify your application icon. + Application = 11, + + /// Specify the default system application icon. See . + SystemApplication = 12 + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/LanguagePackManager.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/LanguagePackManager.cs index 2801d837a..e04affee8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/LanguagePackManager.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/LanguagePackManager.cs @@ -10,12 +10,6 @@ */ #endregion -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Krypton.Toolkit { internal class LanguagePackManager : Storage