Skip to content

Commit 4c83984

Browse files
committed
- Make all controls follow MinHeight of 30 (Apart from Min Trackbar :-)
#615
1 parent 1d181cb commit 4c83984

23 files changed

+95
-32
lines changed

Source/.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ dotnet_diagnostic.CS8073.severity = None
4949
dotnet_diagnostic.CS8618.severity = None
5050

5151
#Warning CS8622 Nullability of reference types in type of parameter 'sender' of ####
52-
dotnet_diagnostic.CS8622.severity = None
52+
#dotnet_diagnostic.CS8622.severity = None
5353

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

+6
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ private int InnerArrayIndexOfIdentifier(object? identifier, int stateMask)
161161
}
162162

163163
#endregion
164+
164165
}
165166

166167
/// <summary>
@@ -525,6 +526,11 @@ public void RefreshItemSizes()
525526
#endregion
526527

527528
#region Protected
529+
530+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
531+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
532+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
533+
528534
/// <summary>
529535
/// Creates a new instance of the item collection.
530536
/// </summary>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public KryptonColorButton()
123123
AutoRecentColors = true;
124124
SchemeThemes = ColorScheme.OfficeThemes;
125125
SchemeStandard = ColorScheme.OfficeStandard;
126-
_selectedRect = new Rectangle(0, 12, 16, 4);
126+
_selectedRect = new Rectangle(0, 12, 16, 6);
127127
_selectedColor = Color.Red;
128128
_emptyBorderColor = Color.DarkGray;
129129
DialogResult = DialogResult.None;
@@ -1504,7 +1504,7 @@ private void SetCustomColorPreviewShape(KryptonColorButtonCustomColorPreviewShap
15041504

15051505
Values.RoundedCorners = 0;
15061506

1507-
Values.SelectedRect = new Rectangle(0, 12, 16, 4);
1507+
Values.SelectedRect = new Rectangle(0, 12, 16, 6);
15081508
break;
15091509
case KryptonColorButtonCustomColorPreviewShape.Circle:
15101510
Values.Image = GenericImageResources.Transparent_16_x_16;

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ public InternalComboBox(KryptonComboBox kryptonComboBox)
135135
{
136136
// Remember incoming reference
137137
_kryptonComboBox = kryptonComboBox;
138-
139138
// Remove from view until size for the first time by the Krypton control
140139
ItemHeight = 15;
141140
DropDownHeight = 200;
@@ -212,6 +211,10 @@ public bool MouseOver
212211
#endregion
213212

214213
#region Protected
214+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
215+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
216+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
217+
215218
protected override void OnEnabledChanged(EventArgs e)
216219
{
217220
// Do not forward, to allow the correct Background for disabled state
@@ -1143,11 +1146,10 @@ public KryptonComboBox()
11431146

11441147
// Create the element that fills the remainder space and remembers fill rectangle
11451148
_layoutFill = new ViewLayoutFill(_comboHolder);
1146-
11471149
// Create inner view for placing inside the drawing docker
11481150
_drawDockerInner = new ViewLayoutDocker
11491151
{
1150-
{ _layoutFill, ViewDockStyle.Fill }
1152+
{ _layoutFill, ViewDockStyle.Bottom } // Make it better when drawing smaller font than MinHeight
11511153
};
11521154

11531155
// Create view for the control border and background
@@ -2161,7 +2163,7 @@ public void DesignerMouseLeave() =>
21612163
OnMouseLeave(EventArgs.Empty);
21622164

21632165
/// <summary>Gets or sets the height and width of the control.</summary>
2164-
[DefaultValue(typeof(Size), "121, 21")]
2166+
[DefaultValue(typeof(Size), "121, 30")]
21652167
public new Size Size
21662168
{
21672169
get => base.Size;

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

+15-7
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public InternalDomainUpDown(KryptonDomainUpDown kryptonDomainUpDown)
5757

5858
// Remove from view until size for the first time by the Krypton control
5959
Size = Size.Empty;
60-
6160
// We provide the border manually
6261
BorderStyle = BorderStyle.None;
62+
Padding = Padding.Empty;
6363
}
6464
#endregion
6565

@@ -93,6 +93,16 @@ public bool MouseOver
9393
#endregion
9494

9595
#region Protected
96+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
97+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
98+
protected override Size DefaultMinimumSize => GlobalStaticValues.ResetDefaultMinimumSize;
99+
100+
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
101+
protected override void OnSystemColorsChanged(EventArgs e)
102+
{
103+
// DO nothing, It's Krypton Colours that are in use !
104+
}
105+
96106
/// <summary>
97107
/// Process Windows-based messages.
98108
/// </summary>
@@ -313,7 +323,6 @@ protected override void WndProc(ref Message m)
313323
{
314324
var tme = new PI.TRACKMOUSEEVENTS
315325
{
316-
317326
// This structure needs to know its own size in bytes
318327
cbSize = (uint)Marshal.SizeOf(typeof(PI.TRACKMOUSEEVENTS)),
319328
dwHoverTime = 100,
@@ -567,8 +576,7 @@ protected override void WndProc(ref Message m)
567576
}
568577

569578
// Draw the actual up and down buttons split inside the client rectangle
570-
DrawUpDownButtons(g,
571-
clientRect with { Height = clientRect.Height - 1 });
579+
DrawUpDownButtons(g, clientRect);
572580

573581
// Now blit from the bitmap from the screen to the real dc
574582
PI.BitBlt(hdc, clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height,
@@ -942,7 +950,7 @@ public override Color BackColor
942950
public override Font Font
943951
{
944952
get => base.Font;
945-
set => base.Font = value;
953+
set => base.Font = value!;
946954
}
947955

948956
/// <summary>
@@ -1367,7 +1375,7 @@ public override Rectangle DisplayRectangle
13671375
ForceViewLayout();
13681376

13691377
// The inside text box is the client rectangle size
1370-
return new Rectangle(DomainUpDown.Location, DomainUpDown.Size);
1378+
return new Rectangle(_domainUpDown.Location, _domainUpDown.Size);
13711379
}
13721380
}
13731381

@@ -1714,7 +1722,7 @@ protected override void OnNeedPaint(object? sender, NeedLayoutEventArgs e)
17141722
Font? font = triple.PaletteContent.GetContentShortTextFont(state);
17151723
if ((_domainUpDown.Handle != IntPtr.Zero) && !_domainUpDown.Font.Equals(font))
17161724
{
1717-
_domainUpDown.Font = font;
1725+
_domainUpDown.Font = font!;
17181726
}
17191727
}
17201728

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

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public KryptonGroup()
5050
// Create the internal panel used for containing content
5151
Panel = new KryptonGroupPanel(this, StateCommon, StateDisabled, StateNormal, OnGroupPanelPaint)
5252
{
53-
5453
// Make sure the panel back style always mimics our back style
5554
PanelBackStyle = PaletteBackStyle.ControlClient
5655
};

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

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ public void RefreshItemSizes()
157157
#endregion
158158

159159
#region Protected
160+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
161+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
162+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
163+
160164
/// <summary>
161165
/// Raises the Layout event.
162166
/// </summary>

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

+7
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public bool MouseOver
132132
#endregion
133133

134134
#region Protected
135+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
136+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
137+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
135138

136139
/// <summary>Raises the <see cref="E:System.Windows.Forms.Control.SystemColorsChanged" /> event.</summary>
137140
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
@@ -146,6 +149,10 @@ protected override void OnSystemColorsChanged(EventArgs e)
146149
/// <param name="levent">A LayoutEventArgs containing the event data.</param>
147150
protected override void OnLayout(LayoutEventArgs levent)
148151
{
152+
if (!IsHandleCreated || !Visible)
153+
{
154+
return;
155+
}
149156
base.OnLayout(levent);
150157

151158
// Ask the panel to layout given our available size

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

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public InternalMaskedTextBox(KryptonMaskedTextBox kryptonMaskedTextBox)
8080

8181
// We provide the border manually
8282
BorderStyle = BorderStyle.None;
83+
Padding = Padding.Empty;
8384
}
8485
#endregion
8586

@@ -113,6 +114,9 @@ public bool MouseOver
113114
#endregion
114115

115116
#region Protected
117+
//If this is here, then it will make the control have a minHeight of 37 ?!?!?!
118+
//protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
119+
116120
/// <summary>
117121
/// Process Windows-based messages.
118122
/// </summary>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static DialogResult Show(string text,
5252
/// <param name="showCtrlCopy">Show extraText in title. If null (default) then only when Warning or Error icon is used.</param>
5353
/// <param name="showCloseButton">Displays the close button. If null (default), then the close button will be displayed.</param>
5454
/// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
55-
public static DialogResult Show(string text, string caption, bool? showCtrlCopy = null,
55+
public static DialogResult Show(string? text, string caption, bool? showCtrlCopy = null,
5656
bool? showCloseButton = null) =>
5757
ShowCore(null, text, caption,
5858
showCtrlCopy: showCtrlCopy,

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

+18-7
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public InternalNumericUpDown(KryptonNumericUpDown kryptonNumericUpDown)
6161

6262
// Remove from view until size for the first time by the Krypton control
6363
Size = Size.Empty;
64-
6564
// We provide the border manually
6665
BorderStyle = BorderStyle.None;
66+
Padding = Padding.Empty;
6767
}
6868

6969
public void SetChangingText(bool value) => ChangingText = value;
@@ -100,6 +100,16 @@ public bool MouseOver
100100
#endregion
101101

102102
#region Protected
103+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
104+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
105+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
106+
107+
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
108+
protected override void OnSystemColorsChanged(EventArgs e)
109+
{
110+
// DO nothing, It's Krypton Colours that are in use !
111+
}
112+
103113
/// <summary>
104114
/// Process Windows-based messages.
105115
/// </summary>
@@ -590,8 +600,7 @@ protected override void WndProc(ref Message m)
590600
}
591601

592602
// Draw the actual up and down buttons split inside the client rectangle
593-
DrawUpDownButtons(g,
594-
clientRect with { Height = clientRect.Height - 1 });
603+
DrawUpDownButtons(g, clientRect);
595604

596605
// Now blit from the bitmap from the screen to the real dc
597606
PI.BitBlt(hdc, clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height,
@@ -853,11 +862,13 @@ public KryptonNumericUpDown()
853862
{
854863
DisplayPadding = new Padding(1, 1, 1, 0)
855864
};
865+
// When font is smaller than the Min size, then attempt to Vertical centralise the control
866+
var layoutCentre = new ViewLayoutCenter(_layoutFill);
856867

857868
// Create inner view for placing inside the drawing docker
858869
_drawDockerInner = new ViewLayoutDocker
859870
{
860-
{ _layoutFill, ViewDockStyle.Fill }
871+
{ layoutCentre, ViewDockStyle.Fill }
861872
};
862873

863874
// Create view for the control border and background
@@ -1383,7 +1394,7 @@ public ButtonStyle UpDownButtonStyle
13831394
/// </summary>
13841395
/// <param name="start">The position of the first character in the current text selection within the text box.</param>
13851396
/// <param name="length">The number of characters to select.</param>
1386-
public void Select(int start, int length) => _numericUpDown?.Select(start, length);
1397+
public void Select(int start, int length) => _numericUpDown.Select(start, length);
13871398

13881399
/// <summary>
13891400
/// Sets the fixed state of the control.
@@ -1733,7 +1744,7 @@ protected override void OnLayout(LayoutEventArgs levent)
17331744
if (IsHandleCreated || _forcedLayout || (DesignMode && (_numericUpDown != null)))
17341745
{
17351746
Rectangle fillRect = _layoutFill.FillRect;
1736-
_numericUpDown?.SetBounds(fillRect.X, fillRect.Y, fillRect.Width, fillRect.Height);
1747+
_numericUpDown.SetBounds(fillRect.X, fillRect.Y, fillRect.Width, fillRect.Height);
17371748
}
17381749
}
17391750
}
@@ -1769,7 +1780,7 @@ protected override void OnMouseLeave(EventArgs e)
17691780
protected override void OnGotFocus(EventArgs e)
17701781
{
17711782
base.OnGotFocus(e);
1772-
_numericUpDown?.Focus();
1783+
_numericUpDown.Focus();
17731784
}
17741785

17751786
/// <summary>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public bool UseValueAsText
180180
}
181181

