Browse Source

添加缓存字段

章政 7 years ago
parent
commit
cf127043d9

+ 15 - 0
UAS_CheckWork/App.config

@@ -1,6 +1,21 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <configuration>
+    <configSections>
+        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+            <section name="UAS_CheckWork.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+        </sectionGroup>
+    </configSections>
     <startup> 
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
     </startup>
+    <userSettings>
+        <UAS_CheckWork.Properties.Settings>
+            <setting name="IP" serializeAs="String">
+                <value />
+            </setting>
+            <setting name="Port" serializeAs="String">
+                <value />
+            </setting>
+        </UAS_CheckWork.Properties.Settings>
+    </userSettings>
 </configuration>

+ 0 - 2
UAS_CheckWork/Form1.Designer.cs

@@ -74,7 +74,6 @@
             this.txtPort.Name = "txtPort";
             this.txtPort.Size = new System.Drawing.Size(37, 21);
             this.txtPort.TabIndex = 12;
-            this.txtPort.Text = "4370";
             // 
             // txtIP
             // 
@@ -83,7 +82,6 @@
             this.txtIP.Name = "txtIP";
             this.txtIP.Size = new System.Drawing.Size(99, 21);
             this.txtIP.TabIndex = 11;
-            this.txtIP.Text = "192.168.253.201";
             // 
             // btnConnect
             // 

+ 14 - 6
UAS_CheckWork/Form1.cs

@@ -11,7 +11,7 @@ namespace UAS_CheckWork
 {
     public partial class Form1 : Form
     {
-     
+
         DataHelper dh;
         //Create Standalone SDK class dynamicly.
         public zkemkeeper.CZKEMClass axCZKEM1 = new zkemkeeper.CZKEMClass();
@@ -26,8 +26,19 @@ namespace UAS_CheckWork
             StartPosition = FormStartPosition.CenterScreen;
         }
 
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            CheckForIllegalCrossThreadCalls = false;//可跨线程
+            txtIP.Text = Properties.Settings.Default.IP;
+            txtPort.Text = Properties.Settings.Default.Port;
+            dh = new DataHelper();
+        }
+
         private void btnConnect_Click(object sender, EventArgs e)
         {
+            Properties.Settings.Default.IP = txtIP.Text;
+            Properties.Settings.Default.Port = txtPort.Text;
+            Properties.Settings.Default.Save();
             if (txtIP.Text.Trim() == "" || txtPort.Text.Trim() == "")
             {
                 MessageBox.Show("请先输入IP和端口", "Error");
@@ -69,6 +80,7 @@ namespace UAS_CheckWork
                 MessageBox.Show("请先连接设备", "Error");
                 return;
             }
+       
             InitGetInfo = new Thread(InPrint);
             SetLoadingWindow stw = new SetLoadingWindow(InitGetInfo, "正在同步数据...");
             stw.StartPosition = FormStartPosition.CenterParent;
@@ -128,11 +140,7 @@ namespace UAS_CheckWork
             }
         }
 
-        private void Form1_Load(object sender, EventArgs e)
-        {
-            CheckForIllegalCrossThreadCalls = false;//可跨线程
-            dh = new DataHelper();
-        }
+    
 
         private void saveData_Click(object sender, EventArgs e)
         {

+ 37 - 17
UAS_CheckWork/Properties/Settings.Designer.cs

@@ -1,30 +1,50 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
 //
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace UAS_CheckWork.Properties
-{
-
-
+namespace UAS_CheckWork.Properties {
+    
+    
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
+        
+        public static Settings Default {
+            get {
                 return defaultInstance;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("")]
+        public string IP {
+            get {
+                return ((string)(this["IP"]));
+            }
+            set {
+                this["IP"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("")]
+        public string Port {
+            get {
+                return ((string)(this["Port"]));
+            }
+            set {
+                this["Port"] = value;
+            }
+        }
     }
 }

+ 11 - 6
UAS_CheckWork/Properties/Settings.settings

@@ -1,7 +1,12 @@
 <?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
-  <Profiles>
-    <Profile Name="(Default)" />
-  </Profiles>
-  <Settings />
-</SettingsFile>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="UAS_CheckWork.Properties" GeneratedClassName="Settings">
+  <Profiles />
+  <Settings>
+    <Setting Name="IP" Type="System.String" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="Port" Type="System.String" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+  </Settings>
+</SettingsFile>