Parcourir la source

add Listbox color

张泳健 il y a 8 ans
Parent
révision
f92d057275

BIN
.vs/GWSocketClient/v15/.suo Voir le fichier


+ 94 - 72
GWSocketClient/Form1.Designer.cs Voir le fichier

@@ -31,6 +31,9 @@
31 31
             this.components = new System.ComponentModel.Container();
32 32
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
33 33
             this.groupBox1 = new System.Windows.Forms.GroupBox();
34
+            this.label7 = new System.Windows.Forms.Label();
35
+            this.tfTmpResponse = new System.Windows.Forms.TextBox();
36
+            this.label6 = new System.Windows.Forms.Label();
34 37
             this.tfTmpSendData = new System.Windows.Forms.TextBox();
35 38
             this.tbCCID = new System.Windows.Forms.TextBox();
36 39
             this.label5 = new System.Windows.Forms.Label();
@@ -58,9 +61,6 @@
58 61
             this.listBoxShow = new System.Windows.Forms.ListBox();
59 62
             this.cmslistboxRightMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
60 63
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
61
-            this.label6 = new System.Windows.Forms.Label();
62
-            this.tfTmpResponse = new System.Windows.Forms.TextBox();
63
-            this.label7 = new System.Windows.Forms.Label();
64 64
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
65 65
             this.groupBox1.SuspendLayout();
66 66
             this.menuStrip1.SuspendLayout();
@@ -91,28 +91,58 @@
91 91
             this.groupBox1.Controls.Add(this.label2);
92 92
             this.groupBox1.Controls.Add(this.tbIpaddress);
93 93
             this.groupBox1.Controls.Add(this.label1);
94
-            this.groupBox1.Location = new System.Drawing.Point(12, 28);
94
+            this.groupBox1.Location = new System.Drawing.Point(14, 40);
95
+            this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
95 96
             this.groupBox1.Name = "groupBox1";
96
-            this.groupBox1.Size = new System.Drawing.Size(883, 104);
97
+            this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
98
+            this.groupBox1.Size = new System.Drawing.Size(1030, 147);
97 99
             this.groupBox1.TabIndex = 0;
98 100
             this.groupBox1.TabStop = false;
99 101
             this.groupBox1.Text = "groupBox1";
100 102
             // 
103
+            // label7
104
+            // 
105
+            this.label7.AutoSize = true;
106
+            this.label7.Location = new System.Drawing.Point(436, 106);
107
+            this.label7.Name = "label7";
108
+            this.label7.Size = new System.Drawing.Size(32, 17);
109
+            this.label7.TabIndex = 16;
110
+            this.label7.Text = "发送";
111
+            // 
112
+            // tfTmpResponse
113
+            // 
114
+            this.tfTmpResponse.Location = new System.Drawing.Point(55, 102);
115
+            this.tfTmpResponse.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
116
+            this.tfTmpResponse.Name = "tfTmpResponse";
117
+            this.tfTmpResponse.Size = new System.Drawing.Size(374, 23);
118
+            this.tfTmpResponse.TabIndex = 15;
119
+            // 
120
+            // label6
121
+            // 
122
+            this.label6.AutoSize = true;
123
+            this.label6.Location = new System.Drawing.Point(7, 106);
124
+            this.label6.Name = "label6";
125
+            this.label6.Size = new System.Drawing.Size(35, 17);
126
+            this.label6.TabIndex = 14;
127
+            this.label6.Text = "回复:";
128
+            // 
101 129
             // tfTmpSendData
102 130
             // 
103 131
             this.tfTmpSendData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
104 132
             | System.Windows.Forms.AnchorStyles.Right)));
105
-            this.tfTmpSendData.Location = new System.Drawing.Point(415, 72);
133
+            this.tfTmpSendData.Location = new System.Drawing.Point(484, 102);
134
+            this.tfTmpSendData.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
106 135
             this.tfTmpSendData.Name = "tfTmpSendData";
