/
SettingControl.cs
executable file
·98 lines (86 loc) · 2.47 KB
/
SettingControl.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
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Aont
{
public partial class SettingControl : UserControl
{
public SettingControl()
{
InitializeComponent();
}
int _Space = 30;
int _MinimumTextBoxSize = 30;
public int Space
{
get { return this._Space; }
set
{
this._Space = value;
this.ValueTextbox.Left = (this.TitleLabel.Width / _Space + 1) * _Space;
}
}
string _Title;
public string Title
{
get
{
return this._Title;
}
set
{
this._Title = value;
this.TitleLabel.Text = value;
this.ValueTextbox.Left = (this.TitleLabel.Width / _Space + 1) * _Space;
}
}
public string Value
{
get { return this.ValueTextbox.Text; }
set { this.ValueTextbox.Text = value; }
}
public event EventHandler OnKeyEnter = delegate(object @object, EventArgs e) { };
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
this.OnKeyEnter(this, null);
break;
default:
break;
}
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
SizeSet();
}
void SizeSet()
{
var Left = (this.TitleLabel.Width / _Space + 1) * _Space;
var Width = this.Width;
if (Width > Left + _MinimumTextBoxSize)
{
this.ValueTextbox.Top = 0;
this.ValueTextbox.Left = Left;
this.ValueTextbox.Width = Width - Left;
}
else
{
this.ValueTextbox.Left = 0;
this.ValueTextbox.Top = this.TitleLabel.Height + 6;
this.ValueTextbox.Width = Width;
}
}
protected override void OnPaint(PaintEventArgs e)
{
SizeSet();
base.OnPaint(e);
}
}
}