Skip to content

Commit

Permalink
Merge pull request #205 from Krypton-Suite/alpha-150-KLabelTheme
Browse files Browse the repository at this point in the history
- Make sure that the `NormalPanel` is the default style
  • Loading branch information
PWagner1 authored Jul 24, 2021
2 parents 25570d1 + 1477208 commit ed0580e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 56 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ These packages only support .NET Framework >= 4.8, .NET Core 3.1 and .NET 6.
=======

## 2021-08-01 Build 2108 - August 2021 (Canary)
* Fixed [#150](https://github.com/Krypton-Suite/Standard-Toolkit/issues/150)
- Make sure that the `NormalPanel` is the default style
- Also Fixed the WrapLabel Style not being set correctly
* Fixed [#202](https://github.com/Krypton-Suite/Standard-Toolkit/issues/202), `KryptonGroup` transparency
* Remove the internal class Called `KryptonDataGridViewIconColumn` from design use [#27](https://github.com/Krypton-Suite/Standard-Toolkit/issues/27)
- Put back the removed `CLSCompliant` and `ComVisible` assembly flags for backwards compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#endregion


using System.ComponentModel;

namespace Krypton.Toolkit
{
/// <summary>
Expand Down Expand Up @@ -54,11 +56,12 @@ public class KryptonLabel : VisualSimpleBase, IContentValues
/// </summary>
public KryptonLabel()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
// The label cannot take the focus
SetStyle(ControlStyles.Selectable, false);

// Set default properties
_style = LabelStyle.NormalControl;
_style = LabelStyle.NormalPanel;
_useMnemonic = true;
_orientation = VisualOrientation.Top;
_target = null;
Expand All @@ -69,7 +72,7 @@ public KryptonLabel()
Values.TextChanged += OnLabelTextChanged;

// Create palette redirector
_paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
_paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel);

// Create the palette provider
StateCommon = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);
Expand Down Expand Up @@ -147,10 +150,7 @@ public override string Text
}

private bool ShouldSerializeText()
{
// Never serialize, let the label values serialize instead
return false;
}
=> false;

/// <summary>
/// Resets the Text property to its default value.
Expand Down Expand Up @@ -185,15 +185,23 @@ public virtual VisualOrientation Orientation
}
}

private bool ShouldSerializeOrientation()
=> (_orientation != VisualOrientation.Top);

private void ResetOrientation()
{
_orientation = VisualOrientation.Top;
}

/// <summary>
/// Gets and sets the label style.
/// </summary>
[Category("Visuals")]
[Description("Label style.")]
[DefaultValue(typeof(LabelStyle), "NormalPanel")]
public LabelStyle LabelStyle
{
get => _style;

set
{
if (_style != value)
Expand All @@ -205,15 +213,9 @@ public LabelStyle LabelStyle
}
}

private bool ShouldSerializeLabelStyle()
{
return (LabelStyle != LabelStyle.NormalControl);
}
private bool ShouldSerializeLabelStyle() => (LabelStyle != LabelStyle.NormalPanel);

private void ResetLabelStyle()
{
LabelStyle = LabelStyle.NormalControl;
}
private void ResetLabelStyle() => LabelStyle = LabelStyle.NormalPanel;

/// <summary>
/// Gets access to the label content.
Expand All @@ -223,10 +225,7 @@ private void ResetLabelStyle()
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public LabelValues Values { get; }

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

/// <summary>
/// Gets access to the common label appearance that other states can override.
Expand All @@ -236,10 +235,7 @@ private bool ShouldSerializeValues()
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PaletteContent StateCommon { get; }

private bool ShouldSerializeStateCommon()
{
return !StateCommon.IsDefault;
}
private bool ShouldSerializeStateCommon() => !StateCommon.IsDefault;

/// <summary>
/// Gets access to the disabled label appearance entries.
Expand All @@ -249,10 +245,7 @@ private bool ShouldSerializeStateCommon()
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PaletteContent StateDisabled { get; }

private bool ShouldSerializeStateDisabled()
{
return !StateDisabled.IsDefault;
}
private bool ShouldSerializeStateDisabled() => !StateDisabled.IsDefault;

/// <summary>
/// Gets access to the normal label appearance entries.
Expand All @@ -262,10 +255,7 @@ private bool ShouldSerializeStateDisabled()
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PaletteContent StateNormal { get; }

