-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmPushButtons.cs
170 lines (153 loc) · 4.48 KB
/
frmPushButtons.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
using System;
using System.Collections.Generic;
using System.Net;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Lextm.SharpSnmpLib;
using Lextm.SharpSnmpLib.Messaging;
namespace snmpd
{
public partial class frmPushButtons : Form
{
TaskScheduler UiScheduler;
ButtonGroup bgMain;
public frmPushButtons()
{
InitializeComponent();
UiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
}
private void frmPushButtons_Load(object sender, EventArgs e)
{
lblMsg.Text = "Send SNMP Set commands like the buttons do. Simulate button behaviour.";
SetIpLabel();
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
SetIpLabel();
}
private void SetIpLabel()
{
switch (Convert.ToInt32(NudGroup.Value))
{
case 1:
lblIP.Text = "192.168.1.40";
break;
case 2:
lblIP.Text = "192.168.1.41";
break;
case 3:
lblIP.Text = "192.168.1.42";
break;
case 4:
lblIP.Text = "192.168.1.43";
break;
case 5:
lblIP.Text = "192.168.1.44";
break;
case 6:
lblIP.Text = "192.168.1.45";
break;
case 7:
lblIP.Text = "192.168.1.46";
break;
case 8:
lblIP.Text = "192.168.1.47";
break;
default:
lblIP.Text = "127.0.0.1";
break;
}
}
private void btnInit_Click(object sender, EventArgs e)
{
bgMain = new ButtonGroup(Convert.ToInt32(NudGroup.Value), lblIP.Text);
}
private void button1_Click(object sender, EventArgs e)
{
if (bgMain != null)
{
Button b = bgMain.buttons[0];
txtOutput.Text += "ButtonID: " + b.ID + " OID: " + b.OID + " Text: " + b.Text;
b.BackColor = Color.LawnGreen;
}
else
{
MessageBox.Show("No Button group has been initialized.");
btnInit.Focus();
}
}
public void ToggleButtonColor(int buttonNo)
{
System.Windows.Forms.Button btn;
switch (buttonNo)
{
case 9:
btn = button9;
break;
case 10:
btn = button10;
break;
case 11:
btn = button11;
break;
case 12:
btn = button12;
break;
case 13:
btn = button13;
break;
case 14:
btn = button14;
break;
case 15:
btn = button15;
break;
case 16:
btn = button16;
break;
case 1:
btn = button1;
break;
case 2:
btn = button2;
break;
case 3:
btn = button3;
break;
case 4:
btn = button4;
break;
case 5:
btn = button5;
break;
case 6:
btn = button6;
break;
case 7:
btn = button7;
break;
case 8:
btn = button8;
break;
default:
btn = button1;
break;
}
if (btn.BackColor == Color.Coral)
btn.BackColor = Color.Green;
else
btn.BackColor = Color.Coral;
}
private void ButtonError()
{
}
private void gbButtons_Enter(object sender, EventArgs e)
{
}
}
}