Browse Source

load properties file

张泳健 8 years ago
parent
commit
be63cb2a49

BIN
.vs/GWSocketClient/v15/.suo View File


+ 1 - 0
GWSocketClient/Form1.Designer.cs View File

375
             this.listBoxShow.Size = new System.Drawing.Size(1106, 274);
375
             this.listBoxShow.Size = new System.Drawing.Size(1106, 274);
376
             this.listBoxShow.TabIndex = 0;
376
             this.listBoxShow.TabIndex = 0;
377
             this.listBoxShow.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBoxShow_DrawItem);
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
             // cmslistboxRightMenu
380
             // cmslistboxRightMenu
380
             // 
381
             // 

+ 31 - 3
GWSocketClient/Form1.cs View File

257
         private void addToListboxItem(object info)
257
         private void addToListboxItem(object info)
258
         {
258
         {
259
             if (listBoxShow.Items.Count > 1000)
259
             if (listBoxShow.Items.Count > 1000)
260
-                listBoxShow.Items.Clear();
260
+            {
261
+                listBoxShow.Items.Remove(0);
262
+//                listBoxShow.Items.Clear();
263
+            }
261
 
264
 
262
             Console.WriteLine(info);
265
             Console.WriteLine(info);
263
             listBoxShow.Items.Add(info);
266
             listBoxShow.Items.Add(info);
306
         /// </summary>
309
         /// </summary>
307
         private void btnPressureTest_Click(object sender, EventArgs e)
310
         private void btnPressureTest_Click(object sender, EventArgs e)
308
         {
311
         {
309
-
310
             ip = tbIpaddress.Text.Trim();
312
             ip = tbIpaddress.Text.Trim();
311
             port = tbPort.Text.Trim();
313
             port = tbPort.Text.Trim();
312
 
314
 
315
+            int count = int.Parse(tbPresureTestCount.Text);
316
+
313
             ThreadPool.QueueUserWorkItem(o =>
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
                     SocketHelper.TcpClients clientx = new SocketHelper.TcpClients(); //初始化类库  
321
                     SocketHelper.TcpClients clientx = new SocketHelper.TcpClients(); //初始化类库  
318
                     clientx.InitSocket(ip, int.Parse(port));
322
                     clientx.InitSocket(ip, int.Parse(port));
323
                     loginCmd += "820014383938363032423131393135353034373938" + i;
327
                     loginCmd += "820014383938363032423131393135353034373938" + i;
324
                     loginCmd = Utils.calcCrcCode(loginCmd);
328
                     loginCmd = Utils.calcCrcCode(loginCmd);
325
                     sockeTcpClients.SendData(HexUtil.hexToBytes(loginCmd));
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 View File

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 View File

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