Skip to content

Commit

Permalink
Merge pull request #1177 from Krypton-Suite/master-v80-patch-1
Browse files Browse the repository at this point in the history
* V80 Patch 1
  • Loading branch information
Smurf-IV authored Nov 18, 2023
2 parents 911b54b + d38d96f commit 4c38c84
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 327 deletions.
8 changes: 8 additions & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

=======

## 2023-11-17 - Build 2311 (Patch 1) - November 2023
* Resolved issue where an assertion is made when using `KryptonThemeComboBox` or `KryptonRibbonGroupThemeComboBox`
* Resolved issue where `Sparkle` themes would crash when using certain `ButtonSpecs`
* Resolved [#1174](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1174), Unable to adjust height of `KryptonForm` when `KryptonRibbon` is added
- _Note:_ This disables features from [#1117](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1117), until further testing is completed

=======

## 2023-11-14 - Build 2311 - November 2023
* Implemented [#1117](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1117), Is it possible to have the KForm back colour as the KPanel colour
* Resolved [#1153](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1153), Whilst investigating #1152 found that "Start drag" in certain application causes an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,48 @@ namespace Krypton.Ribbon
public class KryptonRibbonGroupThemeComboBox : KryptonRibbonGroupComboBox
{
#region Instance Fields

private int _selectedIndex;

private readonly int _defaultPaletteIndex = (int)PaletteMode.Microsoft365Blue;

private PaletteMode _defaultPalette;

#endregion

#region Public

/// <summary>Gets or sets the default palette mode.</summary>
/// <value>The default palette mode.</value>
[Category(@"Visuals")]
[Description(@"The default palette mode.")]
[DefaultValue(PaletteMode.Microsoft365Blue)]
public PaletteMode DefaultPalette
{
get => _defaultPalette;
set
{
_defaultPalette = value;
UpdateDefaultPaletteIndex(value);
}
}

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

set => SelectedIndex = value;
private set => SelectedIndex = value;
}

private void ResetThemeSelectedIndex() => _selectedIndex = 33;
private void ResetThemeSelectedIndex() => _selectedIndex = (int)PaletteMode.Microsoft365Blue;

private bool ShouldSerializeThemeSelectedIndex() => _selectedIndex != 33;
private bool ShouldSerializeThemeSelectedIndex() => _selectedIndex != (int)PaletteMode.Microsoft365Blue;

/// <summary>
/// Gets and sets the ThemeSelectedIndex.
Expand Down Expand Up @@ -75,14 +96,18 @@ public KryptonRibbonGroupThemeComboBox()
}
var cnvtr = new PaletteModeConverter();
Text = cnvtr.ConvertToString(PaletteMode.Microsoft365Blue)!;
_selectedIndex = SelectedIndex;
Debug.Assert(_selectedIndex == 33, "Microsoft365Blue needs to be at the 33rd index for backward compatibility");

_selectedIndex = SelectedIndex = _defaultPaletteIndex;
_defaultPalette = PaletteMode.Microsoft365Blue;
Debug.Assert(_selectedIndex == _defaultPaletteIndex, $@"Microsoft365Blue needs to be at the index position of {_defaultPaletteIndex} for backward compatibility");
}

#endregion

#region Implementation

private void UpdateDefaultPaletteIndex(PaletteMode mode) => _selectedIndex = (int)mode;

/// <summary>Returns the palette mode.</summary>
/// <returns>
/// <br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ public KryptonForm()
#pragma warning disable CS0618
_useDropShadow = false;
#pragma warning restore CS0618

BackStyle = PaletteBackStyle.PanelClient;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,47 @@ public class KryptonThemeComboBox : KryptonComboBox

private int _selectedIndex;

private readonly int _defaultPaletteIndex = (int)PaletteMode.Microsoft365Blue;

private PaletteMode _defaultPalette;

#endregion

#region Public

/// <summary>Gets or sets the default palette mode.</summary>
/// <value>The default palette mode.</value>
[Category(@"Visuals")]
[Description(@"The default palette mode.")]
[DefaultValue(PaletteMode.Microsoft365Blue)]
public PaletteMode DefaultPalette
{
get => _defaultPalette;

set
{
_defaultPalette = value;

UpdateDefaultPaletteIndex(value);
}
}

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

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

private void ResetThemeSelectedIndex() => _selectedIndex = 33;
private void ResetThemeSelectedIndex() => _selectedIndex = _defaultPaletteIndex;

private bool ShouldSerializeThemeSelectedIndex() => _selectedIndex != 33;
private bool ShouldSerializeThemeSelectedIndex() => _selectedIndex != _defaultPaletteIndex;

/// <summary>
/// Gets and sets the ThemeSelectedIndex.
Expand Down Expand Up @@ -69,13 +90,18 @@ public KryptonThemeComboBox()
Items.Add(kvp.Key);
}
Text = ThemeManager.ReturnPaletteModeAsString(PaletteMode.Microsoft365Blue);
_selectedIndex = SelectedIndex;
Debug.Assert(_selectedIndex == 33, "Microsoft365Blue needs to be at the 33rd index for backward compatibility");
_selectedIndex = SelectedIndex = _defaultPaletteIndex;

_defaultPalette = PaletteMode.Microsoft365Blue;

Debug.Assert(_selectedIndex == _defaultPaletteIndex, $@"Microsoft365Blue needs to be at the index position of {_defaultPaletteIndex} for backward compatibility");
}
#endregion

