IOTextControl.cs
2.0 KB
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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace UControl.UC
{
public partial class IOTextControl : UserControl
{
public string IOName { get; set; }
public int IOValue { get; set; }
public bool CanClick { get; set; } = false;
public IOTextControl()
{
InitializeComponent();
}
public IOTextControl(string ioName, string name, int widht = 220, int height = 26, int ioValue = -1, bool canClick = false, int tabIndex = 0)
{
InitializeComponent();
IOName = ioName;
IOValue = IOValue;
CanClick = canClick;
Name = "IO_" + name;
Size = new Size(widht, height);
TabIndex = tabIndex;
}
public void ShowData()
{
this.Invoke(new Action(() => {
label1.Text = IOName;
if (IOValue == 0)
{
picBoxState.Image = UIControl.Properties.Resource.gray;
}
else if (IOValue == 1)
{
picBoxState.Image = UIControl.Properties.Resource.green;
}
else
{
picBoxState.Image = UIControl.Properties.Resource.gray;
}
}));
}
private void label1_DoubleClick(object sender, EventArgs e)
{
this.OnDoubleClick(e);
}
private void label1_Click(object sender, EventArgs e)
{
this.OnClick(e);
}
private void IOTextControl_Load(object sender, EventArgs e)
{
ShowData();
}
private void picBoxState_Click(object sender, EventArgs e)
{
this.OnClick(e);
}
private void picBoxState_DoubleClick(object sender, EventArgs e)
{
this.OnDoubleClick(e);
ImageList list = new ImageList();
list.Images.Add(UIControl.Properties.Resource.gray);
}
}
}