182182
/// <inheritdoc />
183-
[DefaultValue(typeof(Size), @"100, 22")]
183+
[DefaultValue(typeof(Size), @"100, 30")]
184184
public override Size Size { get => base.Size; set => base.Size = value; }
185185

186186
#endregion

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

+4
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public int Print(int charFrom, int charTo, Graphics gr, Rectangle bounds)
152152
#endregion
153153

154154
#region Protected
155+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
156+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
157+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
158+
155159
protected override void OnEnabledChanged(EventArgs e)
156160
{
157161
// Do not forward, to allow the correct Background for disabled state

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public InternalTextBox(KryptonTextBox kryptonTextBox)
6060

6161
// We provide the border manually
6262
BorderStyle = BorderStyle.None;
63+
Padding = Padding.Empty;
6364
}
6465
#endregion
6566

@@ -93,6 +94,8 @@ public bool MouseOver
9394
#endregion
9495

9596
#region Protected
97+
//If this is here, then the Min Height Become 37 ?!?!?!?!
98+
//protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
9699

97100
/// <summary>
98101
/// Process Windows-based messages.
@@ -143,7 +146,6 @@ protected override void WndProc(ref Message m)
143146
// Grab the client area of the control
144147
PI.GetClientRect(Handle, out PI.RECT rect);
145148