private bool ShouldSerializeStateNormal()
{
return !StateNormal.IsDefault;
}
private bool ShouldSerializeStateNormal() => !StateNormal.IsDefault;

/// <summary>
/// Gets or sets a value indicating whether an ampersand is included in the text of the control.
Expand Down Expand Up @@ -367,10 +357,7 @@ public virtual void SetFixedState(PaletteState state)
/// </summary>
/// <param name="state">The state for which the image is needed.</param>
/// <returns>Image value.</returns>
public Image GetImage(PaletteState state)
{
return KryptonCommand?.ImageSmall ?? Values.GetImage(state);
}
public Image GetImage(PaletteState state) => KryptonCommand?.ImageSmall ?? Values.GetImage(state);

/// <summary>
/// Gets the image color that should be transparent.
Expand All @@ -395,10 +382,7 @@ public Image GetImage(PaletteState state)
/// Update the view elements based on the requested label style.
/// </summary>
/// <param name="style">New label style.</param>
protected virtual void SetLabelStyle(LabelStyle style)
{
_paletteCommonRedirect.Style = CommonHelper.ContentStyleFromLabelStyle(style);
}
protected virtual void SetLabelStyle(LabelStyle style) => _paletteCommonRedirect.Style = CommonHelper.ContentStyleFromLabelStyle(style);

/// <summary>
/// Processes a mnemonic character.
Expand All @@ -417,7 +401,7 @@ protected override bool ProcessMnemonic(char charCode)
if (EnabledTarget)
{
// Do we have a target that can take the focus
if ((Target != null) && Target.CanFocus)
if (Target is { CanFocus: true })
{
Target.Focus();
return true;
Expand All @@ -440,7 +424,7 @@ protected override void OnClick(EventArgs e)
if (EnabledTarget)
{
// Do we have a target that can take the focus
if ((Target != null) && Target.CanFocus)
if (Target is { CanFocus: true })
{
Target.Focus();
}
Expand Down Expand Up @@ -523,10 +507,7 @@ protected override bool EvalTransparentPaint()
#endregion

#region Implementation
private void OnLabelTextChanged(object sender, EventArgs e)
{
OnTextChanged(EventArgs.Empty);
}
private void OnLabelTextChanged(object sender, EventArgs e) => OnTextChanged(EventArgs.Empty);
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public KryptonWrapLabel()
_redirector = CreateRedirector();

// Default properties
SetLabelStyle(LabelStyle.NormalControl);
SetLabelStyle(LabelStyle.NormalPanel);
AutoSize = true;
TabStop = false;
}
Expand Down Expand Up @@ -242,6 +242,7 @@ public override bool AutoSize
/// </summary>
[Category("Visuals")]
[Description("Label style.")]
[DefaultValue(typeof(LabelStyle), "NormalPanel")]
public LabelStyle LabelStyle
{
get => _labelStyle;
Expand All @@ -257,9 +258,9 @@ public LabelStyle LabelStyle
}
}

private bool ShouldSerializeLabelStyle() => (LabelStyle != LabelStyle.NormalControl);
private bool ShouldSerializeLabelStyle() => (LabelStyle != LabelStyle.NormalPanel);

private void ResetLabelStyle() => LabelStyle = LabelStyle.NormalControl;
private void ResetLabelStyle() => LabelStyle = LabelStyle.NormalPanel;

/// <summary>
/// Gets or sets the palette to be applied.
Expand Down Expand Up @@ -620,19 +621,13 @@ protected override void OnPaintBackground(PaintEventArgs pEvent)
/// Create the redirector instance.
/// </summary>
/// <returns>PaletteRedirect derived class.</returns>
private PaletteRedirect CreateRedirector()
{
return new PaletteRedirect(_palette);
}
private PaletteRedirect CreateRedirector() => new PaletteRedirect(_palette);

/// <summary>
/// Update the view elements based on the requested label style.
/// </summary>
/// <param name="style">New label style.</param>
private void SetLabelStyle(LabelStyle style)
{
_labelContentStyle = CommonHelper.ContentStyleFromLabelStyle(style);
}
private void SetLabelStyle(LabelStyle style) => _labelContentStyle = CommonHelper.ContentStyleFromLabelStyle(style);

/// <summary>
/// Update global event attachments.
Expand Down

0 comments on commit ed0580e

Please sign in to comment.