Browse Source

添加配置文件默认值

wb_han 5 years ago
parent
commit
f8ec73f8c0

+ 31 - 0
HOZProject/App.config

@@ -4,13 +4,44 @@
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
     </startup>
     <appSettings>
+      <!--厂商_数据源-->
       <add key="Firm" value="厂商A,厂商B,厂商C,厂商D"/>
+      <!--样品类型_数据源-->
       <add key="Sample_Type" value="类型A,类型B,类型C"/>
+      <!--拍照的工作电压_数据源-->
       <add key="WPZD" value="100,200,300"/>
+      <!--拍照的放大倍数_数据源-->
       <add key="WPZF" value="100,200,300"/>
+      <!--定位切割位置的工作电压_数据源-->
       <add key="WQGD" value="100,200,300"/>
+      <!--定位切割位置的放大倍数_数据源-->
       <add key="WQGF" value="100,200,300"/>
+      <!--拉直操作需要的放大倍数_数据源-->
       <add key="WLZ" value="类型A,类型B,类型C"/>
       <add key="ConfigFilePath" value="E:/ConfigFile"/>
+      <!--PT使用的ELY文件-->
+      <add key="PT_ELYFile" value=""/>
+      <!--FIB使用的ELY文件-->
+      <add key="FIB_ELYFile" value=""/>
+      <!--拉直操作需要的放大倍数-->
+      <add key="Strectch_Magnification" value=""/>
+      <!--定位切割位置的放大倍数-->
+      <add key="Locatio_Magnification" value=""/>
+      <!--定位切割位置的工作电压-->
+      <add key="Location_Voltage" value=""/>
+      <!--拍照的放大倍数-->
+      <add key="Photograph_Magnification" value=""/>
+      <!--拍照的工作电压-->
+      <add key="Photograph_Voltage" value=""/>
+      <!--校正角度选择-->
+      <add key="Correction_Angle" value=""/>
+      <!--样品类型-->
+      <add key="Sample_Type" value=""/>
+      <!--厂商-->
+      <add key="Firm" value=""/>
+      <!--是否仅拍照-->
+      <add key="Is_Photograph" value=""/>
+      <!--是否PT沉积-->
+      <add key="PT_Depostion" value=""/>
     </appSettings>
 </configuration>

+ 35 - 19
HOZProject/UserControls/UControl_Init.Designer.cs

@@ -31,6 +31,7 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UControl_Init));
             this.label1 = new System.Windows.Forms.Label();
             this.panel1 = new System.Windows.Forms.Panel();
+            this.pbClose = new System.Windows.Forms.PictureBox();
             this.tbCutHoleFilePath = new System.Windows.Forms.TextBox();
             this.txtWPTF = new System.Windows.Forms.TextBox();
             this.lblCutHoleCount = new System.Windows.Forms.Label();
@@ -69,8 +70,9 @@
             this.pbFIBTemplateFile = new System.Windows.Forms.PictureBox();
             this.pbPTTemplateFile = new System.Windows.Forms.PictureBox();
             this.pbCutHoleFile = new System.Windows.Forms.PictureBox();
-            this.pbClose = new System.Windows.Forms.PictureBox();
+            this.btnSaveDefalutPara = new System.Windows.Forms.Button();
             this.panel1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pbClose)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbDelWLZ)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbDelWQGD)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbWQGFDel)).BeginInit();
@@ -82,7 +84,6 @@
             ((System.ComponentModel.ISupportInitialize)(this.pbFIBTemplateFile)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbPTTemplateFile)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbCutHoleFile)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.pbClose)).BeginInit();
             this.SuspendLayout();
             // 
             // label1
@@ -107,6 +108,20 @@
             this.panel1.Size = new System.Drawing.Size(576, 33);
             this.panel1.TabIndex = 3;
             // 
+            // pbClose
+            // 
+            this.pbClose.BackColor = System.Drawing.Color.Black;
+            this.pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
+            this.pbClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
+            this.pbClose.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.pbClose.Dock = System.Windows.Forms.DockStyle.Right;
+            this.pbClose.Location = new System.Drawing.Point(544, 0);
+            this.pbClose.Name = "pbClose";
+            this.pbClose.Size = new System.Drawing.Size(32, 33);
+            this.pbClose.TabIndex = 106;
+            this.pbClose.TabStop = false;
+            this.pbClose.Click += new System.EventHandler(this.btnClose_Click);
+            // 
             // tbCutHoleFilePath
             // 
             this.tbCutHoleFilePath.Font = new System.Drawing.Font("宋体", 10F);
@@ -315,7 +330,7 @@
             this.label54.Name = "label54";
             this.label54.Size = new System.Drawing.Size(91, 14);
             this.label54.TabIndex = 89;
-            this.label54.Text = "拍照放大数";
+            this.label54.Text = "拍照放大数";
             // 
             // label46
             // 
