From b3139b9bc7e57e562327bee831a48f14b2692de9 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Sat, 11 Feb 2023 12:06:56 +0000 Subject: [PATCH] * Underpinnings for #927 --- .../ButtonSpecs/ButtonSpecNavFormClose.cs | 77 +++++++++++++++++++ .../ButtonSpecs/ButtonSpecNavFormMaximize.cs | 33 ++++++++ .../ButtonSpecs/ButtonSpecNavFormMinimize.cs | 33 ++++++++ .../ButtonSpecs/ButtonSpecNavFormRestore.cs | 33 ++++++++ .../ButtonSpec/ButtonSpecFormWindowClose.cs | 9 ++- 5 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormClose.cs create mode 100644 Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMaximize.cs create mode 100644 Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMinimize.cs create mode 100644 Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormRestore.cs diff --git a/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormClose.cs b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormClose.cs new file mode 100644 index 000000000..bdbf4f23b --- /dev/null +++ b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormClose.cs @@ -0,0 +1,77 @@ +#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.Navigator +{ + public class ButtonSpecNavFormClose : ButtonSpecNavFixed + { + #region Instance Fields + + private bool _enabled = true; + + #endregion + + #region Identity + + /// Initializes a new instance of the class. + /// The navigator. + public ButtonSpecNavFormClose(KryptonNavigator navigator) : base(navigator, PaletteButtonSpecStyle.FormClose) + { + } + + #endregion + + #region Implementation + + /* + /// + /// Form Close Button Enabled: This will also Disable the System Menu `Close` BUT NOT the `Alt+F4` key action + /// + [Category(@"Appearance")] + [DefaultValue(true)] + [Description("Form Close Button Enabled: This will also Disable the System Menu `Close` BUT NOT the `Alt+F4` key action")] + public bool Enabled + { + get => _enabled; + set + { + if (_enabled != value) + { + _enabled = value; + IntPtr hSystemMenu = PI.GetSystemMenu(KryptonForm.Handle, false); + if (hSystemMenu != IntPtr.Zero) + { + PI.EnableMenuItem(hSystemMenu, PI.SC_.CLOSE, _enabled ? PI.MF_.ENABLED : PI.MF_.DISABLED); + } + } + } + } + */ + #endregion + + #region ButtonSpecNavFixed Implementation + + public override bool GetVisible(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonCheckState GetChecked(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonEnabled GetEnabled(PaletteBase palette) + { + throw new NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMaximize.cs b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMaximize.cs new file mode 100644 index 000000000..a88826f76 --- /dev/null +++ b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMaximize.cs @@ -0,0 +1,33 @@ +#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.Navigator +{ + public class ButtonSpecNavFormMaximize : ButtonSpecNavFixed + { + public ButtonSpecNavFormMaximize(KryptonNavigator navigator, PaletteButtonSpecStyle fixedStyle) : base(navigator, fixedStyle) + { + } + + public override bool GetVisible(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonCheckState GetChecked(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonEnabled GetEnabled(PaletteBase palette) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMinimize.cs b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMinimize.cs new file mode 100644 index 000000000..a9fa72bf0 --- /dev/null +++ b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormMinimize.cs @@ -0,0 +1,33 @@ +#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.Navigator +{ + public class ButtonSpecNavFormMinimize : ButtonSpecNavFixed + { + public ButtonSpecNavFormMinimize(KryptonNavigator navigator, PaletteButtonSpecStyle fixedStyle) : base(navigator, fixedStyle) + { + } + + public override bool GetVisible(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonCheckState GetChecked(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonEnabled GetEnabled(PaletteBase palette) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormRestore.cs b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormRestore.cs new file mode 100644 index 000000000..76b09063a --- /dev/null +++ b/Source/Krypton Components/Krypton.Navigator/ButtonSpecs/ButtonSpecNavFormRestore.cs @@ -0,0 +1,33 @@ +#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.Navigator +{ + public class ButtonSpecNavFormRestore : ButtonSpecNavFixed + { + public ButtonSpecNavFormRestore(KryptonNavigator navigator, PaletteButtonSpecStyle fixedStyle) : base(navigator, fixedStyle) + { + } + + public override bool GetVisible(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonCheckState GetChecked(PaletteBase palette) + { + throw new NotImplementedException(); + } + + public override ButtonEnabled GetEnabled(PaletteBase palette) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecFormWindowClose.cs b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecFormWindowClose.cs index 52461c98b..752caa180 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecFormWindowClose.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ButtonSpec/ButtonSpecFormWindowClose.cs @@ -38,14 +38,15 @@ public ButtonSpecFormWindowClose(KryptonForm form) public bool Enabled { get => _enabled; - set { + set + { if (_enabled != value) { _enabled = value; IntPtr hSystemMenu = PI.GetSystemMenu(KryptonForm.Handle, false); - if ( hSystemMenu != IntPtr.Zero) + if (hSystemMenu != IntPtr.Zero) { - PI.EnableMenuItem(hSystemMenu, PI.SC_.CLOSE, _enabled ? PI.MF_.ENABLED:PI.MF_.DISABLED); + PI.EnableMenuItem(hSystemMenu, PI.SC_.CLOSE, _enabled ? PI.MF_.ENABLED : PI.MF_.DISABLED); } } } @@ -77,7 +78,7 @@ public override bool GetVisible(PaletteBase palette) /// /// Palette to use for inheriting values. /// Button enabled state. - public override ButtonEnabled GetEnabled(PaletteBase palette) => KryptonForm.CloseBox && Enabled ? ButtonEnabled.True: ButtonEnabled.False; + public override ButtonEnabled GetEnabled(PaletteBase palette) => KryptonForm.CloseBox && Enabled ? ButtonEnabled.True : ButtonEnabled.False; /// /// Gets the button checked state.