#region Implementation

private void UpdateDefaultPaletteIndex(PaletteMode mode) => ThemeSelectedIndex = (int)mode + 1;

/// <summary>Returns the palette mode.</summary>
/// <returns>
/// <br />
Expand Down Expand Up @@ -165,6 +191,10 @@ public override string Text
set => base.AutoCompleteCustomSource = value;
}

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new int SelectedIndex { get => base.SelectedIndex; set => base.SelectedIndex = value; }

#endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public abstract class VisualForm : Form,
private const int DEFAULT_COMPOSITION_HEIGHT = 30;
private static readonly bool _themedApp;
private readonly PaletteDoubleRedirect _stateCommon;
private readonly PaletteContentInheritRedirect ItemShortcutTextRedirect;
private readonly PaletteContentJustShortText ItemShortcutText;

#endregion

Expand Down Expand Up @@ -107,8 +105,6 @@ public VisualForm()
{
InitializeComponent();

base.DoubleBuffered = true;

// Automatically redraw whenever the size of the window changes
SetStyle(ControlStyles.ResizeRedraw, true);

Expand Down Expand Up @@ -136,9 +132,6 @@ public VisualForm()
_stateCommon = new PaletteDoubleRedirect(Redirector, PaletteBackStyle.ButtonCustom1,
PaletteBorderStyle.ButtonCustom1, NeedPaintDelegate);

ItemShortcutTextRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel);
ItemShortcutText = new PaletteContentJustShortText(ItemShortcutTextRedirect, NeedPaintDelegate);

// Hook into global static events
KryptonManager.GlobalPaletteChanged += OnGlobalPaletteChanged;
SystemEvents.UserPreferenceChanged += OnUserPreferenceChanged;
Expand Down Expand Up @@ -192,120 +185,6 @@ protected override void Dispose(bool disposing)

#region Public

/// <inheritdoc />
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
protected override bool DoubleBuffered
{
get => true;
set
{
// Do Nothing
}
}

/// <inheritdoc />
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Color BackColor
{
get
{
Color rawBackColor = _stateCommon.Back.GetBackColor1(Enabled ? PaletteState.Disabled : PaletteState.Normal);
return !rawBackColor.IsEmpty ? rawBackColor : Control.DefaultBackColor;
}
set
{
//Do Nothing;
}
}

/// <inheritdoc />
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[AmbientValue(null)]
public override Font Font
{
get => ItemShortcutText.GetContentShortTextFont(Enabled ? PaletteState.Disabled : PaletteState.Normal);
set
{
//Do Nothing;
}
}

/// <inheritdoc />
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Color ForeColor
{
get => ItemShortcutText.GetContentShortTextColor1(Enabled ? PaletteState.Disabled : PaletteState.Normal);
set
{
//Do Nothing;
}
}

/// <inheritdoc />
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[DefaultValue(null)]
public override Image? BackgroundImage
{
get => _stateCommon.Back.GetBackImage(Enabled ? PaletteState.Disabled : PaletteState.Normal);
set
{
//Do Nothing;
}
}
/// <inheritdoc />
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[DefaultValue(ImageLayout.Tile)]
public override ImageLayout BackgroundImageLayout
{
get
{
return _stateCommon.Back.GetBackImageStyle(Enabled ? PaletteState.Disabled : PaletteState.Normal) switch
{
PaletteImageStyle.TopMiddle => ImageLayout.Center,
PaletteImageStyle.CenterLeft => ImageLayout.Center,
PaletteImageStyle.CenterMiddle => ImageLayout.Center,
PaletteImageStyle.CenterRight => ImageLayout.Center,
PaletteImageStyle.Stretch => ImageLayout.Stretch,
PaletteImageStyle.Tile => ImageLayout.Tile,
_ => ImageLayout.None
};
}
set
{
//Do Nothing;
}
}

/// <summary>Sets the default panel backcolor source i.e. PanelClient.</summary>
[DefaultValue(typeof(PaletteBackStyle), @"PaletteBackStyle.PanelClient")]
[Description(@"Sets the default panel backcolor source i.e. PanelClient.")]
public PaletteBackStyle BackStyle
{
get => _stateCommon.BackStyle;

set
{
if (_stateCommon.BackStyle != value)
{
_stateCommon.BackStyle = value;

PerformNeedPaint(true);
}
}
}

/// <summary>
/// Gets the DpiX of the view.
/// </summary>
Expand Down Expand Up @@ -1205,13 +1084,6 @@ protected virtual void OnNeedPaint(object? sender, [DisallowNull] NeedLayoutEven
InvalidateNonClient();
}
}

// Force repaint of Background etc.
OnBackColorChanged(EventArgs.Empty);
OnBackgroundImageChanged(EventArgs.Empty);
OnBackgroundImageLayoutChanged(EventArgs.Empty);
OnFontChanged(EventArgs.Empty);
OnForeColorChanged(EventArgs.Empty);
}

/// <summary>
Expand Down
Loading

0 comments on commit 4c38c84

Please sign in to comment.