-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathKryptonAutoHiddenPanel.cs
More file actions
111 lines (101 loc) · 3.77 KB
/
Copy pathKryptonAutoHiddenPanel.cs
File metadata and controls
111 lines (101 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#region BSD License
/*
*
* Original BSD 3-Clause License (https://github.com/ComponentFactory/Krypton/blob/master/LICENSE)
* © Component Factory Pty Ltd, 2006 - 2016, (Version 4.5.0.0) All rights reserved.
*
* New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE)
* Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2017 - 2026. All rights reserved.
*
*/
#endregion
namespace Krypton.Docking;
/// <summary>
/// Edge strip that stacks <see cref="KryptonAutoHiddenGroup"/> tab controls. Preferred size accounts
/// for group stacking along the dock orientation.
/// </summary>
[ToolboxItem(false)]
[DesignerCategory("code")]
[DesignTimeVisible(false)]
public class KryptonAutoHiddenPanel : KryptonPanel
{
#region Static Fields
private const int EXTRA_PADDING = 4;
#endregion
#region Identity
/// <summary>
/// Initialize a new instance of the KryptonAutoHiddenPanel class.
/// </summary>
/// <param name="edge">Docking edge being managed.</param>
public KryptonAutoHiddenPanel(DockingEdge edge)
{
// Add extra padding between the child items and the side facing inwards
switch (edge)
{
case DockingEdge.Left:
Padding = new Padding(0, 0, EXTRA_PADDING, 0);
break;
case DockingEdge.Right:
Padding = new Padding(EXTRA_PADDING, 0, 0, 0);
break;
case DockingEdge.Top:
Padding = new Padding(0, 0, 0, EXTRA_PADDING);
break;
case DockingEdge.Bottom:
Padding = new Padding(0, EXTRA_PADDING, 0, 0);
break;
default:
break;
}
}
#endregion
#region Public
/// <summary>
/// Retrieves the size of a rectangular area into which a control can be fitted.
/// </summary>
public override Size GetPreferredSize(Size proposedSize)
{
var width = 0;
var height = 0;
foreach (KryptonAutoHiddenGroup group in Controls)
{
// Only interested in the group if it has some visible pages
if (group.Pages.VisibleCount > 0)
{
// Find the exact size the child would like to be sized
Size groupSize = group.GetPreferredSize(proposedSize);
switch (Dock)
{
case DockStyle.Left:
case DockStyle.Right:
// We are as wide as the widest child and as tall as heights added together
width = Math.Max(width, groupSize.Width);
height += groupSize.Height;
break;
case DockStyle.Top:
case DockStyle.Bottom:
// We are as tall as the tallest child and as wide as widths added together
width += groupSize.Width;
height = Math.Max(height, groupSize.Height);
break;
case DockStyle.None:
// We are big enough to show the largest child
width = Math.Max(width, groupSize.Width);
height = Math.Max(height, groupSize.Height);
break;
}
}
}
// Add on any padding values but only if we have something to display
if (width > 0)
{
width += Padding.Horizontal;
}
if (height > 0)
{
height += Padding.Vertical;
}
return new Size(width, height);
}
#endregion
}