Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the display of the initial selected theme in the "ThemeSelection ComboBox" #879

Merged
merged 3 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
=======

## 2023-11-xx - Build 2311 - November 2023
* 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
* Implemented [#866](https://github.com/Krypton-Suite/Standard-Toolkit/issues/866), `KryptonMessageBox` Option to use system icons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,7 @@ public void Reset()
[KryptonPersist(false, false)]
[Category(@"Visuals")]
[Description(@"Base palette used to inherit from.")]
[DefaultValue(typeof(PaletteMode), "Office365Blue")]
[DefaultValue(typeof(PaletteMode), "Microsoft365Blue")]
public PaletteMode BasePaletteMode
{
get => _basePaletteMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,33 @@ public class KryptonThemeComboBox : KryptonComboBox
{
#region Instance Fields
private readonly List<string> _supportedThemesList;

private int _selectedIndex;

private PaletteModeManager _paletteModeManager;
#endregion

#region Properties

[EditorBrowsable(EditorBrowsableState.Never)]
public List<string> SupportedThemesList => _supportedThemesList;

[DefaultValue(22)]
/// <summary>
/// Gets and sets the ThemeSelectedIndex.
/// </summary>
[Category(@"Visuals")]
[Description(@"Theme Selected Index. (Default = `Office 365 - Blue`)")]
[DefaultValue(25)]
public int ThemeSelectedIndex
{
get => _selectedIndex;

set => _selectedIndex = value;
set => SelectedIndex = value;
}

private void ResetThemeSelectedIndex() => _selectedIndex = 25;

private bool ShouldSerializeThemeSelectedIndex() => _selectedIndex != 25;


[EditorBrowsable(EditorBrowsableState.Never)]
public KryptonManager Manager
{
get;
Expand All @@ -53,9 +62,8 @@ public KryptonThemeComboBox()
{
DropDownStyle = ComboBoxStyle.DropDownList;

ThemeSelectedIndex = 22;

_supportedThemesList = ThemeManager.PropagateSupportedThemeList();
_selectedIndex = 25;
}
#endregion

Expand All @@ -73,17 +81,9 @@ public KryptonThemeComboBox()

protected override void OnCreateControl()
{
if (!DesignMode)
{
Items.AddRange(ThemeManager.ReturnThemeArray());
}

Text = Manager.GlobalPaletteMode.ToString();


_paletteModeManager = Manager.GlobalPaletteMode;

base.OnCreateControl();
Items.AddRange(ThemeManager.ReturnThemeArray());
SelectedIndex = _selectedIndex;
}

protected override void OnSelectedIndexChanged(EventArgs e)
Expand All @@ -96,5 +96,59 @@ protected override void OnSelectedIndexChanged(EventArgs e)
}

#endregion

#region Removed Designer visibility
/// <summary>
/// Gets and sets the text associated associated with the control.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override string Text
{
get => base.Text;
set => base.Text = value;
}

/// <summary>
/// Gets and sets the appearance and functionality of the KryptonComboBox.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new ComboBoxStyle DropDownStyle
{
get => base.DropDownStyle;
set => base.DropDownStyle = value;
}

/// <summary>
/// Gets or sets the items in the KryptonComboBox.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new ComboBox.ObjectCollection Items => base.Items;

/// <summary>Gets or sets the draw mode of the combobox.</summary>
/// <value>The draw mode of the combobox.</value>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new DrawMode DrawMode
{
get => base.DrawMode;
set => base.DrawMode = value;
}

/// <summary>
/// Gets or sets the StringCollection to use when the AutoCompleteSource property is set to CustomSource.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new AutoCompleteStringCollection AutoCompleteCustomSource
{
get => base.AutoCompleteCustomSource;
set => base.AutoCompleteCustomSource = value;
}

#endregion
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public OperationThread(Operation op, object parameter)
/// </summary>
public int State
{
get
get
{
int ret;

Expand All @@ -54,7 +54,7 @@ public int State
ret = _state;
}

return ret;
return ret;
}
}

Expand Down Expand Up @@ -82,18 +82,18 @@ public void Run()
Result = _op(_parameter);

// Success
lock(this)
lock (this)
{
_state = 1;
}
}
catch(Exception ex)
catch (Exception ex)
{
// Remember the exception details
Exception = ex;

// Failed with exception
lock(this)
lock (this)
{
_state = 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public PaletteCueHintText(PaletteRedirect redirect,
NeedPaintHandler needPaint)
: base(new PaletteContentInheritRedirect(redirect, PaletteContentStyle.InputControlStandalone), needPaint)
{
_padding = Padding.Empty;
_shortTextV = PaletteRelativeAlign.Center;
_shortTextH = PaletteRelativeAlign.Near;
_contentTextHint = PaletteTextHint.AntiAlias;
}

Expand Down Expand Up @@ -58,7 +56,7 @@ public PaletteCueHintText(PaletteRedirect redirect,
[KryptonPersist(false)]
[Category(@"Visuals")]
[Description(@"Text rendering hint for the content text. (No `Inherit`)")]
[DefaultValue(typeof(PaletteTextHint), "AntiAlias")]
[DefaultValue(PaletteTextHint.AntiAlias)]
[RefreshProperties(RefreshProperties.All)]
public virtual PaletteTextHint Hint
{
Expand All @@ -74,20 +72,17 @@ public virtual PaletteTextHint Hint
}
}

private bool ShouldSerializeHint() => _contentTextHint != PaletteTextHint.Inherit;
private bool ShouldSerializeHint() => _contentTextHint != PaletteTextHint.AntiAlias;

/// <summary>
/// Resets the Image property to its default value.
/// </summary>
private void ResetHint() => _contentTextHint = PaletteTextHint.Inherit;
private void ResetHint() => _contentTextHint = PaletteTextHint.AntiAlias;

#endregion

public override bool IsDefault =>
(Font == null) &&
(Color1 == Color.Empty) &&
Padding.Equals(Padding.Empty) // <- This is not the same as the base
&& (TextH == PaletteRelativeAlign.Near) // <- This is not the same as the base
/// <inheritdoc/>
public override bool IsDefault => base.IsDefault
&& string.IsNullOrWhiteSpace(CueHintText)
&& (_shortTextV == PaletteRelativeAlign.Center)
&& !ShouldSerializeHint();
Expand Down Expand Up @@ -119,7 +114,7 @@ public override Font GetContentShortTextNewFont(PaletteState state)
/// </summary>
/// <param name="state">Palette value should be applicable to this state.</param>
/// <returns>Color value.</returns>
public new Color GetContentShortTextColor1(PaletteState state) => Color1 != Color.Empty ? Color1 : ControlPaint.Light(Inherit.GetContentShortTextColor1(state));
public new Color GetContentShortTextColor1(PaletteState state) => !Color1.IsEmpty ? Color1 : ControlPaint.Light(Inherit.GetContentShortTextColor1(state));

internal void PerformPaint(VisualControlBase textBox, Graphics g, PI.RECT rect, SolidBrush backBrush)
{
Expand Down Expand Up @@ -202,66 +197,13 @@ public PaletteRelativeAlign TextV

private void ResetTextV() => _shortTextV = PaletteRelativeAlign.Center;

/// <summary>
/// Gets and sets the horizontal Content text alignment for the text.
/// </summary>
[KryptonPersist(false)]
[Category(@"Visuals")]
[Description(@"Relative horizontal Content text alignment")]
[RefreshProperties(RefreshProperties.All)]
[DefaultValue(PaletteRelativeAlign.Near)]
public override PaletteRelativeAlign TextH
{
get => _shortTextH;

set
{
if (value != _shortTextH)
{
_shortTextH = value;
PerformNeedPaint();
}
}
}
private bool ShouldSerializeTextH() => _shortTextH != PaletteRelativeAlign.Near;

private void ResetTextH() => _shortTextH = PaletteRelativeAlign.Near;

/// <summary>
/// Gets the actual content short text vertical alignment value.
/// </summary>
/// <param name="state">Palette value should be applicable to this state.</param>
/// <returns>RelativeAlignment value.</returns>
public override PaletteRelativeAlign GetContentShortTextV(PaletteState state) => _shortTextV != PaletteRelativeAlign.Inherit ? _shortTextH : Inherit.GetContentShortTextV(state);

#endregion

#region Padding
/// <summary>
/// Gets the padding between the border and content drawing.
/// </summary>
[KryptonPersist(false)]
[Category(@"Visuals")]
[Description(@"Padding between the border and content drawing.")]
[DefaultValue(typeof(Padding), "0")]
public new Padding Padding
{
get => _padding;

set
{
if (!value.Equals(_padding))
{
_padding = value;
PerformNeedPaint(true);
}
}
}

private bool ShouldSerializePadding() => !_padding.Equals(Padding.Empty);

private void ResetPadding() => _padding = Padding.Empty;

// Use the base class
//protected virtual Padding GetContentPadding(PaletteState state) => !_padding.Equals(CommonHelper.InheritPadding) ? _padding : Inherit.GetContentPadding(state);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public PaletteInputControlContentStates(IPaletteContent inherit,
/// </summary>
[Browsable(false)]
public override bool IsDefault => (Font == null) &&
(Color1 == Color.Empty) &&
(Color1.IsEmpty) &&
Padding.Equals(CommonHelper.InheritPadding)
&& (TextH == PaletteRelativeAlign.Inherit)
;
Expand Down Expand Up @@ -213,7 +213,7 @@ public virtual Font Font
[Description(@"Relative horizontal Content text alignment\nIn order to get this into the designer.cs you must also modify another value in this area!")]
[RefreshProperties(RefreshProperties.All)]
[DefaultValue(PaletteRelativeAlign.Inherit)]
public virtual PaletteRelativeAlign TextH
public PaletteRelativeAlign TextH
{
get => _shortTextH;

Expand Down Expand Up @@ -286,7 +286,7 @@ public virtual Color Color1
/// </summary>
/// <param name="state">Palette value should be applicable to this state.</param>
/// <returns>Color value.</returns>
public Color GetContentShortTextColor1(PaletteState state) => _color1 != Color.Empty ? _color1 : Inherit.GetContentShortTextColor1(state);
public Color GetContentShortTextColor1(PaletteState state) => !_color1.IsEmpty ? _color1 : Inherit.GetContentShortTextColor1(state);

/// <summary>
/// Gets the second back color for the short text.
Expand Down