107
-            this.tfTmpSendData.Size = new System.Drawing.Size(462, 21);
136
+            this.tfTmpSendData.Size = new System.Drawing.Size(538, 23);
108 137
             this.tfTmpSendData.TabIndex = 13;
109 138
             // 
110 139
             // tbCCID
111 140
             // 
112 141
             this.tbCCID.ForeColor = System.Drawing.Color.Blue;
113
-            this.tbCCID.Location = new System.Drawing.Point(464, 14);
142
+            this.tbCCID.Location = new System.Drawing.Point(541, 20);
143
+            this.tbCCID.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
114 144
             this.tbCCID.Name = "tbCCID";
115
-            this.tbCCID.Size = new System.Drawing.Size(294, 21);
145
+            this.tbCCID.Size = new System.Drawing.Size(342, 23);
116 146
             this.tbCCID.TabIndex = 12;
117 147
             this.tbCCID.Text = "3839383630324231313931353530343739383737";
118 148
             this.tbCCID.TextChanged += new System.EventHandler(this.tbCCID_TextChanged);
@@ -120,17 +150,18 @@
120 150
             // label5
121 151
             // 
122 152
             this.label5.AutoSize = true;
123
-            this.label5.Location = new System.Drawing.Point(423, 17);
153
+            this.label5.Location = new System.Drawing.Point(493, 24);
124 154
             this.label5.Name = "label5";
125
-            this.label5.Size = new System.Drawing.Size(35, 12);
155
+            this.label5.Size = new System.Drawing.Size(45, 17);
126 156
             this.label5.TabIndex = 11;
127 157
             this.label5.Text = "CCCID";
128 158
             // 
129 159
             // btnPressureTest
130 160
             // 
131
-            this.btnPressureTest.Location = new System.Drawing.Point(375, 45);
161
+            this.btnPressureTest.Location = new System.Drawing.Point(437, 64);
162
+            this.btnPressureTest.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
132 163
             this.btnPressureTest.Name = "btnPressureTest";
133
-            this.btnPressureTest.Size = new System.Drawing.Size(75, 23);
164
+            this.btnPressureTest.Size = new System.Drawing.Size(87, 33);
134 165
             this.btnPressureTest.TabIndex = 10;
135 166
             this.btnPressureTest.Text = "压力测试";
136 167
             this.btnPressureTest.UseVisualStyleBackColor = true;
@@ -138,26 +169,28 @@
138 169
             // label4
139 170
             // 
140 171
             this.label4.AutoSize = true;
141
-            this.label4.Location = new System.Drawing.Point(252, 50);
172
+            this.label4.Location = new System.Drawing.Point(294, 71);
142 173
             this.label4.Name = "label4";
143
-            this.label4.Size = new System.Drawing.Size(53, 12);
174
+            this.label4.Size = new System.Drawing.Size(56, 17);
144 175
             this.label4.TabIndex = 9;
145 176
             this.label4.Text = "压力测试";
146 177
             // 
147 178
             // tbPresureTestCount
148 179
             // 
149 180
             this.tbPresureTestCount.ForeColor = System.Drawing.Color.Blue;
150
-            this.tbPresureTestCount.Location = new System.Drawing.Point(312, 47);
181
+            this.tbPresureTestCount.Location = new System.Drawing.Point(364, 67);
182
+            this.tbPresureTestCount.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
151 183
             this.tbPresureTestCount.Name = "tbPresureTestCount";
152
-            this.tbPresureTestCount.Size = new System.Drawing.Size(56, 21);
184
+            this.tbPresureTestCount.Size = new System.Drawing.Size(65, 23);
153 185
             this.tbPresureTestCount.TabIndex = 8;
154 186
             this.tbPresureTestCount.Text = "100";
155 187
             // 
156 188
             // btnSendData
157 189
             // 
158
-            this.btnSendData.Location = new System.Drawing.Point(170, 45);
190
+            this.btnSendData.Location = new System.Drawing.Point(198, 64);
191
+            this.btnSendData.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
159 192
             this.btnSendData.Name = "btnSendData";