146-
147149
// Create rect for the text area
148150
Size borderSize = SystemInformation.BorderSize;
149151
rect.left -= borderSize.Width + 1;

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

+4
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ public bool DrawBackground
502502
#endregion
503503

504504
#region Protected
505+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
506+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
507+
protected override Size DefaultMinimumSize => GlobalStaticValues.ResetDefaultMinimumSize; // MinSize is controlled by the enum
508+
505509
/// <summary>
506510
/// Gets the default size of the control.
507511
/// </summary>

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

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ public void ResetIndent()
146146
#endregion
147147

148148
#region Protected
149+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
150+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
151+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
152+
149153
/// <summary>
150154
/// Raises the Layout event.
151155
/// </summary>

Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ protected override void Dispose(bool disposing)
168168
#endregion
169169

170170
#region Public
171+
/// <summary>Gets the length and height, in pixels, that is specified as the default minimum size of a control.</summary>
172+
/// <returns>A <see cref="T:System.Drawing.Size" /> representing the size of the control.</returns>
173+
protected override Size DefaultMinimumSize => GlobalStaticValues.DefaultMinimumSize;
174+
171175
/// <summary>Gets or sets the <see cref="T:System.Windows.Forms.ContextMenuStrip" /> associated with this control.</summary>
172176
/// <returns>The <see cref="T:System.Windows.Forms.ContextMenuStrip" /> for this control, or <see langword="null" /> if there is no <see cref="T:System.Windows.Forms.ContextMenuStrip" />. The default is <see langword="null" />.</returns>
173177
[Category(@"Behavior")]

Source/Krypton Components/Krypton.Toolkit/General/GlobalStaticValues.cs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace Krypton.Toolkit
1616
/// <summary>Provides a collection of static values, used within the toolkit.</summary>
1717
public class GlobalStaticValues
1818
{
19+
public static Size DefaultMinimumSize = new Size(0, 30);
20+
public static Size ResetDefaultMinimumSize = new Size(0, 0);
1921
/// <summary>The default date and time value</summary>
2022
public static DateTime DEFAULT_DATE_TIME_VALUE = DateTime.Now;
2123

0 commit comments

Comments
 (0)