This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
/
dockpadding.cs
executable file
·89 lines (76 loc) · 1.73 KB
/
dockpadding.cs
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
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms;
namespace DickPadding {
public class Form1 : System.Windows.Forms.Form {
private Panel p;
private Button b;
public Form1() {
InitializeComponent();
}
int myCounter = 0;
private void SetDockPadding() {
b.Dock = System.Windows.Forms.DockStyle.Fill;
if (myCounter > 5) {
myCounter = 0;
}
switch (myCounter) {
case 0:
p.DockPadding.All = 0;
b.Text = "Start";
break;
case 1:
p.DockPadding.Top = 10;
b.Text = "Top";
break;
case 2:
p.DockPadding.Bottom = 10;
b.Text = "Bottom";
break;
case 3:
p.DockPadding.Left = 10;
b.Text = "Left";
break;
case 4:
p.DockPadding.Right = 10;
b.Text = "Right";
break;
case 5:
p.DockPadding.All = 20;
b.Text = "All";
break;
}
myCounter += 1;
}
private void InitializeComponent() {
p = new Panel();
b = new Button();
this.SuspendLayout();
p.Location = new System.Drawing.Point(8, 40);
p.Name = "panel";
p.Size = new System.Drawing.Size(272, 152);
p.BackColor = Color.SkyBlue;
p.DockPadding.All = 10;
b.Location = new Point(8, 8);
b.Text = "Start";
b.Click += new EventHandler(b_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
Controls.Add(this.p);
p.Controls.Add(this.b);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
[STAThread]
static void Main() {
Application.Run(new Form1());
}
private void b_Click(object sender, EventArgs e) {
SetDockPadding();
}
}
}