160
-            this.btnSendData.Size = new System.Drawing.Size(75, 23);
193
+            this.btnSendData.Size = new System.Drawing.Size(87, 33);
161 194
             this.btnSendData.TabIndex = 7;
162 195
             this.btnSendData.Text = "发送数据";
163 196
             this.btnSendData.UseVisualStyleBackColor = true;
@@ -165,9 +198,10 @@
165 198
             // 
166 199
             // btnQuickLogout
167 200
             // 
168
-            this.btnQuickLogout.Location = new System.Drawing.Point(88, 45);
201
+            this.btnQuickLogout.Location = new System.Drawing.Point(103, 64);
202
+            this.btnQuickLogout.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
169 203
             this.btnQuickLogout.Name = "btnQuickLogout";
170
-            this.btnQuickLogout.Size = new System.Drawing.Size(75, 23);
204
+            this.btnQuickLogout.Size = new System.Drawing.Size(87, 33);
171 205
             this.btnQuickLogout.TabIndex = 6;
172 206
             this.btnQuickLogout.Text = "退出登录";
173 207
             this.btnQuickLogout.UseVisualStyleBackColor = true;
@@ -175,9 +209,10 @@
175 209
             // 
176 210
             // btnLogin
177 211
             // 
178
-            this.btnLogin.Location = new System.Drawing.Point(6, 45);
212
+            this.btnLogin.Location = new System.Drawing.Point(7, 64);
213
+            this.btnLogin.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
179 214
             this.btnLogin.Name = "btnLogin";
180
-            this.btnLogin.Size = new System.Drawing.Size(75, 23);
215
+            this.btnLogin.Size = new System.Drawing.Size(87, 33);
181 216
             this.btnLogin.TabIndex = 3;
182 217
             this.btnLogin.Text = "登录";
183 218
             this.btnLogin.UseVisualStyleBackColor = true;
@@ -186,9 +221,10 @@
186 221
             // tbEquipmentAddress
187 222
             // 
188 223
             this.tbEquipmentAddress.ForeColor = System.Drawing.Color.Blue;
189
-            this.tbEquipmentAddress.Location = new System.Drawing.Point(294, 14);
224
+            this.tbEquipmentAddress.Location = new System.Drawing.Point(343, 20);
225
+            this.tbEquipmentAddress.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
190 226
             this.tbEquipmentAddress.Name = "tbEquipmentAddress";
191
-            this.tbEquipmentAddress.Size = new System.Drawing.Size(123, 21);
227
+            this.tbEquipmentAddress.Size = new System.Drawing.Size(143, 23);
192 228
             this.tbEquipmentAddress.TabIndex = 5;
193 229
             this.tbEquipmentAddress.Text = "4442832e833c";
194 230
             this.tbEquipmentAddress.TextChanged += new System.EventHandler(this.tbEquipmentAddress_TextChanged);
@@ -196,45 +232,47 @@
196 232
             // tbPort
197 233
             // 
198 234
             this.tbPort.ForeColor = System.Drawing.Color.Blue;
199
-            this.tbPort.Location = new System.Drawing.Point(171, 14);
235
+            this.tbPort.Location = new System.Drawing.Point(199, 20);
236
+            this.tbPort.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
200 237
             this.tbPort.Name = "tbPort";
201
-            this.tbPort.Size = new System.Drawing.Size(56, 21);
238
+            this.tbPort.Size = new System.Drawing.Size(65, 23);
202 239
             this.tbPort.TabIndex = 3;
203 240
             this.tbPort.Text = "15440";
204 241
             // 
205 242
             // label3
206 243
             // 
207 244
             this.label3.AutoSize = true;
208
-            this.label3.Location = new System.Drawing.Point(234, 17);
245
+            this.label3.Location = new System.Drawing.Point(273, 24);
209 246
             this.label3.Name = "label3";