@@ -339,7 +354,7 @@
             this.label42.Name = "label42";
             this.label42.Size = new System.Drawing.Size(119, 14);
             this.label42.TabIndex = 87;
-            this.label42.Text = "定位切割放大数";
+            this.label42.Text = "定位切割放大数";
             // 
             // label38
             // 
@@ -351,7 +366,7 @@
             this.label38.Name = "label38";
             this.label38.Size = new System.Drawing.Size(119, 14);
             this.label38.TabIndex = 86;
-            this.label38.Text = "拉直操作放大数";
+            this.label38.Text = "拉直操作放大数";
             // 
             // chkWIsP
             // 
@@ -432,7 +447,7 @@
             // 
             this.btnCreateConfig.Cursor = System.Windows.Forms.Cursors.Hand;
             this.btnCreateConfig.ForeColor = System.Drawing.Color.Black;
-            this.btnCreateConfig.Location = new System.Drawing.Point(433, 381);
+            this.btnCreateConfig.Location = new System.Drawing.Point(14, 384);
             this.btnCreateConfig.Margin = new System.Windows.Forms.Padding(2);
             this.btnCreateConfig.Name = "btnCreateConfig";
             this.btnCreateConfig.Size = new System.Drawing.Size(135, 41);
@@ -593,19 +608,18 @@
             this.pbCutHoleFile.TabStop = false;
             this.pbCutHoleFile.Click += new System.EventHandler(this.pbCutHoleFile_Click);
             // 
-            // pbClose
+            // btnSaveDefalutPara
             // 
-            this.pbClose.BackColor = System.Drawing.Color.Black;
-            this.pbClose.BackgroundImage = global::HOZProject.Properties.Resources.exit_Gray;
-            this.pbClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
-            this.pbClose.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.pbClose.Dock = System.Windows.Forms.DockStyle.Right;
-            this.pbClose.Location = new System.Drawing.Point(544, 0);
-            this.pbClose.Name = "pbClose";
-            this.pbClose.Size = new System.Drawing.Size(32, 33);
-            this.pbClose.TabIndex = 106;
-            this.pbClose.TabStop = false;
-            this.pbClose.Click += new System.EventHandler(this.btnClose_Click);
+            this.btnSaveDefalutPara.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.btnSaveDefalutPara.ForeColor = System.Drawing.Color.Black;
+            this.btnSaveDefalutPara.Location = new System.Drawing.Point(432, 384);
+            this.btnSaveDefalutPara.Margin = new System.Windows.Forms.Padding(2);
+            this.btnSaveDefalutPara.Name = "btnSaveDefalutPara";
+            this.btnSaveDefalutPara.Size = new System.Drawing.Size(135, 41);
+            this.btnSaveDefalutPara.TabIndex = 112;
+            this.btnSaveDefalutPara.Text = "保存默认值";
+            this.btnSaveDefalutPara.UseVisualStyleBackColor = true;
+            this.btnSaveDefalutPara.Click += new System.EventHandler(this.btnSaveDefalutPara_Click);
             // 
             // UControl_Init
             // 
@@ -613,6 +627,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.Black;
             this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.Controls.Add(this.btnSaveDefalutPara);
             this.Controls.Add(this.label50);
             this.Controls.Add(this.pbDelWLZ);
             this.Controls.Add(this.pbDelWQGD);
@@ -659,6 +674,7 @@
             this.Load += new System.EventHandler(this.UControl_Init_Load);
             this.panel1.ResumeLayout(false);
             this.panel1.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pbClose)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbDelWLZ)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbDelWQGD)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbWQGFDel)).EndInit();
@@ -670,7 +686,6 @@
             ((System.ComponentModel.ISupportInitialize)(this.pbFIBTemplateFile)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbPTTemplateFile)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbCutHoleFile)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.pbClose)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -720,5 +735,6 @@
         private System.Windows.Forms.PictureBox pbDelWQGD;
         private System.Windows.Forms.PictureBox pbWQGFDel;
         private System.Windows.Forms.PictureBox pbDelWLZ;
+        private System.Windows.Forms.Button btnSaveDefalutPara;
     }
 }

+ 53 - 8
HOZProject/UserControls/UControl_Init.cs

@@ -140,6 +140,10 @@ namespace HOZProject
 
         #region 创建与读取样品参数文件
         private void btnCreateConfig_Click(object sender, EventArgs e)
+        {
+            SaveTemplateFile();
+        }
+        private void SaveTemplateFile()
         {
             ConfigFile cfm = new ConfigFile();
             cfm.Is_Photograph = chkWIsP.Checked;
@@ -176,12 +180,12 @@ namespace HOZProject
             //编辑Config文件
             EditConfig();
         }
