using System.Drawing;
using System.Windows.Forms;
namespace MainForm.Core {
public class VerticalPanel : System.Windows.Forms.Panel {
public VerticalPanel() {
Width = 1;
Height = 0;
AutoSize = true;
AutoScroll = false;
}
//public VerticalPanel(bool AutoScroll) {
// Width = 1;
// Height = 0;
// AutoSize = !AutoScroll;
// this.AutoScroll = AutoScroll;
//}
int x = 0;
int h = 0;
public void add(Control control, int split) {
h = split;
//x = (x == 0) ? 0 : x += split;
HorizontalScroll.Enabled = true;
control.Location = getLocation();// new Point(x, 0);
Controls.Add(control);
x += control.Height;
//if (x > Height && this.AutoScroll == true) {
// Width = control.Width + 20;
//} else {
// Width = control.Width;
//}
}
Point getLocation() {
x = (x == 0) ? 0 : x += h;
return new Point(0, x);
}
public void add(Control control) {
add(control, 0);
}
protected override void OnControlRemoved(ControlEventArgs e) {
x = 0;
foreach (Control c in Controls) {
c.Location = getLocation();
x += c.Height;
}
}
}
}
No comments:
Post a Comment