210
-            this.label3.Size = new System.Drawing.Size(53, 12);
247
+            this.label3.Size = new System.Drawing.Size(56, 17);
211 248
             this.label3.TabIndex = 4;
212 249
             this.label3.Text = "设备地址";
213 250
             // 
214 251
             // label2
215 252
             // 
216 253
             this.label2.AutoSize = true;
217
-            this.label2.Location = new System.Drawing.Point(135, 17);
254
+            this.label2.Location = new System.Drawing.Point(157, 24);
218 255
             this.label2.Name = "label2";
219
-            this.label2.Size = new System.Drawing.Size(29, 12);
256
+            this.label2.Size = new System.Drawing.Size(32, 17);
220 257
             this.label2.TabIndex = 2;
221 258
             this.label2.Text = "端口";
222 259
             // 
223 260
             // tbIpaddress
224 261
             // 
225 262
             this.tbIpaddress.ForeColor = System.Drawing.Color.Blue;
226
-            this.tbIpaddress.Location = new System.Drawing.Point(28, 14);
263
+            this.tbIpaddress.Location = new System.Drawing.Point(33, 20);
264
+            this.tbIpaddress.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
227 265
             this.tbIpaddress.Name = "tbIpaddress";
228
-            this.tbIpaddress.Size = new System.Drawing.Size(100, 21);
266
+            this.tbIpaddress.Size = new System.Drawing.Size(116, 23);
229 267
             this.tbIpaddress.TabIndex = 1;
230 268
             this.tbIpaddress.Text = "127.0.0.1";
231 269
             // 
232 270
             // label1
233 271
             // 
234 272
             this.label1.AutoSize = true;
235
-            this.label1.Location = new System.Drawing.Point(4, 17);
273
+            this.label1.Location = new System.Drawing.Point(5, 24);
236 274
             this.label1.Name = "label1";
237
-            this.label1.Size = new System.Drawing.Size(17, 12);
275
+            this.label1.Size = new System.Drawing.Size(19, 17);
238 276
             this.label1.TabIndex = 0;
239 277
             this.label1.Text = "IP";
240 278
             // 
@@ -244,7 +282,8 @@
244 282
             this.文件FToolStripMenuItem});
245 283
             this.menuStrip1.Location = new System.Drawing.Point(0, 0);
246 284
             this.menuStrip1.Name = "menuStrip1";
247
-            this.menuStrip1.Size = new System.Drawing.Size(907, 25);
285
+            this.menuStrip1.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
286
+            this.menuStrip1.Size = new System.Drawing.Size(1058, 27);
248 287
             this.menuStrip1.TabIndex = 1;
249 288
             this.menuStrip1.Text = "menuStrip1";
250 289
             // 
@@ -270,9 +309,10 @@
270 309
             this.tsslEquipmentAddress,
271 310
             this.toolStripStatusLabel2,
272 311
             this.tsslCCIDLEN});
273
-            this.statusStrip1.Location = new System.Drawing.Point(0, 617);
312
+            this.statusStrip1.Location = new System.Drawing.Point(0, 883);
274 313
             this.statusStrip1.Name = "statusStrip1";
275
-            this.statusStrip1.Size = new System.Drawing.Size(907, 22);
314
+            this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0);
315
+            this.statusStrip1.Size = new System.Drawing.Size(1058, 22);
276 316
             this.statusStrip1.TabIndex = 2;
277 317
             this.statusStrip1.Text = "statusStrip1";
278 318
             // 
@@ -306,9 +346,11 @@
306 346
             | System.Windows.Forms.AnchorStyles.Left) 
307 347
             | System.Windows.Forms.AnchorStyles.Right)));
308 348
             this.groupBox2.Controls.Add(this.listBoxShow);
309
-            this.groupBox2.Location = new System.Drawing.Point(12, 396);
349
+            this.groupBox2.Location = new System.Drawing.Point(14, 561);
350
+            this.groupBox2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
310 351
             this.groupBox2.Name = "groupBox2";
