Selaa lähdekoodia

保存文件后,配置测量参数对象

wb_han 5 vuotta sitten
vanhempi
commit
ea7894e348
2 muutettua tiedostoa jossa 47 lisäystä ja 32 poistoa
  1. 2 0
      HOZProject/FormHOZMain.cs
  2. 45 32
      HOZProject/UserControls/UControl_Init.cs

+ 2 - 0
HOZProject/FormHOZMain.cs

@@ -286,6 +286,8 @@ namespace HOZProject
             else
             {
                 m_MeasureFile.Save();
+                //将初始化中的参数,配置到测量参数中
+                m_MeasureFile.MParam = uControl_Init.GetMeasureParamInfo();
             }
         }
 

+ 45 - 32
HOZProject/UserControls/UControl_Init.cs

@@ -97,18 +97,10 @@ namespace HOZProject
         #region 加载PT模板文件
         private void pbTemplateFile_Click(object sender, EventArgs e)
         {
-            //判断保存的路径是否存在
-            if (!Directory.Exists(m_TemplateFilePath))
-            {
-                //创建路径
-                Directory.CreateDirectory(m_TemplateFilePath);
-            }
             string FilePathName;
             string fileNameWithoutExtension;
             //新建一个文件对话框
             OpenFileDialog pOpenFileDialog = new OpenFileDialog();
-            //设置默认打开路径(绝对路径)
-            pOpenFileDialog.InitialDirectory =  m_TemplateFilePath;
             //设置对话框标题
             pOpenFileDialog.Title = "选择模板文件";
             //设置打开文件类型
@@ -129,18 +121,10 @@ namespace HOZProject
         #region 加载FIB模板文件
         private void pbFIBTemplateFile_Click(object sender, EventArgs e)
         {
-            //判断保存的路径是否存在
-            if (!Directory.Exists(m_TemplateFilePath))
-            {
-                //创建路径
-                Directory.CreateDirectory(m_TemplateFilePath);
-            }
             string FilePathName;
             string fileNameWithoutExtension;
             //新建一个文件对话框
             OpenFileDialog pOpenFileDialog = new OpenFileDialog();
-            //设置默认打开路径(绝对路径)
-            pOpenFileDialog.InitialDirectory = m_TemplateFilePath;
             //设置对话框标题
             pOpenFileDialog.Title = "选择模板文件";
             //设置打开文件类型
@@ -162,25 +146,55 @@ namespace HOZProject
         {
             SaveTemplateFile();
         }
-        private void SaveTemplateFile()
+        /// <summary>
+        /// 获取测量参数,初始化窗体中的控件信息
+        /// </summary>
+        /// <returns></returns>
+        public MeasureParam GetConfigInfo()
+        {
+            MeasureParam cfm = new MeasureParam();
+            cfm.Is_Photograph = chkWIsP.Checked;
+            cfm.PT = chkWPT.Checked;
+            cfm.PTTemp = txtWPTF.Text;
+            cfm.FIBTemp = txtWFIBF.Text;
+            cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
+            cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
+            cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
+            cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
+            cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
+            if (cbbWXZ.SelectedIndex == 0)
+            {
+                cfm.Correction_Angle = 36;
+            }
+            else
+            {
+                cfm.Correction_Angle = 54;
+            }
+
+            cfm.SampleName = cbbWYP.Text;
+            cfm.Firm = cbbWCS.Text;
+            return cfm;
+        }
+
+        public void SaveTemplateFile()
         {
             MeasureParam cfm = new MeasureParam();
             cfm.Is_Photograph = chkWIsP.Checked;
             cfm.PT = chkWPT.Checked;
             cfm.PTTemp = txtWPTF.Text;
             cfm.FIBTemp = 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);
+            cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
+            cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
+            cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
+            cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
+            cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
             if (cbbWXZ.SelectedIndex == 0)
             {
-                cfm.Correction_Angle = 36.0;
+                cfm.Correction_Angle = 36;
             }
             else
             {
-                cfm.Correction_Angle = 54.0;
+                cfm.Correction_Angle = 54;
             }
 
             cfm.SampleName = cbbWYP.Text;
@@ -279,20 +293,19 @@ namespace HOZProject
                 cfm.PT = chkWPT.Checked;
                 cfm.PTTemp = txtWPTF.Text;
                 cfm.FIBTemp = 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);
+                cfm.Stretch_Magnification = Convert.ToSingle(cbbWLZ.Text);
+                cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
+                cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
+                cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
+                cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
                 if (cbbWXZ.SelectedIndex == 0)
                 {
-                    cfm.Correction_Angle = 36.0;
+                    cfm.Correction_Angle = 36;
                 }
                 else
                 {
-                    cfm.Correction_Angle = 54.0;
+                    cfm.Correction_Angle = 54;
                 }
-                
 
                 cfm.SampleName = cbbWYP.Text;
                 cfm.Firm = cbbWCS.Text;