-
         /// <summary>
         /// 编辑confing 文件信息
         /// </summary>
         public void EditConfig()
         {
+            //设置数据源信息
             //样品类型
             List<String> _sT = sT.ToList();
             if (_sT.IndexOf(cbbWYP.Text) < 0)
@@ -238,6 +242,42 @@ namespace HOZProject
                 string wWLZ = string.Join(",", _WLZ.ToArray());
                 config.AppSettings.Settings["WLZ"].Value = wWLZ;
             }
+
+            ConfigFile cfm = new ConfigFile();
+            cfm.Is_Photograph = chkWIsP.Checked;
+            cfm.PT_Depostion = chkWPT.Checked;
+            cfm.PT_ELYFile = txtWPTF.Text;
+            cfm.FIB_ELYFile = txtWFIBF.Text;
+            cfm.Stretch_Magnification = Convert.ToDouble(cbbWLZ.Text);
+            cfm.Location_Magnification = Convert.ToDouble(cbbWQGF.Text);
+            cfm.Location_Voltage = Convert.ToDouble(cbbWQGD.Text);
+            cfm.Photograph_Magnification = Convert.ToDouble(cbbWPZF.Text);
+            cfm.Photograph_Voltage = Convert.ToDouble(cbbWPZD.Text);
+            if (cbbWXZ.SelectedIndex == 0)
+            {
+                cfm.Correction_Angle = 36.0;
+            }
+            else
+            {
+                cfm.Correction_Angle = 54.0;
+            }
+            cfm.Sample_Type = cbbWYP.Text;
+            cfm.Firm = cbbWCS.Text;
+
+            //设置配置文件默认值
+            config.AppSettings.Settings["Is_Photograph"].Value = cfm.Is_Photograph.ToString();
+            config.AppSettings.Settings["PT_Depostion"].Value = cfm.PT_Depostion.ToString();
+            config.AppSettings.Settings["PT_ELYFile"].Value = cfm.PT_ELYFile;
+            config.AppSettings.Settings["FIB_ELYFile"].Value = cfm.FIB_ELYFile;
+            config.AppSettings.Settings["Stretch_Magnification"].Value = cfm.Stretch_Magnification.ToString();
+            config.AppSettings.Settings["Location_Magnification"].Value = cfm.Location_Magnification.ToString();
+            config.AppSettings.Settings["Location_Voltage"].Value = cfm.Location_Voltage.ToString();
+            config.AppSettings.Settings["Photograph_Magnification"].Value = cfm.Photograph_Magnification.ToString();
+            config.AppSettings.Settings["Photograph_Voltage"].Value = cfm.Photograph_Voltage.ToString();
+            config.AppSettings.Settings["Correction_Angle"].Value = cfm.Correction_Angle.ToString();
+            config.AppSettings.Settings["Sample_Type"].Value = cfm.Sample_Type;
+            config.AppSettings.Settings["Firm"].Value = cfm.Firm;
+
             config.Save(ConfigurationSaveMode.Modified);
             ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
             ReloadConfig();
@@ -340,13 +380,13 @@ namespace HOZProject
             cbbWQGF.Items.Clear();
             cbbWLZ.Items.Clear();
 
-            string sample_Type = ConfigurationManager.AppSettings["Sample_Type"];
-            string firm = ConfigurationManager.AppSettings["Firm"];
-            string WPZDTemp = ConfigurationManager.AppSettings["WPZD"];
-            string WPZFTemp = ConfigurationManager.AppSettings["WPZF"];
-            string WQGDTemp = ConfigurationManager.AppSettings["WQGD"];
-            string WQGFTemp = ConfigurationManager.AppSettings["WQGF"];
-            string WLZTemp = ConfigurationManager.AppSettings["WLZ"];
+            string sample_Type = config.AppSettings.Settings["Sample_Type"].ToString();
+            string firm = config.AppSettings.Settings["Firm"].ToString();
+            string WPZDTemp = config.AppSettings.Settings["WPZD"].ToString();
+            string WPZFTemp = config.AppSettings.Settings["WPZF"].ToString();
+            string WQGDTemp = config.AppSettings.Settings["WQGD"].ToString();
+            string WQGFTemp = config.AppSettings.Settings["WQGF"].ToString();
+            string WLZTemp = config.AppSettings.Settings["WLZ"].ToString();
             //样品类型
             sT = sample_Type.Split(',');
             BindComboxData(cbbWYP, sT);
@@ -456,5 +496,10 @@ namespace HOZProject
             }
         }
         #endregion
+
+        private void btnSaveDefalutPara_Click(object sender, EventArgs e)
+        {
+            EditConfig();
+        }
     }
 }

+ 1 - 1
MeasureData/ConfigFile.cs

@@ -45,7 +45,7 @@ namespace MeasureData
             set { this.fib_ELYFile = value; }
         }
 
-        //拉直操作需要的放大
+        //拉直操作需要的放大
         private double stretch_Magnification;
         public double Stretch_Magnification
         {