311
-            this.groupBox2.Size = new System.Drawing.Size(883, 218);
352
+            this.groupBox2.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
353
+            this.groupBox2.Size = new System.Drawing.Size(1030, 309);
312 354
             this.groupBox2.TabIndex = 13;
313 355
             this.groupBox2.TabStop = false;
314 356
             this.groupBox2.Text = "groupBox2";
@@ -319,14 +361,17 @@
319 361
             | System.Windows.Forms.AnchorStyles.Left) 
320 362
             | System.Windows.Forms.AnchorStyles.Right)));
321 363
             this.listBoxShow.ContextMenuStrip = this.cmslistboxRightMenu;
322
-            this.listBoxShow.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
364
+            this.listBoxShow.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
365
+            this.listBoxShow.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
323 366
             this.listBoxShow.FormattingEnabled = true;
324 367
             this.listBoxShow.HorizontalScrollbar = true;
325 368
             this.listBoxShow.ItemHeight = 14;
326
-            this.listBoxShow.Location = new System.Drawing.Point(8, 20);
369
+            this.listBoxShow.Location = new System.Drawing.Point(9, 28);
370
+            this.listBoxShow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
327 371
             this.listBoxShow.Name = "listBoxShow";
328
-            this.listBoxShow.Size = new System.Drawing.Size(869, 172);
372
+            this.listBoxShow.Size = new System.Drawing.Size(1013, 242);
329 373
             this.listBoxShow.TabIndex = 0;
374
+            this.listBoxShow.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBoxShow_DrawItem);
330 375
             // 
331 376
             // cmslistboxRightMenu
332 377
             // 
@@ -339,52 +384,29 @@
339 384
             // rightMenuCopyCmd
340 385
             // 
341 386
             this.rightMenuCopyCmd.Name = "rightMenuCopyCmd";
342
-            this.rightMenuCopyCmd.Size = new System.Drawing.Size(152, 22);
387
+            this.rightMenuCopyCmd.Size = new System.Drawing.Size(140, 22);
343 388
             this.rightMenuCopyCmd.Text = "复制指令(&C)";
344 389
             this.rightMenuCopyCmd.Click += new System.EventHandler(this.rightMenuCopyCmd_Click);
345 390
             // 
346
-            // label6
347
-            // 
348
-            this.label6.AutoSize = true;
349
-            this.label6.Location = new System.Drawing.Point(6, 75);
350
-            this.label6.Name = "label6";
351
-            this.label6.Size = new System.Drawing.Size(35, 12);
352
-            this.label6.TabIndex = 14;
353
-            this.label6.Text = "回复:";
354
-            // 
355
-            // tfTmpResponse
356
-            // 
357
-            this.tfTmpResponse.Location = new System.Drawing.Point(47, 72);
358
-            this.tfTmpResponse.Name = "tfTmpResponse";
359
-            this.tfTmpResponse.Size = new System.Drawing.Size(321, 21);
360
-            this.tfTmpResponse.TabIndex = 15;
361
-            // 
362
-            // label7
363
-            // 
364
-            this.label7.AutoSize = true;
365
-            this.label7.Location = new System.Drawing.Point(374, 75);
366
-            this.label7.Name = "label7";
367
-            this.label7.Size = new System.Drawing.Size(29, 12);
368
-            this.label7.TabIndex = 16;
369
-            this.label7.Text = "发送";
370
-            // 
371 391
             // rightMenuClearInfo
372 392
             // 
373 393
             this.rightMenuClearInfo.Name = "rightMenuClearInfo";
374
-            this.rightMenuClearInfo.Size = new System.Drawing.Size(152, 22);
394
+            this.rightMenuClearInfo.Size = new System.Drawing.Size(140, 22);
375 395
             this.rightMenuClearInfo.Text = "清空信息(&L)";
376 396
             this.rightMenuClearInfo.Click += new System.EventHandler(this.rightMenuClearInfo_Click);
377 397
             // 
378 398
             // Form1
379 399
             // 
