-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColumnForm.cs
203 lines (178 loc) · 6.47 KB
/
ColumnForm.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace AlphaIMS
{
public partial class ColumnForm : Form
{
public string ReturnName { get; set; }
public string ReturnFormula { get; set; }
public double ReturnMin { get; set; }
public double ReturnMax { get; set; }
public int ReturnReadvalue { get; set; }
public ColumnForm(int column, int x, int y, TABLECOLUMN tableCol)
{
InitializeComponent();
columnLabel.Text = string.Format("{0}列", Convert.ToChar(column + 65).ToString());
nameTextBox.Text = Convert.ToChar(column + 65).ToString();
if (tableCol != null)
{
formulaTextBox.Text = tableCol.Formula;
minTextBox.Text = tableCol.Min.ToString("f3");
maxTextBox.Text = tableCol.Max.ToString("f3");
if (tableCol.Name != "")
nameTextBox.Text = tableCol.Name;
switch (tableCol.Readvalue)
{
case 0:
radioButton1.Checked = true;
break;
case 1:
radioButton2.Checked = true;
break;
case 2:
radioButton3.Checked = true;
break;
case 3:
radioButton4.Checked = true;
break;
case 4:
radioButton5.Checked = true;
break;
}
if (formulaTextBox.Text == "")
{
radioButton1.Visible = true;
radioButton2.Visible = true;
radioButton3.Visible = true;
radioButton4.Visible = true;
radioButton5.Visible = true;
}
else
{
radioButton1.Visible = false;
radioButton2.Visible = false;
radioButton3.Visible = false;
radioButton4.Visible = false;
radioButton5.Visible = false;
}
}
OKBtn.BackColor = Color.FromArgb(72, 180, 225);
cancelBtn.BackColor = Color.FromArgb(72, 180, 225);
if ((x + this.Width) > Screen.PrimaryScreen.Bounds.Width)
x = x - ((x + this.Width) - Screen.PrimaryScreen.Bounds.Width);
this.Location = new Point(x, y);
this.BackColor = Color.FromArgb(226,226,226);
}
private void OKBtn_Click(object sender, EventArgs e)
{
ReturnName = nameTextBox.Text;
ReturnFormula = formulaTextBox.Text;
ReturnMin = Double.Parse(minTextBox.Text);
ReturnMax = Double.Parse(maxTextBox.Text);
if (radioButton1.Checked)
ReturnReadvalue = 0;
else if (radioButton2.Checked)
ReturnReadvalue = 1;
else if(radioButton3.Checked)
ReturnReadvalue = 2;
else if(radioButton3.Checked)
ReturnReadvalue = 3;
else
ReturnReadvalue = 4;
this.DialogResult = DialogResult.OK;
}
private void formulaTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= (Char)97 && e.KeyChar <= (Char)122)
{
e.Handled = true;
}
else
{
e.Handled = false;
}
}
private void formulaTextBox_KeyUp(object sender, KeyEventArgs e)
{
if (formulaTextBox.Text == "")
{
radioButton1.Visible = true;
radioButton2.Visible = true;
radioButton3.Visible = true;
radioButton4.Visible = true;
radioButton5.Visible = true;
}
else
{
radioButton1.Visible = false;
radioButton2.Visible = false;
radioButton3.Visible = false;
radioButton4.Visible = false;
radioButton5.Visible = false;
}
}
private void minTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
// e.KeyChar == (Char)48 ~ 57 -----> 0~9
// e.KeyChar == (Char)8 -----------> Backpace
// e.KeyChar == (Char)46 -----------> .
if (e.KeyChar == (Char)48 || e.KeyChar == (Char)49 ||
e.KeyChar == (Char)50 || e.KeyChar == (Char)51 ||
e.KeyChar == (Char)52 || e.KeyChar == (Char)53 ||
e.KeyChar == (Char)54 || e.KeyChar == (Char)55 ||
e.KeyChar == (Char)56 || e.KeyChar == (Char)57 ||
e.KeyChar == (Char)8 || e.KeyChar == (Char)46)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
private void maxTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
// e.KeyChar == (Char)48 ~ 57 -----> 0~9
// e.KeyChar == (Char)8 -----------> Backpace
// e.KeyChar == (Char)46 -----------> .
if (e.KeyChar == (Char)48 || e.KeyChar == (Char)49 ||
e.KeyChar == (Char)50 || e.KeyChar == (Char)51 ||
e.KeyChar == (Char)52 || e.KeyChar == (Char)53 ||
e.KeyChar == (Char)54 || e.KeyChar == (Char)55 ||
e.KeyChar == (Char)56 || e.KeyChar == (Char)57 ||
e.KeyChar == (Char)8 || e.KeyChar == (Char)46)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
private void cancelBtn_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
}
public class TABLECOLUMN
{
public TABLECOLUMN()
{
Name = "";
Formula = "";
Min = 0.00;
Max = 1000.00;
Readvalue = 0;
}
public string Name { get; set; }
public string Formula { get; set; }
public double Min { get; set; }
public double Max { get; set; }
public int Readvalue { get; set; }
}
}