Skip to content

Commit

Permalink
Merge branch 'alpha' into alpha-827-ExposeIPaletteIII
Browse files Browse the repository at this point in the history
  • Loading branch information
Smurf-IV authored Jan 21, 2023
2 parents e4d8736 + 73f44f8 commit 701582b
Show file tree
Hide file tree
Showing 16 changed files with 1,286 additions and 40 deletions.
2 changes: 2 additions & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

## 2023-11-xx - Build 2311 - November 2023
* Complete [#827](https://github.com/Krypton-Suite/Standard-Toolkit/issues/827),Expose IPalette / PaletteBase as a public interface in KryptonManager
* Resolved [#891](https://github.com/Krypton-Suite/Standard-Toolkit/issues/891), `LabelStyle` does not appear to have a default designer value
* Implemented [#887](https://github.com/Krypton-Suite/Standard-Toolkit/issues/887), A 'LinkLabel' version of the `KryptonWrapLabel`
* Fixed the display of the initial selected theme in the "ThemeSelection ComboBox"
* Resolved [#876](https://github.com/Krypton-Suite/Standard-Toolkit/issues/876), `Office 365 - Black` does not display text correctly
* Resolved [#874](https://github.com/Krypton-Suite/Standard-Toolkit/issues/874), 80.xx Canary Nuget text is incorrrect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Krypton.Toolkit
public class KryptonButton : VisualSimpleBase, IButtonControl, IContentValues
{
#region Instance Fields

private readonly ViewDrawButton _drawButton;
private ButtonStyle _style;
private readonly ButtonController _buttonController;
Expand All @@ -37,7 +38,14 @@ public class KryptonButton : VisualSimpleBase, IButtonControl, IContentValues
private readonly PaletteTripleOverride _overrideTracking;
private readonly PaletteTripleOverride _overridePressed;
private IKryptonCommand _command;
private bool _useAsDialogButton, _isDefault, _useMnemonic, _wasEnabled, _useAsUACElevationButton;
private bool _useAsDialogButton;
private bool _isDefault;
private bool _useMnemonic;
private bool _wasEnabled;
private bool _useAsUACElevationButton;
private Size _customUACShieldSize;
private UACShieldIconSize _uacShieldIconSize;

#endregion

#region Events
Expand Down Expand Up @@ -116,9 +124,13 @@ public KryptonButton()
ViewManager = new ViewManager(this, _drawButton);

_useAsDialogButton = false;

_useAsUACElevationButton = false;

_customUACShieldSize = new Size(16, 16);

_uacShieldIconSize = UACShieldIconSize.ExtraSmall;

// Set `CornerRoundingRadius' to 'GlobalStaticValues.PRIMARY_CORNER_ROUNDING_VALUE' (-1)
CornerRoundingRadius = GlobalStaticValues.PRIMARY_CORNER_ROUNDING_VALUE;
}
Expand Down Expand Up @@ -237,26 +249,32 @@ private void ResetButtonStyle()
ButtonStyle = ButtonStyle.Standalone;
}

[DefaultValue(false),
[DefaultValue(false),
Description(@"If set to true, the text will pair up with the equivalent KryptonManager's dialog button text result. (Note: You'll lose any previous text)")]
public bool UseAsADialogButton
{
get => _useAsDialogButton;
set => _useAsDialogButton = value;
public bool UseAsADialogButton
{
get => _useAsDialogButton;
set => _useAsDialogButton = value;
}

[DefaultValue(false),
[DefaultValue(false),
Description(@"Transforms the button into a UAC elevated button.")]
public bool UseAsUACElevationButton
{
get => _useAsUACElevationButton;
set
{
_useAsUACElevationButton = value;
ShowUACShield(value);
}
public bool UseAsUACElevationButton
{
get => _useAsUACElevationButton;
set
{
_useAsUACElevationButton = value;
ShowUACShield(value);
}
}

[DefaultValue(null), Description(@"")]
public Size CustomUACShieldSize { get => _customUACShieldSize; set { _customUACShieldSize = value; UpdateShieldCustomSize(value); } }

[DefaultValue(typeof(UACShieldIconSize), @"UACShieldIconSize.ExtraSmall"), Description(@"")]
public UACShieldIconSize UACShieldIconSize { get => _uacShieldIconSize; set { _uacShieldIconSize = value; UpdateShieldSize(value); } }

/// <summary>
/// Gets access to the button content.
/// </summary>
Expand All @@ -267,6 +285,11 @@ public bool UseAsUACElevationButton

private bool ShouldSerializeValues() => !Values.IsDefault;

//[Category(@"Visuals"), Description(@"UAC Shield Values"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
//public UACShieldValues UACShieldValues { get; }

//private bool ShouldSerializeUACShieldValues() => !UACShieldValues.IsDefault;

/// <summary>
/// Gets access to the common button appearance that other states can override.
/// </summary>
Expand Down Expand Up @@ -580,7 +603,7 @@ protected override void OnClick(EventArgs e)
{
owner.DialogResult = DialogResult;
}
catch (InvalidEnumArgumentException )
catch (InvalidEnumArgumentException)
{
// Is it https://github.com/Krypton-Suite/Standard-Toolkit/issues/728
if (owner is KryptonMessageBoxForm)
Expand Down Expand Up @@ -710,7 +733,7 @@ protected virtual void SetStyles(ButtonStyle buttonStyle)
/// </summary>
/// <returns>Set of button values.</returns>
/// <param name="needPaint">Delegate for notifying paint requests.</param>
protected virtual ButtonValues CreateButtonValues(NeedPaintHandler needPaint) => new (needPaint);
protected virtual ButtonValues CreateButtonValues(NeedPaintHandler needPaint) => new(needPaint);

/// <summary>
/// Raises the KryptonCommandChanged event.
Expand Down Expand Up @@ -794,6 +817,34 @@ private void ShowUACShield(bool showUACShield)
Values.Image = null;
}
}

private void UpdateShieldCustomSize(Size value) => UpdateShieldSize(UACShieldIconSize.Custom, value);

private void UpdateShieldSize(UACShieldIconSize value, Size? customSize = null)
{
switch (value)
{
case UACShieldIconSize.Custom:
Values.Image = GraphicsExtensions.ScaleImage(Values.Image, customSize);
break;
case UACShieldIconSize.ExtraSmall:
Values.Image = GraphicsExtensions.ScaleImage(Values.Image, new Size(16, 16));
break;
case UACShieldIconSize.Small:
Values.Image = GraphicsExtensions.ScaleImage(Values.Image, new Size(32, 32));
break;
case UACShieldIconSize.Medium:
Values.Image = GraphicsExtensions.ScaleImage(Values.Image, new Size(64, 64));
break;
case UACShieldIconSize.Large:
Values.Image = GraphicsExtensions.ScaleImage(Values.Image, new Size(128, 128));
break;
case UACShieldIconSize.ExtraLarge:
Values.Image = GraphicsExtensions.ScaleImage(Values.Image, new Size(255, 255));
break;
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public KryptonForm()

// Create the view manager instance
ViewManager = new ViewManager(this, _drawDocker);

// Set the CornerRoundingRadius to 'GlobalStaticValues.PRIMARY_CORNER_ROUNDING_VALUE', default value
CornerRoundingRadius = GlobalStaticValues.PRIMARY_CORNER_ROUNDING_VALUE;

Expand Down Expand Up @@ -1616,7 +1616,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e)
PaletteBackStyle.ControlToolTip,
PaletteBorderStyle.ControlToolTip,
CommonHelper.ContentStyleFromLabelStyle(toolTipStyle),
shadow);
shadow);

_visualPopupToolTip.Disposed += OnVisualPopupToolTipDisposed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void ResetOrientation()
/// </summary>
[Category(@"Visuals")]
[Description(@"Label style.")]
[DefaultValue(typeof(LabelStyle), "NormalPanel")]
[DefaultValue(typeof(LabelStyle), "LabelStyle.NormalPanel")]
public LabelStyle LabelStyle
{
get => _style;
Expand Down
Loading

0 comments on commit 701582b

Please sign in to comment.