Explorar el Código

load properties file

张泳健 hace 8 años
padre
commit
be63cb2a49

BIN
.vs/GWSocketClient/v15/.suo Ver fichero


+ 1 - 0
GWSocketClient/Form1.Designer.cs Ver fichero

@@ -375,6 +375,7 @@
375 375
             this.listBoxShow.Size = new System.Drawing.Size(1106, 274);
376 376
             this.listBoxShow.TabIndex = 0;
377 377
             this.listBoxShow.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBoxShow_DrawItem);
378
+            this.listBoxShow.DoubleClick += new System.EventHandler(this.listBoxShow_DoubleClick);
378 379
             // 
379 380
             // cmslistboxRightMenu
380 381
             // 

+ 31 - 3
GWSocketClient/Form1.cs Ver fichero

@@ -257,7 +257,10 @@ namespace GWSocketClient
257 257
         private void addToListboxItem(object info)
258 258
         {
259 259
             if (listBoxShow.Items.Count > 1000)
260
-                listBoxShow.Items.Clear();
260
+            {
261
+                listBoxShow.Items.Remove(0);
262
+//                listBoxShow.Items.Clear();
263
+            }
261 264
 
262 265
             Console.WriteLine(info);
263 266
             listBoxShow.Items.Add(info);
@@ -306,13 +309,14 @@ namespace GWSocketClient
306 309
         /// </summary>
307 310
         private void btnPressureTest_Click(object sender, EventArgs e)
308 311
         {
309
-
310 312
             ip = tbIpaddress.Text.Trim();
311 313
             port = tbPort.Text.Trim();
312 314
 
315
+            int count = int.Parse(tbPresureTestCount.Text);
316
+
313 317
             ThreadPool.QueueUserWorkItem(o =>
314 318
             {
315
-                for (int i = 1024; i < 1024 + 100; i++)
319
+                for (int i = 1024; i < 1024 + count; i++)
316 320
                 {
317 321
                     SocketHelper.TcpClients clientx = new SocketHelper.TcpClients(); //初始化类库  
318 322
                     clientx.InitSocket(ip, int.Parse(port));
@@ -323,8 +327,32 @@ namespace GWSocketClient
323 327
                     loginCmd += "820014383938363032423131393135353034373938" + i;
324 328
                     loginCmd = Utils.calcCrcCode(loginCmd);
325 329
                     sockeTcpClients.SendData(HexUtil.hexToBytes(loginCmd));
330
+                    Thread.Sleep(200);
326 331
                 }
327 332
             });
328 333
         }
334
+
335
+        private void listBoxShow_DoubleClick(object sender, EventArgs e)
336
+        {
337
+            int index = listBoxShow.SelectedIndex;
338
+            if (index >= 0 && index < listBoxShow.Items.Count)
339
+            {
340
+                string info = listBoxShow.SelectedItem.ToString();
341
+                if (!info.Equals(""))
342
+                {
343
+                    if (info.Contains("[") || info.Contains("]"))
344
+                    {
345
+                        Regex reg = new Regex(@"\[\w+\]"); //注意里面的引号 要用双引号表示,而不是用反斜
346
+                        Match match = reg.Match(info);
347
+                        string ifs = match.ToString();
348
+                        ifs = ifs.Replace("[", "").Replace("]", "");
349
+                        if (!info.Equals(""))
350
+                        {
351
+                            MessageBox.Show(ifs);
352
+                        }
353
+                    }
354
+                }
355
+            }
356
+        }
329 357
     }
330 358
 }

+ 42 - 0
GWSocketClient/property/PropertiesLoader.cs Ver fichero

@@ -0,0 +1,42 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.IO;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+namespace GWSocketClient.property
9
+{
10
+    class PropertiesLoader
11
+    {
12
+        public Dictionary<string, string> PROPERTIES = new Dictionary<string, string>();
13
+
14
+        public PropertiesLoader()
15
+        {
16
+            string propertiesPath = @"";
17
+            loadPropertiesFile(propertiesPath);
18
+        }
19
+
20
+        public PropertiesLoader(string propertiesPath)
21
+        {
22
+            loadPropertiesFile(propertiesPath);
23
+        }
24
+
25
+        public PropertiesLoader loadPropertiesFile(string propertiesPath)
26
+        {
27
+            StreamReader sr = new StreamReader(propertiesPath);
28
+            string line = "";
29
+            while ((line = sr.ReadLine()) != null)
30
+            {
31
+                if (line.Trim().Equals(""))
32
+                    continue;
33
+
34
+                int post = line.IndexOf("=");
35
+                PROPERTIES.Add(line.Substring(0, post), line.Substring(post + 1));
36
+            }
37
+
38
+            sr.Close();
39
+            return this;
40
+        }
41
+    }
42
+}

+ 2 - 0
GWSocketClient/xml/XmlLoader.cs Ver fichero

@@ -62,6 +62,8 @@ namespace GWSocketClient.xml
62 62
             xmlNamespaceManager.AddNamespace("ns2", "http://www.example.org/GolfCountryClub");
63 63
 
64 64
             vcarecityPd = loadXml();
65
+
66
+            reader.Close();
65 67
         }
66 68
 
67 69
         public VcarecityPD loadXml()