Skip to content

Commit 359cc75

Browse files
authored
Merge branch 'alpha' into 2492-bug-kryptonform-does-not-display-administrator-when-elevated
2 parents 12d7c5f + 1ab2b61 commit 359cc75

15 files changed

+529
-169
lines changed

Documents/Changelog/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## 2025-11-xx - Build 2511 (V10 - alpha) - November 2025
66
* Resolved [#2492](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2492), `KryptonForm` does not display '(Administrator)' when elevated
7+
* Resolved [#2495](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2495), `KryptonProgressBar` private field `_mementoContent` can be null.
78
* Resolved [#2490](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2490), `KryptonComboBox` uses an incorrect Items editor string.
89
* Resolved [#2487](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2487), `PaletteBase.PalettePaint` event is not synchronized toward the user.
910
* Implemented [#2446](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2446), Add `build.yml` to `.github/workflows`.

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonProgressBar.cs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public KryptonProgressBar()
131131
_textShadowColor = Color.Empty;
132132
_showTextBackdrop = false;
133133
_textBackdropColor = Color.Empty;
134+
135+
OnlayoutInternal();
134136
}
135137

136138
/// <inheritdoc />
@@ -679,26 +681,7 @@ protected override void OnEnabledChanged(EventArgs e)
679681
/// <inheritdoc />
680682
protected override void OnLayout(LayoutEventArgs e)
681683
{
682-
if (_palette != null)
683-
{
684-
// We want the inner part of the control to draw like a button.
685-
var (barPaletteState, barState) = GetBarPaletteState();
686-
687-
// Get the renderer associated with this palette
688-
IRenderer renderer = _palette.GetRenderer();
689-
690-
// Create a layout context used to allow the renderer to layout the content
691-
using var viewContext = new ViewLayoutContext(this, renderer);
692-
693-
// Cleanup resources by disposing of old memento instance
694-
_mementoContent?.Dispose();
695-
696-
// Ask the renderer to work out how the Content values will be laid out and
697-
// return a memento object that we cache for use when actually performing painting
698-
_mementoContent = renderer.RenderStandardContent.LayoutContent(viewContext, ClientRectangle, barPaletteState.PaletteContent!,
699-
this, Orientation, barState);
700-
}
701-
684+
OnlayoutInternal(e);
702685
base.OnLayout(e);
703686
}
704687

@@ -1060,6 +1043,29 @@ protected override void OnPaint(PaintEventArgs e)
10601043
#endregion
10611044

10621045
#region Implementation
1046+
private void OnlayoutInternal(LayoutEventArgs? e = null)
1047+
{
1048+
if (_palette != null)
1049+
{
1050+
// We want the inner part of the control to draw like a button.
1051+
var (barPaletteState, barState) = GetBarPaletteState();
1052+
1053+
// Get the renderer associated with this palette
1054+
IRenderer renderer = _palette.GetRenderer();
1055+
1056+
// Create a layout context used to allow the renderer to layout the content
1057+
using var viewContext = new ViewLayoutContext(this, renderer);
1058+
1059+
// Cleanup resources by disposing of old memento instance
1060+
_mementoContent?.Dispose();
1061+
1062+
// Ask the renderer to work out how the Content values will be laid out and
1063+
// return a memento object that we cache for use when actually performing painting
1064+
_mementoContent = renderer.RenderStandardContent.LayoutContent(viewContext, ClientRectangle, barPaletteState.PaletteContent!,
1065+
this, Orientation, barState);
1066+
}
1067+
}
1068+
10631069
// Find the correct state when getting ProgressBar values
10641070
private (IPaletteTriple barPaletteState, PaletteState barState) GetBarPaletteState()
10651071
{

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog/Elements/KryptonTaskDialogElementBase.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,16 @@ public KryptonTaskDialogElementBase(KryptonTaskDialogDefaults taskDialogDefaults
7575
#endregion
7676

7777
#region Protected
78-
protected void OnSizeChanged()
78+
/// <summary>
79+
/// Virtual method that invokes the SizeChanged event and notifies subscribers.
80+
/// </summary>
81+
/// <param name="performLayout">If a layout needs to be performed regardless of the element's visible state.</param>
82+
protected virtual void OnSizeChanged(bool performLayout = false)
7983
{
80-
SizeChanged?.Invoke();
84+
if (!performLayout)
85+
{
86+
SizeChanged?.Invoke();
87+
}
8188
}
8289
#endregion
8390

@@ -215,7 +222,7 @@ private void OnBackColorsChanged()
215222
}
216223
}
217224

218-
private void OnVisibleChanged()
225+
protected virtual void OnVisibleChanged()
219226
{
220227
VisibleChanged?.Invoke();
221228
}

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog/Elements/KryptonTaskDialogElementCheckBox.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,31 @@ public KryptonTaskDialogElementCheckBox(KryptonTaskDialogDefaults taskDialogDefa
2727

2828
_checkBox = new();
2929
_checkBox.AutoSize = true;
30-
_checkBox.Padding = new Padding(5, 0, 0, 0);
31-
_checkBox.Margin = _nullMargin;
30+
_checkBox.Padding = new Padding(Defaults.ComponentSpace, 0, 0, 0);
31+
_checkBox.Margin = Defaults.NullMargin;
3232
_checkBox.CheckState = CheckState.Unchecked;
3333

3434
_tlp.Controls.Add(_checkBox, 0, 0);
3535

3636
LayoutDirty = true;
3737
}
3838

39-
#region Private
40-
#endregion
41-
private void OnSizeChanged(bool performLayout = false)
39+
#region Protected/Internal
40+
/// <inheritdoc/>
41+
protected override void OnSizeChanged(bool performLayout = false)
4242
{
4343
// Updates / changes are deferred if the element is not visible or until PerformLayout is called
4444
if (LayoutDirty && (Visible || performLayout))
4545
{
4646
Panel.Height = _checkBox.Height + Defaults.PanelTop + Defaults.PanelBottom;
4747

48-
if (!performLayout)
49-
{
50-
base.OnSizeChanged();
51-
}
48+
base.OnSizeChanged(performLayout);
5249

5350
LayoutDirty = false;
54-
5551
}
5652
}
5753

58-
#region Protected/Internal
54+
/// <inheritdoc/>
5955
protected override void OnPalettePaint(object? sender, PaletteLayoutEventArgs e)
6056
{
6157
base.OnPalettePaint(sender, e);
@@ -69,6 +65,7 @@ protected override void OnPalettePaint(object? sender, PaletteLayoutEventArgs e)
6965
}
7066
}
7167

68+
/// <inheritdoc/>
7269
internal override void PerformLayout()
7370
{
7471
base.PerformLayout();

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog/Elements/KryptonTaskDialogElementComboBox.cs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ public KryptonTaskDialogElementComboBox(KryptonTaskDialogDefaults taskDialogDefa
6161
#endregion
6262

6363
#region Override
64+
/// <inheritdoc/>
65+
protected override void OnSizeChanged(bool performLayout = false)
66+
{
67+
if (LayoutDirty && (Visible || performLayout))
68+
{
69+
int height = ShowDescription
70+
? _description.Height + _description.Margin.Bottom :
71+
0;
72+
73+
Panel.Height = Defaults.PanelTop + Defaults.PanelBottom + _comboBox.Height + height;
74+
75+
base.OnSizeChanged(performLayout);
76+
77+
LayoutDirty = false;
78+
}
79+
}
80+
6481
/// <inheritdoc/>
6582
internal override void PerformLayout()
6683
{
@@ -182,7 +199,7 @@ private void SetupPanel()
182199
{
183200
// the description that goes with the combobox
184201
_description.AutoSize = true;
185-
_description.Padding = _nullPadding;
202+
_description.Padding = Defaults.NullPadding;
186203
_description.Margin = new(0, 0, 0, Defaults.ComponentSpace);
187204

188205
_comboBox.AutoSize = true;
@@ -206,25 +223,6 @@ private void OnComboBoxSizeChanged(object? sender, EventArgs e)
206223
OnSizeChanged();
207224
}
208225

209-
private void OnSizeChanged(bool performLayout = false)
210-
{
211-
if (LayoutDirty && (Visible || performLayout))
212-
{
213-
int height = ShowDescription
214-
? _description.Height + _description.Margin.Bottom :
215-
0;
216-
217-
Panel.Height = Defaults.PanelTop + Defaults.PanelBottom + _comboBox.Height + height;
218-
219-
if (!performLayout)
220-
{
221-
base.OnSizeChanged();
222-
}
223-
224-
LayoutDirty = false;
225-
}
226-
}
227-
228226
private void OnSelectedIndexChanged(object? sender, EventArgs e)
229227
{
230228
// Only fire if the dialog is visible

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog/Elements/KryptonTaskDialogElementCommonButtons.cs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ private void UpdateButtonSize()
8080
}
8181

8282
#region Protected/Internal
83+
/// <inheritdoc/>
84+
protected override void OnSizeChanged(bool performLayout = false)
85+
{
86+
// Updates / changes are deferred if the element is not visible or until PerformLayout is called
87+
if (LayoutDirty && (Visible || performLayout))
88+
{
89+
// Button size is set through UpdateButtonSize() called from the constructor and OnPalettePaint.
90+
Panel.Height = _btnOk.Height + Defaults.PanelTop + Defaults.PanelBottom;
91+
92+
// Done
93+
LayoutDirty = false;
94+
95+
// Tell everybody about it when visible.
96+
base.OnSizeChanged(performLayout);
97+
}
98+
}
99+
83100
/// <inheritdoc/>
84101
protected override void OnPalettePaint(object? sender, PaletteLayoutEventArgs e)
85102
{
@@ -181,25 +198,6 @@ public KryptonTaskDialogCommonButtonTypes CancelButton
181198
#endregion
182199

183200
#region Private
184-
private void OnSizeChanged(bool performLayout = false)
185-
{
186-
// Updates / changes are deferred if the element is not visible or until PerformLayout is called
187-
if (LayoutDirty && (Visible || performLayout))
188-
{
189-
// Button size is set through UpdateButtonSize() called from the constructor and OnPalettePaint.
190-
Panel.Height = _btnOk.Height + Defaults.PanelTop + Defaults.PanelBottom;
191-
192-
// Done
193-
LayoutDirty = false;
194-
195-
// Tell everybody about it when visible.
196-
if (!performLayout)
197-
{
198-
base.OnSizeChanged();
199-
}
200-
}
201-
}
202-
203201
private void SetupTableLayoutPanel()
204202
{
205203
_tlp = new()

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog/Elements/KryptonTaskDialogElementContent.cs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,31 @@ public KryptonTaskDialogElementContent(KryptonTaskDialogDefaults taskDialogDefau
5151
#endregion
5252

5353
#region Protected/Internal
54+
/// <inheritdoc/>
55+
protected override void OnSizeChanged(bool performLayout = false)
56+
{
57+
// Updates / changes are deferred if the element is not visible or until PerformLayout is called
58+
if (LayoutDirty && (Visible || performLayout))
59+
{
60+
Font font = _textControl.StateCommon.Font
61+
?? Palette.GetContentShortTextFont(PaletteContentStyle.LabelNormalControl, PaletteState.Normal)
62+
?? KryptonManager.CurrentGlobalPalette.BaseFont;
63+
64+
int height = TextRenderer.MeasureText(_textControl.Text, font, new SizeF(_textBoxWidth, float.MaxValue).ToSize(), textFormatFlags).Height;
65+
66+
// Controls seem to need a little help here to stay within the correct bounds
67+
Panel.Height = height + Defaults.PanelTop + Defaults.PanelBottom;
68+
_textControl.Width = _textBoxWidth - Defaults.PanelLeft - Defaults.PanelRight;
69+
_textControl.Height = height;
70+
71+
// Tell everybody about it when visible.
72+
base.OnSizeChanged(performLayout);
73+
74+
// Done
75+
LayoutDirty = false;
76+
}
77+
}
78+
5479
protected override void OnPalettePaint(object? sender, PaletteLayoutEventArgs e)
5580
{
5681
base.OnPalettePaint(sender, e);
@@ -64,12 +89,14 @@ protected override void OnPalettePaint(object? sender, PaletteLayoutEventArgs e)
6489
}
6590
}
6691

92+
/// <inheritdoc/>
6793
internal override void PerformLayout()
6894
{
6995
base.PerformLayout();
7096
OnSizeChanged(true);
7197
}
7298

99+
/// <inheritdoc/>
73100
public override bool Visible
74101
{
75102
get => base.Visible;
@@ -82,35 +109,6 @@ public override bool Visible
82109
}
83110
#endregion
84111

85-
#region Private
86-
private void OnSizeChanged(bool performLayout = false)
87-
{
88-
// Updates / changes are deferred if the element is not visible or until PerformLayout is called
89-
if (LayoutDirty && (Visible || performLayout))
90-
{
91-
Font font = _textControl.StateCommon.Font
92-
?? Palette.GetContentShortTextFont(PaletteContentStyle.LabelNormalControl, PaletteState.Normal)
93-
?? KryptonManager.CurrentGlobalPalette.BaseFont;
94-
95-
int height = TextRenderer.MeasureText(_textControl.Text, font, new SizeF(_textBoxWidth, float.MaxValue).ToSize(), textFormatFlags).Height;
96-
97-
// Controls seem to need a little help here to stay within the correct bounds
98-
Panel.Height = height + Defaults.PanelTop + Defaults.PanelBottom;
99-
_textControl.Width = _textBoxWidth - Defaults.PanelLeft - Defaults.PanelRight;
100-
_textControl.Height = height;
101-
102-
// Tell everybody about it when visible.
103-
if (!performLayout)
104-
{
105-
base.OnSizeChanged();
106-
}
107-
108-
// Done
109-
LayoutDirty = false;
110-
}
111-
}
112-
#endregion
113-
114112
#region Public
115113
/// <inheritdoc/>
116114
public string Text

Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonTaskDialog/Elements/KryptonTaskDialogElementContentTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ internal override void PerformLayout()
9595
OnSizeChanged(true);
9696
}
9797

98-
private void OnSizeChanged(bool performLayout = false)
98+
protected override void OnSizeChanged(bool performLayout = false)
9999
{
100100
if (Visible || performLayout)
101101
{
@@ -120,7 +120,7 @@ private void OnSizeChanged(bool performLayout = false)
120120
Panel.Height += _description.GetDesiredVisibility() ? height + _description.Margin.Top + _description.Margin.Bottom : 0;
121121

122122
//// Tell everybody about it
123-
base.OnSizeChanged();
123+
base.OnSizeChanged(performLayout);
124124
}
125125
}
126126

0 commit comments

Comments
 (0)