Skip to content

Commit c7b215a

Browse files
committed
完善AotPropertyGrid控件UI。
1 parent c7812e0 commit c7b215a

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

QpTestClient/Controls/AotPropertyGrid.cs

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -53,103 +53,102 @@ public AotPropertyGrid()
5353

5454
public void RegisterGroup(string groupName)
5555
{
56-
var groupLabel = new Label();
57-
groupLabel.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
58-
groupLabel.Dock = DockStyle.Top;
59-
groupLabel.Margin = new Padding(0);
60-
groupLabel.BorderStyle = BorderStyle.FixedSingle;
61-
groupLabel.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Bold);
62-
groupLabel.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
63-
groupLabel.Location = new System.Drawing.Point(0, 0);
64-
groupLabel.Name = "label1";
65-
groupLabel.Size = new System.Drawing.Size(878, 40);
66-
groupLabel.TabIndex = 1;
67-
groupLabel.Text = $"∇ {groupName}";
68-
groupLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
56+
var control = new Label();
57+
control.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
58+
control.Dock = DockStyle.Top;
59+
control.Margin = new Padding(0);
60+
control.BorderStyle = BorderStyle.FixedSingle;
61+
control.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Bold);
62+
control.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
63+
control.Location = new System.Drawing.Point(0, 0);
64+
control.Name = "label1";
65+
control.Size = new System.Drawing.Size(878, 40);
66+
control.TabIndex = 1;
67+
control.Text = $"∇ {groupName}";
68+
control.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
6969
var collapse = false;
70-
groupLabel.Click += (_, _) =>
70+
control.Click += (_, _) =>
7171
{
7272
collapse = !collapse;
7373
if (collapse)
74-
groupLabel.Text = $"▷ {groupName}";
74+
control.Text = $"▷ {groupName}";
7575
else
76-
groupLabel.Text = $"∇ {groupName}";
76+
control.Text = $"∇ {groupName}";
7777

7878
var enterGroup = false;
79-
foreach (Control control in pnlPropertyControls)
79+
foreach (Control child in pnlPropertyControls)
8080
{
8181
if (enterGroup)
8282
{
83-
if (control is Label)
83+
if (child is Label)
8484
break;
85-
control.Visible = !collapse;
85+
child.Visible = !collapse;
8686
}
8787
else
8888
{
89-
if (control == groupLabel)
89+
if (child == control)
9090
enterGroup = true;
9191
}
9292
}
9393
};
94-
pnlPropertyControls.Add(groupLabel);
94+
pnlPropertyControls.Add(control);
9595
}
9696

9797
private Label createPropertyLabel(string propertyName, string propertyDescription)
9898
{
99-
var label = new Label();
100-
label.BackColor = SystemColors.ControlLightLight;
101-
label.BorderStyle = BorderStyle.FixedSingle;
102-
label.Dock = DockStyle.Left;
103-
label.Margin = new Padding(0);
104-
label.MinimumSize = new Size(180, 30);
105-
label.Size = new Size(180, 38);
106-
label.Text = propertyName;
107-
label.Click += (_, _) =>
99+
var control = new Label();
100+
control.BackColor = SystemColors.ControlLightLight;
101+
control.BorderStyle = BorderStyle.None;
102+
control.Dock = DockStyle.Left;
103+
control.Margin = new Padding(0);
104+
control.Size = new Size(280, 38);
105+
control.Text = propertyName;
106+
control.Click += (_, _) =>
108107
{
109108
lblPropertyName.Text = propertyName;
110109
lblPropertyDescription.Text = propertyDescription;
111110
};
112-
return label;
111+
return control;
113112
}
114113

115114
private TextBox createPropertyTextBox(string propertyName, string propertyDescription)
116115
{
117-
var textBox = new TextBox();
118-
textBox.BorderStyle = BorderStyle.FixedSingle;
119-
textBox.Dock = DockStyle.Top;
120-
textBox.Margin = new Padding(0);
121-
textBox.Size = new Size(698, 38);
122-
textBox.GotFocus += (_, _) =>
116+
var control = new TextBox();
117+
control.BorderStyle = BorderStyle.None;
118+
control.Dock = DockStyle.Top;
119+
control.Margin = new Padding(0);
120+
control.Size = new Size(698, 38);
121+
control.GotFocus += (_, _) =>
123122
{
124123
lblPropertyName.Text = propertyName;
125124
lblPropertyDescription.Text = propertyDescription;
126125
};
127-
return textBox;
126+
return control;
128127
}
129128

130129
private CheckBox createPropertyCheckBox(string propertyName, string propertyDescription)
131130
{
132-
var checkBox = new CheckBox();
133-
checkBox.BackColor = SystemColors.ControlLightLight;
134-
checkBox.Dock = DockStyle.Top;
135-
checkBox.Location = new Point(0, 0);
136-
checkBox.Padding = new Padding(10, 0, 0, 0);
137-
checkBox.Size = new Size(696, 36);
138-
checkBox.UseVisualStyleBackColor = false;
139-
return checkBox;
131+
var control = new CheckBox();
132+
control.BackColor = SystemColors.ControlLightLight;
133+
control.Dock = DockStyle.Top;
134+
control.Location = new Point(0, 0);
135+
control.Padding = new Padding(10, 0, 0, 0);
136+
control.Size = new Size(696, 36);
137+
control.UseVisualStyleBackColor = false;
138+
return control;
140139
}
141140

142141

143142
private ComboBox createPropertyComboBox(string propertyName, string propertyDescription)
144143
{
145-
var comboBox = new ComboBox();
146-
comboBox.Dock = DockStyle.Top;
147-
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
148-
comboBox.FlatStyle = FlatStyle.Flat;
149-
comboBox.FormattingEnabled = true;
150-
comboBox.Location = new Point(0, 0);
151-
comboBox.Size = new Size(696, 39);
152-
return comboBox;
144+
var control = new ComboBox();
145+
control.Dock = DockStyle.Top;
146+
control.DropDownStyle = ComboBoxStyle.DropDownList;
147+
control.FlatStyle = FlatStyle.Flat;
148+
control.FormattingEnabled = true;
149+
control.Location = new Point(0, 0);
150+
control.Size = new Size(696, 39);
151+
return control;
153152
}
154153

155154
private void addPropertyControl(Label label1, Control control1)
@@ -160,7 +159,9 @@ private void addPropertyControl(Label label1, Control control1)
160159
var panel1 = new Panel();
161160
panel1.AutoSize = true;
162161
panel1.Margin = new Padding(0);
162+
panel1.BorderStyle = BorderStyle.FixedSingle;
163163
panel1.Controls.Add(control1);
164+
panel1.Controls.Add(new Splitter() { BackColor = SystemColors.ControlDark, Width = 2 });
164165
panel1.Controls.Add(label1);
165166
panel1.Padding = new Padding(0);
166167
panel1.Dock = DockStyle.Top;

0 commit comments

Comments
 (0)