380
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
400
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
381 401
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
382
-            this.ClientSize = new System.Drawing.Size(907, 639);
402
+            this.ClientSize = new System.Drawing.Size(1058, 905);
383 403
             this.Controls.Add(this.groupBox2);
384 404
             this.Controls.Add(this.statusStrip1);
385 405
             this.Controls.Add(this.groupBox1);
386 406
             this.Controls.Add(this.menuStrip1);
407
+            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
387 408
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
409
+            this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
388 410
             this.Name = "Form1";
389 411
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
390 412
             this.Text = "Form1";

+ 59 - 15
GWSocketClient/Form1.cs Voir le fichier

@@ -107,21 +107,20 @@ namespace GWSocketClient
107 107
             int funcode = Utils.hexToTen(functionWord);
108 108
 
109 109
 
110
-            if (funcode >= 80 || funcode == 1 || funcode == 2)
110
+            if (funcode == 16 || funcode == 32)
111 111
             {
112
-                return;
113
-            }
114
-            funcode = funcode + 128;
115
-            functionWord = Utils.stringWith0(Utils.tenToHex(funcode), 2);
116
-            string cmd = reqData.Substring(0, 18) + functionWord;
117
-            string data = reqData.Substring(24, 10) + resp;
118
-            cmd = cmd + Utils.stringWith0(Utils.tenToHex(data.Length / 2), 4) + data;
119
-            cmd = Utils.calcCrcCode(cmd);
112
+                funcode = funcode + 128;
113
+                functionWord = Utils.stringWith0(Utils.tenToHex(funcode), 2);
114
+                string cmd = reqData.Substring(0, 18) + functionWord;
115
+                string data = reqData.Substring(24, 10) + resp;
116
+                cmd = cmd + Utils.stringWith0(Utils.tenToHex(data.Length / 2), 4) + data;
117
+                cmd = Utils.calcCrcCode(cmd);
120 118
 
121
-            addToListboxItem(string.Format("回复服务端{0}回应消息:[{1}]", sks.Ip, cmd));
119
+                addToListboxItem(string.Format("回复服务端{0}回应消息:[{1}]", sks.Ip, cmd));
122 120
 
123
-            byte[] ts = HexUtil.hexToBytes(cmd);
124
-            sockeTcpClients.SendData(ts);
121
+                byte[] ts = HexUtil.hexToBytes(cmd);
122
+                sockeTcpClients.SendData(ts);
123
+            }
125 124
         }
126 125
 
127 126
         private void tbEquipmentAddress_TextChanged(object sender, EventArgs e)
@@ -141,7 +140,12 @@ namespace GWSocketClient
141 140
                 sockeTcpClients.InitSocket(ip, int.Parse(port));
142 141
                 sockeTcpClients.Start();
143 142
 
144
-                string loginCmd = "7e7e7e4442832e833c8200143839383630324231313931353530343739383737f7";
143
+                //                string loginCmd = "7e7e7e4442832e833c8200143839383630324231313931353530343739383737f7";
144
+                string loginCmd = "7e7e7e";
145
+                loginCmd += tbEquipmentAddress.Text.Trim() + "82" +
146
+                            Utils.stringWith0(Utils.tenToHex(tbCCID.Text.Trim().Length / 2), 4);
147
+                loginCmd += tbCCID.Text.Trim();
148
+                loginCmd = Utils.calcCrcCode(loginCmd);
145 149
                 //发送登录命令
146 150
                 byte[] ts = HexUtil.hexToBytes(loginCmd);
147 151
 
@@ -171,6 +175,15 @@ namespace GWSocketClient
171 175
 
172 176
         private void tsmiLoadXml_Click(object sender, EventArgs e)
173 177
         {
178
+            OpenFileDialog ofd = new OpenFileDialog();
179
+            ofd.Filter = "XML文件|*.xml|所有文件|*.*";
180
+
181
+            if (ofd.ShowDialog() == DialogResult.OK)
182
+            {
183
+                string xmlFilepath = ofd.FileName;
184
+
185
+                vcarecityProtocolBean = new XmlLoader().load(xmlFilepath).getVcarecityPD();
186
+            }
174 187
         }
