Skip to content

Commit 982f4bf

Browse files
authored
1376-V100-Extending-KryptonTaskDialog (#2519)
* 1376-V100-Extending-KryptonTaskDialog - Removes CommonButtons - Integrates CommonButtons in the FooterBar - Adds a separator to each element which can toggled. - Some housekeeping. * 1376-V100-Extending-KryptonTaskDialog - Removes CommonButtons - Integrates CommonButtons in the FooterBar - Adds a separator to each element which can toggled. - Some housekeeping. * 1376-V100-Extending-KryptonTaskDialog - Removes CommonButtons - Integrates CommonButtons in the FooterBar - Adds a separator to each element which can toggled. - Some housekeeping. * 1376-V100-Extending-KryptonTaskDialog - Removes CommonButtons - Integrates CommonButtons in the FooterBar - Adds a separator to each element which can toggled. - Some housekeeping. * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring * 1376-V100-Extending-KryptonTaskDialog - Added KryptonTaskDialogKryptonPanel which will be the standard panel for elements. - Moved the separator functionality into KryptonTaskDialogKryptonPanel. - Added the KryptonTaskDialogElementCommandLinkButtons element. - Added RoundedCorners to all elements that have controls supporting border rounding. - Added a global switch to toggle RoundedCorners for elements that implement it. - Added KryptonTaskDialogKryptonRichTextBox that contains an adaptation to suppress Enter key fowarding from the RichtTextBox to the form. - Added the KryptonTaskDialogElementRichTextBox element. - Some housekeeping and refactoring
1 parent d1ead18 commit 982f4bf

18 files changed

+1152
-169
lines changed

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

Lines changed: 8 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Krypton.Toolkit;
1414
/// Derived elements can be extended through the use of IKryptonTaskDialogElement interfaces to
1515
/// guarantee correct and consistent definitions and naming of properties and methods.
1616
///
17-
/// The IDisposable pattern has been implemented by default so derived classes can override and implement if required
17+
/// The IDisposable pattern has been implemented by default so derived classes can override and implement if required.
1818
/// </summary>
1919
public abstract class KryptonTaskDialogElementBase :
2020
IKryptonTaskDialogElementBase,
@@ -23,11 +23,9 @@ public abstract class KryptonTaskDialogElementBase :
2323
{
2424
#region Fields
2525
private bool _disposed;
26-
private KryptonPanel _panel;
26+
private KryptonTaskDialogKryptonPanel _panel;
2727
private bool _panelVisible;
2828
private KryptonTaskDialogDefaults _taskDialogDefaults;
29-
private Bitmap _separator;
30-
private (int FontMinValue, int FontMaxValue, int Adjust75, int Adjust50, int Adjust25) _separatorValues;
3129
#endregion
3230

3331
#region Events
@@ -52,31 +50,21 @@ public KryptonTaskDialogElementBase(KryptonTaskDialogDefaults taskDialogDefaults
5250
_taskDialogDefaults = taskDialogDefaults;
5351
_disposed = false;
5452

55-
_separatorValues.FontMinValue = 50;
56-
_separatorValues.FontMaxValue = 255 - 50;
57-
_separatorValues.Adjust75 = 75;
58-
_separatorValues.Adjust50 = 50;
59-
_separatorValues.Adjust25 = 25;
60-
6153
// Although OnGlobalPaletteChanged synchronizes palette changes with the elements,
62-
// The initialisation is done here.
54+
// The initialisation is done here
6355
Palette = KryptonManager.CurrentGlobalPalette;
6456
// From there the event handler will take over.
6557
KryptonManager.GlobalPaletteChanged += OnGlobalPaletteChanged;
6658

67-
_panel = new()
59+
_panel = new(_taskDialogDefaults)
6860
{
6961
Margin = _taskDialogDefaults.NullPadding,
7062
Padding = _taskDialogDefaults.NullMargin,
7163
Visible = false
72-
7364
};
7465

7566
_panelVisible = false;
76-
_separator = CreateSeparator();
77-
_panel.Paint += OnPanelPaint;
7867
Palette.PalettePaint += OnPalettePaint;
79-
8068
LayoutDirty = false;
8169
}
8270
#endregion
@@ -122,7 +110,6 @@ protected virtual void OnGlobalPaletteChanged(object? sender, EventArgs e)
122110
if (Palette is not null)
123111
{
124112
Palette.PalettePaint += OnPalettePaint;
125-
_separator = CreateSeparator();
126113
}
127114
}
128115
#endregion
@@ -203,16 +190,8 @@ public sealed override string ToString()
203190
/// </summary>
204191
public bool ShowSeparator
205192
{
206-
get => field;
207-
208-
set
209-
{
210-
if (field != value)
211-
{
212-
field = value;
213-
_panel.Invalidate();
214-
}
215-
}
193+
get => _panel.ShowSeparator;
194+
set => _panel.ShowSeparator = value;
216195
}
217196

218197
/// <summary>
@@ -221,7 +200,7 @@ public bool ShowSeparator
221200
internal bool LayoutDirty { get; set; }
222201

223202
/// <summary>
224-
/// Return the height of the element when visible.<br/>
203+
/// Returns the height of the element when visible.<br/>
225204
/// When not visible Height returns zero.
226205
/// </summary>
227206
public int Height => _panelVisible ? Panel.Height : 0;
@@ -231,11 +210,6 @@ public bool ShowSeparator
231210
#endregion
232211

233212
#region Private
234-
private void OnPanelPaint(object? sender, PaintEventArgs e)
235-
{
236-
PaintSeparator();
237-
}
238-
239213
private void OnBackColorsChanged()
240214
{
241215
if (BackColor1 != Color.Empty && BackColor2 != Color.Empty)
@@ -258,86 +232,13 @@ protected virtual void OnVisibleChanged()
258232
}
259233
#endregion
260234

261-
#region Private Separator
262-
private Bitmap CreateSeparator()
263-
{
264-
(Color color1, Color color2) colors = GetSeparatorColors();
265-
266-
int width = Defaults.ClientWidth - Defaults.PanelLeft - Defaults.PanelRight;
267-
Rectangle rectangle = new Rectangle(0, 0, width, 2);
268-
Rectangle rectangleTop = new Rectangle(0, 0, width, 1);
269-
Rectangle rectangleBottom = new Rectangle(0, 1, width, 1);
270-
271-
using Bitmap bitmap = new Bitmap(rectangle.Width, rectangle.Height);
272-
using Brush brush1 = new SolidBrush(colors.color1);
273-
using Brush brush2 = new SolidBrush(colors.color2);
274-
using Graphics graphics = Graphics.FromImage(bitmap);
275-
276-
graphics.FillRectangle(brush1, rectangleTop);
277-
graphics.FillRectangle(brush2, rectangleBottom);
278-
279-
return bitmap.Clone(rectangle, bitmap.PixelFormat);
280-
}
281-
282-
private void PaintSeparator()
283-
{
284-
if (ShowSeparator)
285-
{
286-
using Graphics graphics = Panel.CreateGraphics();
287-
graphics.DrawImage(_separator, Defaults.PanelLeft, 0);
288-
}
289-
}
290-
291-
private (Color, Color) GetSeparatorColors()
292-
{
293-
Color color1;
294-
Color color2;
295-
296-
// If BackColor1 has been set use this for the separator, otherwise fall back to theme colours.
297-
Color tmp = this.BackColor1 != Color.Empty
298-
? this.BackColor1
299-
: Panel.GetResolvedPalette().GetBackColor1(PaletteBackStyle.PanelClient, PaletteState.Normal);
300-
301-
if (tmp.R > _separatorValues.FontMaxValue && tmp.G > _separatorValues.FontMaxValue && tmp.B > _separatorValues.FontMaxValue)
302-
{
303-
// If the colour reaches an upper bound it can't be made lighter.
304-
color1 = Color.FromArgb(tmp.R - _separatorValues.Adjust75, tmp.G - _separatorValues.Adjust75, tmp.B - _separatorValues.Adjust75);
305-
color2 = Color.White;
306-
}
307-
else if (tmp.R < _separatorValues.FontMinValue && tmp.G < _separatorValues.FontMinValue && tmp.B < _separatorValues.FontMinValue)
308-
{
309-
// If the colour reaches a lower bound, it can't be made darker.
310-
color2 = ControlPaint.Light(tmp);
311-
color1 = ControlPaint.Light(Color.LightSlateGray);
312-
}
313-
else if (tmp.R > 150 && tmp.G > 150 && tmp.B > 150)
314-
{
315-
// Colours that are somewhere in the middle need different handling
316-
int r = Math.Min(tmp.R - _separatorValues.Adjust50, 255);
317-
int g = Math.Min(tmp.G - _separatorValues.Adjust50, 255);
318-
int b = Math.Min(tmp.B - _separatorValues.Adjust50, 255);
319-
320-
color1 = Color.FromArgb(r, g, b);
321-
color2 = Color.LightGray;
322-
}
323-
else
324-
{
325-
color1 = ControlPaint.Dark(tmp);
326-
color2 = ControlPaint.Light(tmp);
327-
}
328-
329-
return (color1, color2);
330-
}
331-
#endregion
332-
333235
#region IDispose
334236
/// <inheritdoc/>
335237
protected virtual void Dispose(bool disposing)
336238
{
337239
if (!_disposed && disposing)
338240
{
339241
KryptonManager.GlobalPaletteChanged -= OnGlobalPaletteChanged;
340-
_panel.Paint -= OnPanelPaint;
341242

342243
if (Palette is not null)
343244
{
@@ -358,3 +259,4 @@ public void Dispose()
358259
}
359260
#endregion
360261
}
262+

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
namespace Krypton.Toolkit;
1111

1212
public class KryptonTaskDialogElementComboBox : KryptonTaskDialogElementSingleLineControlBase,
13-
IKryptonTaskDialogElementDescription
13+
IKryptonTaskDialogElementDescription,
14+
IKryptonTaskDialogElementRoundedCorners
1415
{
1516
#region Enum
1617
// Used internally only
@@ -57,6 +58,15 @@ public KryptonTaskDialogElementComboBox(KryptonTaskDialogDefaults taskDialogDefa
5758
}
5859
#endregion
5960

61+
public bool RoundedCorners
62+
{
63+
get => field;
64+
set
65+
{
66+
field = value;
67+
_comboBox.StateCommon.ComboBox.Border.Rounding = Defaults.GetCornerRouding(value);
68+
}
69+
}
6070
#region Override
6171
/// <inheritdoc/>
6272
protected override void OnSizeChanged(bool performLayout = false)

0 commit comments

Comments
 (0)