Skip to content

Commit 2a01383

Browse files
committed
fixed examples: removed custom scrollbars, fixed Create extension method
1 parent 77702d0 commit 2a01383

File tree

3 files changed

+24
-78
lines changed

3 files changed

+24
-78
lines changed

Examples/ControlsExtensions.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,30 @@ public static T Create<T>(
9393
var parentControls = parent.Controls;
9494
if (parentControls.Count > 0)
9595
{
96-
var lastChild = parentControls[parentControls.Count - 1];
97-
var lastChildY = lastChild.Location.Y;
98-
if (lastChildY >= topOffset)
96+
Control lastChild = null;
97+
for (int i = parentControls.Count - 1; i >= 0; i--)
9998
{
100-
if (placeToRight)
99+
var child = parentControls[i];
100+
if (child.uwfSystem)
101+
continue;
102+
103+
lastChild = child;
104+
break;
105+
}
106+
107+
if (lastChild != null)
108+
{
109+
var lastChildY = lastChild.Location.Y;
110+
if (lastChildY >= topOffset)
101111
{
102-
leftOffset = lastChild.Location.X + lastChild.Width + margin;
103-
topOffset = lastChildY;
112+
if (placeToRight)
113+
{
114+
leftOffset = lastChild.Location.X + lastChild.Width + margin;
115+
topOffset = lastChildY;
116+
}
117+
else
118+
topOffset = lastChildY + lineHeight;
104119
}
105-
else
106-
topOffset = lastChildY + lineHeight;
107120
}
108121
}
109122

Examples/FormExamples.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public FormExamples()
104104
treeView.Refresh();
105105

106106
// Grip renderer is normal control. Bring it to front if you use it over other controls that can technicaly hide it.
107-
// Unfortunately it will not dock with scrollbars.
107+
// Unfortunately it will not dock with panel scrollbars.
108108
uwfSizeGripRenderer.BringToFront();
109109
}
110110

@@ -133,7 +133,6 @@ private void TreeViewOnNodeMouseClick(object sender, TreeNodeMouseClickEventArgs
133133
Controls.Add(currentPanel);
134134

135135
currentPanel.Initialize();
136-
currentPanel.UpdateScroll();
137136

138137
uwfSizeGripRenderer.BringToFront();
139138
}

Examples/Panels/BaseExamplePanel.cs

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,12 @@ public abstract class BaseExamplePanel : Panel
88
{
99
protected int lineOffset = 36;
1010

11-
// Panels are not supporting scrolling. This basic is workaround.
12-
private readonly VScrollBar vScrollBar;
13-
1411
protected BaseExamplePanel()
1512
{
13+
AutoScroll = true;
1614
BackColor = Color.FromArgb(239, 235, 233);
17-
18-
vScrollBar = new VScrollBar();
19-
vScrollBar.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
20-
vScrollBar.Location = new Point(Width - vScrollBar.Width, 0);
21-
vScrollBar.Height = Height;
22-
vScrollBar.ValueChanged += VScrollBarOnValueChanged;
23-
24-
Controls.Add(vScrollBar);
25-
}
26-
27-
private int ContentHeight
28-
{
29-
get
30-
{
31-
int bottom = Height;
32-
for (int i = 0; i < Controls.Count; i++)
33-
{
34-
var item = Controls[i];
35-
if (item == null || item == vScrollBar)
36-
continue;
37-
38-
if (item.Location.Y + item.Height > bottom)
39-
bottom = item.Location.Y + item.Height;
40-
}
41-
42-
if (bottom > Height)
43-
bottom += 8;
44-
45-
return bottom;
46-
}
4715
}
48-
16+
4917
public abstract void Initialize();
50-
public void UpdateScroll()
51-
{
52-
var contentHeight = ContentHeight;
53-
54-
vScrollBar.Visible = contentHeight > Height;
55-
vScrollBar.Maximum = contentHeight;
56-
vScrollBar.LargeChange = Height;
57-
}
58-
59-
protected override void OnMouseWheel(MouseEventArgs e)
60-
{
61-
base.OnMouseWheel(e);
62-
63-
if (vScrollBar.Visible)
64-
vScrollBar.Value -= e.Delta;
65-
}
66-
protected override void OnResize(EventArgs e)
67-
{
68-
base.OnResize(e);
69-
70-
UpdateScroll();
71-
}
72-
73-
private void VScrollBarOnValueChanged(object sender, EventArgs eventArgs)
74-
{
75-
for (int i = 0; i < Controls.Count; i++)
76-
{
77-
var item = Controls[i];
78-
if (item == null || item == vScrollBar)
79-
continue;
80-
81-
item.uwfOffset = new Point(0, -vScrollBar.Value);
82-
}
83-
}
8418
}
8519
}

0 commit comments

Comments
 (0)