175 188
 
176 189
         private void btnSendData_Click(object sender, EventArgs e)
@@ -191,12 +204,12 @@ namespace GWSocketClient
191 204
         private void rightMenuCopyCmd_Click(object sender, EventArgs e)
192 205
         {
193 206
             int index = listBoxShow.SelectedIndex;
194
-            if (index > 0 && index < listBoxShow.Items.Count)
207
+            if (index >= 0 && index < listBoxShow.Items.Count)
195 208
             {
196 209
                 string info = listBoxShow.SelectedItem.ToString();
197 210
                 if (!info.Equals(""))
198 211
                 {
199
-                    if (info.Contains("["))
212
+                    if (info.Contains("[") || info.Contains("]"))
200 213
                     {
201 214
                         Regex reg = new Regex(@"\[\w+\]"); //注意里面的引号 要用双引号表示,而不是用反斜
202 215
                         Match match = reg.Match(info);
@@ -211,6 +224,10 @@ namespace GWSocketClient
211 224
                             Clipboard.SetDataObject(info);
212 225
                         }
213 226
                     }
227
+                    else
228
+                    {
229
+                        Clipboard.SetDataObject(info);
230
+                    }
214 231
                 }
215 232
             }
216 233
         }
@@ -231,5 +248,32 @@ namespace GWSocketClient
231 248
         {
232 249
             listBoxShow.Items.Clear();
233 250
         }
251
+
252
+        private void listBoxShow_DrawItem(object sender, DrawItemEventArgs e)
253
+        {
254
+            e.DrawBackground();
255
+            //
256
+            string res = listBoxShow.Items[e.Index].ToString().ToLower();
257
+            if (res.Contains("收到服务端"))
258
+            {
259
+                Font f = new Font("微软雅黑", e.Font.Size, FontStyle.Bold);
260
+
261
+                e.Graphics.DrawString(((ListBox) sender).Items[e.Index].ToString(), f, new SolidBrush(Color.Blue),
262
+                    e.Bounds);
263
+            }
264
+            else if (res.Contains("发送到服务端") || res.Contains("回复"))
265
+            {
266
+                Font f = new Font("微软雅黑", e.Font.Size, FontStyle.Italic);
267
+                e.Graphics.DrawString(((ListBox) sender).Items[e.Index].ToString(), f,
268
+                    new SolidBrush(Color.BlueViolet),
269
+                    e.Bounds);
270
+            }
271
+            else
272
+            {
273
+                e.Graphics.DrawString(((ListBox) sender).Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor),
274
+                    e.Bounds);
275
+            }
276
+            e.DrawFocusRectangle();
277
+        }
234 278
     }
235 279
 }

+ 1 - 1
GWSocketClient/GWSocketClient.csproj Voir le fichier

@@ -5,7 +5,7 @@
5 5
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 6
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 7
     <ProjectGuid>{1E7C256A-9CA5-4937-A5DD-7F281A2EBB21}</ProjectGuid>
8
-    <OutputType>Exe</OutputType>
8
+    <OutputType>WinExe</OutputType>
9 9
     <RootNamespace>GWSocketClient</RootNamespace>
10 10
     <AssemblyName>GWSocketClient</AssemblyName>
11 11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>

+ 1 - 1
GWSocketClient/Properties/AssemblyInfo.cs Voir le fichier

@@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
8 8
 [assembly: AssemblyTitle("GWSocketClient")]
9 9
 [assembly: AssemblyDescription("")]
10 10
 [assembly: AssemblyConfiguration("")]
11
-[assembly: AssemblyCompany("Microsoft")]
11
+[assembly: AssemblyCompany("Vcarecity")]
12 12
 [assembly: AssemblyProduct("GWSocketClient")]
13 13
 [assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
14 14
 [assembly: AssemblyTrademark("")]