Browse Source

在主窗口中添加按钮事件

wb_han 5 years ago
parent
commit
7171292c58

+ 73 - 4
HOZProject/FormHOZMain.Designer.cs

@@ -35,23 +35,31 @@
             this.label1 = new System.Windows.Forms.Label();
             this.plLeftContent = new System.Windows.Forms.Panel();
             this.plTop = new System.Windows.Forms.Panel();
+            this.pbStop = new System.Windows.Forms.PictureBox();
+            this.pbPause = new System.Windows.Forms.PictureBox();
+            this.pbStart = new System.Windows.Forms.PictureBox();
             this.pbMax = new System.Windows.Forms.PictureBox();
             this.pbMin = new System.Windows.Forms.PictureBox();
             this.pbClose = new System.Windows.Forms.PictureBox();
             this.pbLog = new System.Windows.Forms.PictureBox();
             this.pbInit = new System.Windows.Forms.PictureBox();
             this.pbSave = new System.Windows.Forms.PictureBox();
+            this.pbNew = new System.Windows.Forms.PictureBox();
             this.pbOpen = new System.Windows.Forms.PictureBox();
             this.plMain.SuspendLayout();
             this.plFill.SuspendLayout();
             this.plLeft.SuspendLayout();
             this.plTop.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pbStop)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbPause)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbStart)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbMax)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbMin)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbClose)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbLog)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbInit)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbSave)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbNew)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbOpen)).BeginInit();
             this.SuspendLayout();
             // 
@@ -127,12 +135,16 @@
             // plTop
             // 
             this.plTop.BackColor = System.Drawing.Color.Black;
+            this.plTop.Controls.Add(this.pbStop);
+            this.plTop.Controls.Add(this.pbPause);
+            this.plTop.Controls.Add(this.pbStart);
             this.plTop.Controls.Add(this.pbMax);
             this.plTop.Controls.Add(this.pbMin);
             this.plTop.Controls.Add(this.pbClose);
             this.plTop.Controls.Add(this.pbLog);
             this.plTop.Controls.Add(this.pbInit);
             this.plTop.Controls.Add(this.pbSave);
+            this.plTop.Controls.Add(this.pbNew);
             this.plTop.Controls.Add(this.pbOpen);
             this.plTop.Dock = System.Windows.Forms.DockStyle.Top;
             this.plTop.Location = new System.Drawing.Point(0, 0);
@@ -140,6 +152,41 @@
             this.plTop.Size = new System.Drawing.Size(1000, 80);
             this.plTop.TabIndex = 3;
             // 
+            // pbStop
+            // 
+            this.pbStop.BackgroundImage = global::HOZProject.Properties.Resources.Stop;
+            this.pbStop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
+            this.pbStop.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.pbStop.Location = new System.Drawing.Point(523, 6);
+            this.pbStop.Name = "pbStop";
+            this.pbStop.Size = new System.Drawing.Size(68, 71);
+            this.pbStop.TabIndex = 8;
+            this.pbStop.TabStop = false;
+            this.pbStop.Click += new System.EventHandler(this.pbStop_Click);
+            // 
+            // pbPause
+            // 
+            this.pbPause.BackgroundImage = global::HOZProject.Properties.Resources.Pause;
+            this.pbPause.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
+            this.pbPause.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.pbPause.Location = new System.Drawing.Point(449, 6);
+            this.pbPause.Name = "pbPause";
+            this.pbPause.Size = new System.Drawing.Size(68, 71);
+            this.pbPause.TabIndex = 8;
+            this.pbPause.TabStop = false;
+            // 
+            // pbStart
+            // 
+            this.pbStart.BackgroundImage = global::HOZProject.Properties.Resources.Start;
+            this.pbStart.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
+            this.pbStart.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.pbStart.Location = new System.Drawing.Point(375, 6);
+            this.pbStart.Name = "pbStart";
+            this.pbStart.Size = new System.Drawing.Size(68, 71);
+            this.pbStart.TabIndex = 8;
+            this.pbStart.TabStop = false;
+            this.pbStart.Click += new System.EventHandler(this.pbStart_Click);
+            // 
             // pbMax
             // 
             this.pbMax.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -185,7 +232,7 @@
             this.pbLog.BackgroundImage = global::HOZProject.Properties.Resources.Log;
             this.pbLog.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
             this.pbLog.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.pbLog.Location = new System.Drawing.Point(228, 6);
+            this.pbLog.Location = new System.Drawing.Point(301, 6);
             this.pbLog.Name = "pbLog";
             this.pbLog.Size = new System.Drawing.Size(68, 71);
             this.pbLog.TabIndex = 6;
@@ -197,7 +244,7 @@
             this.pbInit.BackgroundImage = global::HOZProject.Properties.Resources.init;
             this.pbInit.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
             this.pbInit.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.pbInit.Location = new System.Drawing.Point(154, 6);
+            this.pbInit.Location = new System.Drawing.Point(227, 6);
             this.pbInit.Name = "pbInit";
             this.pbInit.Size = new System.Drawing.Size(68, 71);
             this.pbInit.TabIndex = 5;
@@ -209,22 +256,36 @@
             this.pbSave.BackgroundImage = global::HOZProject.Properties.Resources.save;
             this.pbSave.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
             this.pbSave.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.pbSave.Location = new System.Drawing.Point(80, 6);
+            this.pbSave.Location = new System.Drawing.Point(153, 6);
             this.pbSave.Name = "pbSave";
             this.pbSave.Size = new System.Drawing.Size(68, 71);
             this.pbSave.TabIndex = 4;
             this.pbSave.TabStop = false;
+            this.pbSave.Click += new System.EventHandler(this.pbSave_Click);
+            // 
+            // pbNew
+            // 
+            this.pbNew.BackgroundImage = global::HOZProject.Properties.Resources.New;
+            this.pbNew.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
+            this.pbNew.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.pbNew.Location = new System.Drawing.Point(5, 6);
+            this.pbNew.Name = "pbNew";
+            this.pbNew.Size = new System.Drawing.Size(68, 71);
+            this.pbNew.TabIndex = 3;
+            this.pbNew.TabStop = false;
+            this.pbNew.Click += new System.EventHandler(this.pbNew_Click);
             // 
             // pbOpen
             // 
             this.pbOpen.BackgroundImage = global::HOZProject.Properties.Resources.open;
             this.pbOpen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
             this.pbOpen.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.pbOpen.Location = new System.Drawing.Point(6, 6);
+            this.pbOpen.Location = new System.Drawing.Point(79, 6);
             this.pbOpen.Name = "pbOpen";
             this.pbOpen.Size = new System.Drawing.Size(68, 71);
             this.pbOpen.TabIndex = 3;
             this.pbOpen.TabStop = false;
+            this.pbOpen.Click += new System.EventHandler(this.pbOpen_Click);
             // 
             // FormHOZMain
             // 
@@ -245,12 +306,16 @@
             this.plLeft.ResumeLayout(false);
             this.plLeft.PerformLayout();
             this.plTop.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.pbStop)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbPause)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbStart)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbMax)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbMin)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbClose)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbLog)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbInit)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbSave)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbNew)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbOpen)).EndInit();
             this.ResumeLayout(false);
 
@@ -271,5 +336,9 @@
         private System.Windows.Forms.PictureBox pbMin;
         private System.Windows.Forms.PictureBox pbClose;
         private System.Windows.Forms.PictureBox pbMax;
+        private System.Windows.Forms.PictureBox pbNew;
+        private System.Windows.Forms.PictureBox pbStart;
+        private System.Windows.Forms.PictureBox pbStop;
+        private System.Windows.Forms.PictureBox pbPause;
     }
 }

+ 145 - 29
HOZProject/FormHOZMain.cs

@@ -1,4 +1,7 @@
-using System;
+using FileManager;
+using MeasureData;
+using MeasureThread;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -12,14 +15,67 @@ namespace HOZProject
 {
     public partial class FormHOZMain : Form
     {
+        #region 成员变量
+        private BackgroundWorker m_BackgroundWorker;// 申明后台对象
+        /// <summary>
+        /// 测量文件
+        /// </summary>
+        public MeasureFile m_MeasureFile;
+
+        /// 测量线程  
+        public Measure m_Ms;
+
+        #endregion
+        #region 构造函数
         public FormHOZMain()
         {
             InitializeComponent();
+
+            m_BackgroundWorker = new BackgroundWorker(); // 实例化后台对象 
+            m_BackgroundWorker.WorkerReportsProgress = true; // 设置可以通告进度 
+            m_BackgroundWorker.WorkerSupportsCancellation = true; // 设置可以取消 
+            m_BackgroundWorker.DoWork += new DoWorkEventHandler(DoWork);
+            m_BackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(UpdateProgress);
+            m_BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompletedWork);
+
+            LogManager.InitManulLog();
+        }
+        #endregion
+        #region 测量线程
+        void DoWork(object sender, DoWorkEventArgs e)
+        {
+            m_Ms = new Measure();
+            m_Ms.InitMeas(m_MeasureFile);
+            m_Ms.SendThreadStatus += new ThreadStatusHandler(displayMessage); //注册事件
+
+            //自动测量的全过程
+            m_Ms.DoMeasure();
+            //定位
+            //切割
+            //分析位置
+            //截面
+        }
+
+        public void displayMessage(object sender, ThreadStatusEventArgs e)
+        {
+            //主界面显示内容
+            this.BeginInvoke((Action)delegate
+            {
+                //this.listmsg.Items.Add(e.Time.ToString() + e.State);
+            });
         }
+
+        void UpdateProgress(object sender, ProgressChangedEventArgs e)
+        {
+        }
+        void CompletedWork(object sender, RunWorkerCompletedEventArgs e)
+        {
+        }
+        #endregion
         
         private void FormHOZMain_Load(object sender, EventArgs e)
         {
-            CreateCutHoleList();
+            //CreateCutHoleList(5);
             //加载控件的点击事件
             this.Click += new EventHandler(FormHOZMain_Click);
             plFill.Click += new EventHandler(FormHOZMain_Click);
@@ -28,9 +84,9 @@ namespace HOZProject
             plLeftContent.Click += new EventHandler(FormHOZMain_Click);
         }
 
-        public void CreateCutHoleList()
+        public void CreateCutHoleList(int cutHoleCount)
         {
-            for (int i = 0; i < 5; i++)
+            for (int i = 0; i < cutHoleCount; i++)
             {
                 UControl_CutHole ucCutHole = new UControl_CutHole(this);
                 ucCutHole.Dock = DockStyle.Top;
@@ -46,31 +102,7 @@ namespace HOZProject
                 plProcess.Visible = false;
             }
         }
-
-        private void pbInit_Click(object sender, EventArgs e)
-        {
-            Form form = new Form();
-            form.StartPosition = FormStartPosition.CenterScreen;
-            UControl_Init uControl_Init = new UControl_Init();
-            form.FormBorderStyle = FormBorderStyle.None;
-            form.Width = uControl_Init.Width;
-            form.Height = uControl_Init.Height;
-            form.Controls.Add(uControl_Init);
-            form.ShowDialog();
-        }
-
-        private void pbLog_Click(object sender, EventArgs e)
-        {
-            Form form = new Form();
-            form.StartPosition = FormStartPosition.CenterScreen;
-            UControl_Log uControl_Log = new UControl_Log();
-            form.FormBorderStyle = FormBorderStyle.None;
-            form.Width = uControl_Log.Width;
-            form.Height = uControl_Log.Height;
-            form.Controls.Add(uControl_Log);
-            form.ShowDialog();
-        }
-
+        
         #region 窗体 最大化 最小化 关闭 按钮事件
         private void pbMin_MouseEnter(object sender, EventArgs e)
         {
@@ -114,6 +146,90 @@ namespace HOZProject
             }
             //窗体据中
             this.StartPosition = FormStartPosition.CenterScreen;
+        }
+        #endregion
+
+        #region 新建、保存、打开、初始化、查看日志
+        private void pbNew_Click(object sender, EventArgs e)
+        {
+            m_MeasureFile = new MeasureFile();
+            if (!m_MeasureFile.New())
+            {
+                return;
+            }
+            else
+            {
+                MessageBox.Show("新建测量文件成功。");
+            }
+        }
+
+        private void pbSave_Click(object sender, EventArgs e)
+        {
+            if (m_MeasureFile == null)
+            {
+                MessageBox.Show("请新建一个测量文件");
+            }
+            else
+            {
+                m_MeasureFile.Save();
+            }
+        }
+
+        private void pbOpen_Click(object sender, EventArgs e)
+        {
+
+        }
+
+        private void pbInit_Click(object sender, EventArgs e)
+        {
+            Form form = new Form();
+            form.StartPosition = FormStartPosition.CenterScreen;
+            UControl_Init uControl_Init = new UControl_Init(this);
+            form.FormBorderStyle = FormBorderStyle.None;
+            form.Width = uControl_Init.Width;
+            form.Height = uControl_Init.Height;
+            form.Controls.Add(uControl_Init);
+            form.ShowDialog();
+        }
+
+        private void pbLog_Click(object sender, EventArgs e)
+        {
+            Form form = new Form();
+            form.StartPosition = FormStartPosition.CenterScreen;
+            UControl_Log uControl_Log = new UControl_Log();
+            form.FormBorderStyle = FormBorderStyle.None;
+            form.Width = uControl_Log.Width;
+            form.Height = uControl_Log.Height;
+            form.Controls.Add(uControl_Log);
+            form.ShowDialog();
+        } 
+        #endregion
+
+        #region 开始、结束线程事件
+        private void pbStart_Click(object sender, EventArgs e)
+        {
+            if (m_MeasureFile == null)
+            {
+                MessageBox.Show("请新建一个测量文件");
+                //listmsg.Items.Clear();
+            }
+            else
+            {
+                if (m_BackgroundWorker.IsBusy)
+                {
+                    MessageBox.Show("线程已经运行");
+                    return;
+                }
+                m_BackgroundWorker.RunWorkerAsync(this);
+            }
+        }
+
+        private void pbStop_Click(object sender, EventArgs e)
+        {
+            if (m_BackgroundWorker.IsBusy)
+            {
+                m_BackgroundWorker.CancelAsync();
+            }
         } 
         #endregion
     }

+ 2 - 2
HOZProject/Program.cs

@@ -17,9 +17,9 @@ namespace HOZProject
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             //Application.Run(new FormUCMain());
-            //Application.Run(new FormHOZMain());
+            Application.Run(new FormHOZMain());
             //Application.Run(new FormMeasureTest());
-            Application.Run(new FormUnitControl());
+            //Application.Run(new FormUnitControl());
         }
     }
 }

+ 40 - 0
HOZProject/Properties/Resources.Designer.cs

@@ -190,6 +190,16 @@ namespace HOZProject.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap New {
+            get {
+                object obj = ResourceManager.GetObject("New", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>
@@ -220,6 +230,16 @@ namespace HOZProject.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap Pause {
+            get {
+                object obj = ResourceManager.GetObject("Pause", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>
@@ -240,6 +260,26 @@ namespace HOZProject.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap Start {
+            get {
+                object obj = ResourceManager.GetObject("Start", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap Stop {
+            get {
+                object obj = ResourceManager.GetObject("Stop", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>

+ 12 - 0
HOZProject/Properties/Resources.resx

@@ -175,4 +175,16 @@
   <data name="save" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="Pause" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\Pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="Start" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\Start.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="Stop" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\Stop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="New" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\New.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>

+ 12 - 0
HOZProject/UnitControl.csproj

@@ -244,5 +244,17 @@
   <ItemGroup>
     <None Include="Resources\Log.png" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\Pause.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\Start.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\Stop.png" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\New.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 103 - 56
HOZProject/UserControls/UControl_Init.Designer.cs

@@ -32,15 +32,18 @@
             this.label1 = new System.Windows.Forms.Label();
             this.panel1 = new System.Windows.Forms.Panel();
             this.tbCutHoleFilePath = new System.Windows.Forms.TextBox();
-            this.tbTemplateFilePath = new System.Windows.Forms.TextBox();
+            this.tBFIBTemp = new System.Windows.Forms.TextBox();
             this.label2 = new System.Windows.Forms.Label();
             this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.tBSampleName = new System.Windows.Forms.TextBox();
+            this.cBIsPT = new System.Windows.Forms.CheckBox();
             this.pbTemplateFile = new System.Windows.Forms.PictureBox();
             this.pbCutHoleFile = new System.Windows.Forms.PictureBox();
-            this.label4 = new System.Windows.Forms.Label();
-            this.tbSampleName = new System.Windows.Forms.TextBox();
-            this.checkBox1 = new System.Windows.Forms.CheckBox();
+            this.btnSave = new System.Windows.Forms.Button();
+            this.cBIsManul = new System.Windows.Forms.CheckBox();
             this.label5 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
             this.panel1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pbTemplateFile)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbCutHoleFile)).BeginInit();
@@ -82,31 +85,29 @@
             // tbCutHoleFilePath
             // 
             this.tbCutHoleFilePath.Font = new System.Drawing.Font("宋体", 10F);
-            this.tbCutHoleFilePath.Location = new System.Drawing.Point(17, 51);
+            this.tbCutHoleFilePath.Location = new System.Drawing.Point(78, 45);
             this.tbCutHoleFilePath.Name = "tbCutHoleFilePath";
             this.tbCutHoleFilePath.ReadOnly = true;
-            this.tbCutHoleFilePath.Size = new System.Drawing.Size(276, 23);
+            this.tbCutHoleFilePath.Size = new System.Drawing.Size(215, 23);
             this.tbCutHoleFilePath.TabIndex = 5;
-            this.tbCutHoleFilePath.Text = "导入切孔文件";
             // 
-            // tbTemplateFilePath
+            // tBFIBTemp
             // 
-            this.tbTemplateFilePath.Font = new System.Drawing.Font("宋体", 10F);
-            this.tbTemplateFilePath.Location = new System.Drawing.Point(17, 122);
-            this.tbTemplateFilePath.Name = "tbTemplateFilePath";
-            this.tbTemplateFilePath.ReadOnly = true;
-            this.tbTemplateFilePath.Size = new System.Drawing.Size(276, 23);
-            this.tbTemplateFilePath.TabIndex = 7;
-            this.tbTemplateFilePath.Text = "导入模板文件";
+            this.tBFIBTemp.Font = new System.Drawing.Font("宋体", 10F);
+            this.tBFIBTemp.Location = new System.Drawing.Point(78, 92);
+            this.tBFIBTemp.Name = "tBFIBTemp";
+            this.tBFIBTemp.ReadOnly = true;
+            this.tBFIBTemp.Size = new System.Drawing.Size(214, 23);
+            this.tBFIBTemp.TabIndex = 7;
             // 
             // label2
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("宋体", 10F);
             this.label2.ForeColor = System.Drawing.Color.LightGray;
-            this.label2.Location = new System.Drawing.Point(17, 91);
+            this.label2.Location = new System.Drawing.Point(77, 73);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(126, 14);
+            this.label2.Size = new System.Drawing.Size(112, 14);
             this.label2.TabIndex = 8;
             this.label2.Text = "成功导入0个切孔";
             // 
@@ -115,69 +116,109 @@
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("宋体", 10F);
             this.label3.ForeColor = System.Drawing.Color.LightGray;
-            this.label3.Location = new System.Drawing.Point(17, 162);
+            this.label3.Location = new System.Drawing.Point(77, 120);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(105, 14);
             this.label3.TabIndex = 9;
             this.label3.Text = "当前模板:XXXXX";
             // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("宋体", 10F);
+            this.label4.ForeColor = System.Drawing.Color.LightGray;
+            this.label4.Location = new System.Drawing.Point(24, 143);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(49, 14);
+            this.label4.TabIndex = 10;
+            this.label4.Text = "样品名";
+            // 
+            // tBSampleName
+            // 
+            this.tBSampleName.Font = new System.Drawing.Font("宋体", 10F);
+            this.tBSampleName.Location = new System.Drawing.Point(80, 139);
+            this.tBSampleName.Name = "tBSampleName";
+            this.tBSampleName.Size = new System.Drawing.Size(213, 23);
+            this.tBSampleName.TabIndex = 11;
+            // 
+            // cBIsPT
+            // 
+            this.cBIsPT.AutoSize = true;
+            this.cBIsPT.Font = new System.Drawing.Font("宋体", 10F);
+            this.cBIsPT.ForeColor = System.Drawing.Color.LightGray;
+            this.cBIsPT.Location = new System.Drawing.Point(80, 167);
+            this.cBIsPT.Name = "cBIsPT";
+            this.cBIsPT.Size = new System.Drawing.Size(96, 18);
+            this.cBIsPT.TabIndex = 12;
+            this.cBIsPT.Text = "是否使用PT";
+            this.cBIsPT.UseVisualStyleBackColor = true;
+            // 
             // pbTemplateFile
             // 
             this.pbTemplateFile.BackColor = System.Drawing.Color.LightGray;
-            this.pbTemplateFile.Location = new System.Drawing.Point(298, 122);
+            this.pbTemplateFile.Location = new System.Drawing.Point(297, 92);
             this.pbTemplateFile.Name = "pbTemplateFile";
             this.pbTemplateFile.Size = new System.Drawing.Size(77, 23);
             this.pbTemplateFile.TabIndex = 6;
             this.pbTemplateFile.TabStop = false;
+            this.pbTemplateFile.Click += new System.EventHandler(this.pbTemplateFile_Click);
             // 
             // pbCutHoleFile
             // 
             this.pbCutHoleFile.BackColor = System.Drawing.Color.LightGray;
-            this.pbCutHoleFile.Location = new System.Drawing.Point(298, 51);
+            this.pbCutHoleFile.Location = new System.Drawing.Point(298, 45);
             this.pbCutHoleFile.Name = "pbCutHoleFile";
             this.pbCutHoleFile.Size = new System.Drawing.Size(77, 23);
             this.pbCutHoleFile.TabIndex = 4;
             this.pbCutHoleFile.TabStop = false;
+            this.pbCutHoleFile.Click += new System.EventHandler(this.pbCutHoleFile_Click);
             // 
-            // label4
-            // 
-            this.label4.AutoSize = true;
-            this.label4.Font = new System.Drawing.Font("宋体", 10F);
-            this.label4.ForeColor = System.Drawing.Color.LightGray;
-            this.label4.Location = new System.Drawing.Point(17, 193);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(49, 14);
-            this.label4.TabIndex = 10;
-            this.label4.Text = "样品名";
-            // 
-            // tbSampleName
+            // btnSave
             // 
-            this.tbSampleName.Font = new System.Drawing.Font("宋体", 10F);
-            this.tbSampleName.Location = new System.Drawing.Point(69, 189);
-            this.tbSampleName.Name = "tbSampleName";
-            this.tbSampleName.Size = new System.Drawing.Size(224, 23);
-            this.tbSampleName.TabIndex = 11;
+            this.btnSave.Location = new System.Drawing.Point(297, 187);
+            this.btnSave.Name = "btnSave";
+            this.btnSave.Size = new System.Drawing.Size(75, 23);
+            this.btnSave.TabIndex = 14;
+            this.btnSave.Text = "保存";
+            this.btnSave.UseVisualStyleBackColor = true;
+            this.btnSave.Click += new System.EventHandler(this.button1_Click);
             // 
-            // checkBox1
+            // cBIsManul
             // 
-            this.checkBox1.AutoSize = true;
-            this.checkBox1.Font = new System.Drawing.Font("宋体", 9F);
-            this.checkBox1.Location = new System.Drawing.Point(17, 224);
-            this.checkBox1.Name = "checkBox1";
-            this.checkBox1.Size = new System.Drawing.Size(15, 14);
-            this.checkBox1.TabIndex = 12;
-            this.checkBox1.UseVisualStyleBackColor = true;
+            this.cBIsManul.AutoSize = true;
+            this.cBIsManul.Font = new System.Drawing.Font("宋体", 10F);
+            this.cBIsManul.ForeColor = System.Drawing.Color.LightGray;
+            this.cBIsManul.Location = new System.Drawing.Point(181, 167);
+            this.cBIsManul.Margin = new System.Windows.Forms.Padding(2);
+            this.cBIsManul.Name = "cBIsManul";
+            this.cBIsManul.Size = new System.Drawing.Size(82, 18);
+            this.cBIsManul.TabIndex = 15;
+            this.cBIsManul.Text = "手动对焦";
+            this.cBIsManul.UseVisualStyleBackColor = true;
             // 
             // label5
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("宋体", 10F);
             this.label5.ForeColor = System.Drawing.Color.LightGray;
-            this.label5.Location = new System.Drawing.Point(32, 224);
+            this.label5.Location = new System.Drawing.Point(17, 96);
+            this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(77, 14);
-            this.label5.TabIndex = 13;
-            this.label5.Text = "是否使用PT";
+            this.label5.Size = new System.Drawing.Size(56, 14);
+            this.label5.TabIndex = 16;
+            this.label5.Text = "FIB模板";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Font = new System.Drawing.Font("宋体", 10F);
+            this.label6.ForeColor = System.Drawing.Color.LightGray;
+            this.label6.Location = new System.Drawing.Point(10, 49);
+            this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(63, 14);
+            this.label6.TabIndex = 17;
+            this.label6.Text = "导入切孔";
             // 
             // UControl_Init
             // 
@@ -185,19 +226,22 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.Black;
             this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.Controls.Add(this.label6);
             this.Controls.Add(this.label5);
-            this.Controls.Add(this.checkBox1);
-            this.Controls.Add(this.tbSampleName);
+            this.Controls.Add(this.cBIsManul);
+            this.Controls.Add(this.btnSave);
+            this.Controls.Add(this.cBIsPT);
+            this.Controls.Add(this.tBSampleName);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.label2);
-            this.Controls.Add(this.tbTemplateFilePath);
+            this.Controls.Add(this.tBFIBTemp);
             this.Controls.Add(this.pbTemplateFile);
             this.Controls.Add(this.tbCutHoleFilePath);
             this.Controls.Add(this.pbCutHoleFile);
             this.Controls.Add(this.panel1);
             this.Name = "UControl_Init";
-            this.Size = new System.Drawing.Size(387, 252);
+            this.Size = new System.Drawing.Size(387, 222);
             this.panel1.ResumeLayout(false);
             this.panel1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pbTemplateFile)).EndInit();
@@ -214,13 +258,16 @@
         private System.Windows.Forms.Panel panel1;
         private System.Windows.Forms.PictureBox pbCutHoleFile;
         private System.Windows.Forms.TextBox tbCutHoleFilePath;
-        private System.Windows.Forms.TextBox tbTemplateFilePath;
+        private System.Windows.Forms.TextBox tBFIBTemp;
         private System.Windows.Forms.PictureBox pbTemplateFile;
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.TextBox tbSampleName;
-        private System.Windows.Forms.CheckBox checkBox1;
+        private System.Windows.Forms.TextBox tBSampleName;
+        private System.Windows.Forms.CheckBox cBIsPT;
+        private System.Windows.Forms.Button btnSave;
+        private System.Windows.Forms.CheckBox cBIsManul;
         private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.Label label6;
     }
 }

+ 79 - 1
HOZProject/UserControls/UControl_Init.cs

@@ -12,9 +12,12 @@ namespace HOZProject
 {
     public partial class UControl_Init : UserControl
     {
-        public UControl_Init()
+        private FormHOZMain formHOZMain;
+        public FormHOZMain FormHOZMainObject { get => formHOZMain; set => formHOZMain = value; }
+        public UControl_Init(FormHOZMain formHOZ)
         {
             InitializeComponent();
+            FormHOZMainObject = formHOZ;
         }
 
         private void btnClose_Click(object sender, EventArgs e)
@@ -22,5 +25,80 @@ namespace HOZProject
             Form fParent = this.ParentForm;
             fParent.Close();
         }
+
+        private void pbCutHoleFile_Click(object sender, EventArgs e)
+        {
+            if (FormHOZMainObject.m_MeasureFile == null)
+            {
+                MessageBox.Show("请新建一个测量文件");
+            }
+            else
+            {
+                if (!FormHOZMainObject.m_MeasureFile.GetCutHolesFromFile(""))
+                {
+                    MessageBox.Show("导入切孔失败");
+                }
+                else
+                {
+                    int cutHoleCount = FormHOZMainObject.m_MeasureFile.ListCutHole.Count;
+                    FormHOZMainObject.CreateCutHoleList(cutHoleCount);
+                }
+                //this.CutHoleGridView.Rows.Clear();
+                //List<CutHole> listHoles = m_MeasureFile.ListCutHole;
+                //foreach (CutHole hole in listHoles)
+                //{
+                //    //在CutHoleGridView中,添加切孔信息
+                //    int index = this.CutHoleGridView.Rows.Add();
+                //    this.CutHoleGridView.Rows[index].Cells[0].Value = hole.HoleName;
+
+                //    SemPosition pos = hole.Position;
+                //    this.CutHoleGridView.Rows[index].Cells[1].Value = pos.X;
+                //    this.CutHoleGridView.Rows[index].Cells[2].Value = pos.Y;
+                //    this.CutHoleGridView.Rows[index].Cells[3].Value = pos.Z;
+                //    this.CutHoleGridView.Rows[index].Cells[4].Value = pos.M;
+                //    this.CutHoleGridView.Rows[index].Cells[5].Value = pos.R;
+                //    this.CutHoleGridView.Rows[index].Cells[6].Value = pos.T;
+                //}
+            }
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            if (FormHOZMainObject.m_MeasureFile == null)
+            {
+                MessageBox.Show("请新建一个测量文件");
+                //this.listmsg.Items.Add("请新建一个测量文件");
+            }
+            else
+            {
+                FormHOZMainObject.m_MeasureFile.MParam.PT = this.cBIsPT.Checked;
+                FormHOZMainObject.m_MeasureFile.MParam.SampleName = this.tBSampleName.Text;
+                FormHOZMainObject.m_MeasureFile.MParam.FIBTemp = this.tBFIBTemp.Text;
+                FormHOZMainObject.m_MeasureFile.MParam.FocusMode = this.cBIsManul.Checked;
+
+                MessageBox.Show("参数设置成功");
+            }
+        }
+
+        private void pbTemplateFile_Click(object sender, EventArgs e)
+        {
+            string FilePathName;
+            string fileNameWithoutExtension;
+            //新建一个文件对话框
+            OpenFileDialog pOpenFileDialog = new OpenFileDialog();
+            //设置对话框标题
+            pOpenFileDialog.Title = "选择模板文件";
+            //设置打开文件类型
+            pOpenFileDialog.Filter = "ely文件(*.ely)|*.ely";
+            //监测文件是否存在
+            pOpenFileDialog.CheckFileExists = true;
+            //文件打开后执行以下程序
+            if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
+            {
+                FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName);  //绝对路径
+                fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FilePathName);
+                this.tBFIBTemp.Text = fileNameWithoutExtension;
+            }
+        }
     }
 }

+ 3 - 3
ManulDo/App.config

@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
     </startup>
-</configuration>
+</configuration>

+ 3 - 1
ManulDo/ManulDo.csproj

@@ -8,10 +8,11 @@
     <OutputType>WinExe</OutputType>
     <RootNamespace>WindowsFormsApp1</RootNamespace>
     <AssemblyName>ManulDo</AssemblyName>
-    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -65,6 +66,7 @@
     <Compile Include="Properties\Resources.Designer.cs">
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
     </Compile>
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>

+ 26 - 34
ManulDo/Properties/Resources.Designer.cs

@@ -1,69 +1,61 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
-//     运行时版本: 4.0.30319.42000
+//     运行时版本:4.0.30319.42000
 //
-//     对此文件的更改可能导致不正确的行为,如果
-//     重新生成代码,则所做更改将丢失。
+//     对此文件的更改可能导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace WindowsFormsApp1.Properties
-{
-
-
+namespace WindowsFormsApp1.Properties {
+    using System;
+    
+    
     /// <summary>
-    ///   强类型资源类,用于查找本地化字符串等。
+    ///   一个强类型资源类,用于查找本地化字符串等。
     /// </summary>
     // 此类是由 StronglyTypedResourceBuilder
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
-    // 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
+    internal class Resources {
+        
         private static global::System.Resources.ResourceManager resourceMan;
-
+        
         private static global::System.Globalization.CultureInfo resourceCulture;
-
+        
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
+        internal Resources() {
         }
-
+        
         /// <summary>
-        ///   返回此类使用的缓存 ResourceManager 实例。
+        ///   返回此类使用的缓存 ResourceManager 实例。
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-
+        
         /// <summary>
-        ///   覆盖当前线程的 CurrentUICulture 属性
-        ///   使用此强类型的资源类的资源查找
+        ///   重写当前线程的 CurrentUICulture 属性
+        ///   重写当前线程的 CurrentUICulture 属性
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
                 return resourceCulture;
             }
-            set
-            {
+            set {
                 resourceCulture = value;
             }
         }

+ 13 - 17
ManulDo/Properties/Settings.Designer.cs

@@ -1,28 +1,24 @@
 //------------------------------------------------------------------------------
 // <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 WindowsFormsApp1.Properties
-{
-
-
+namespace WindowsFormsApp1.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", "15.9.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;
             }
         }

+ 94 - 86
MeasureData/MeasureFile.cs

@@ -234,104 +234,112 @@ namespace MeasureData
         //从文件生成切割孔信息
         public bool GetCutHolesFromFile(string a_FilePathName)
         {
-            //清空原文件中的切孔
-            this.ListCutHole.Clear();
-
-            //弹出打开txt文件的对话矿
-            a_FilePathName.Trim();
-            if (string.IsNullOrEmpty(a_FilePathName))
+            try
             {
-                //新建一个文件对话框
-                OpenFileDialog pOpenFileDialog = new OpenFileDialog();
-                //设置对话框标题
-                pOpenFileDialog.Title = "打开电镜位置列表文件";
-                //设置打开文件类型
-                pOpenFileDialog.Filter = "txt文件(*.txt)|*.txt";
-                //监测文件是否存在
-                pOpenFileDialog.CheckFileExists = true;
-                //文件打开后执行以下程序
-                if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
-                {
-                    a_FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName);                             //绝对路径
-                 }
-            }
-
-            //按行取出txt文件
-            string[] lines = File.ReadAllLines(a_FilePathName, System.Text.Encoding.Default);
+                //清空原文件中的切孔
+                this.ListCutHole.Clear();
 
-            LogManager.AddHardwareLog("read " + lines.Count().ToString() + "lines",true);
-            //按现有的文件格式生成
-            string posMode = lines[1];
-            if (posMode.CompareTo(@"Absolute") != 0)
-            {
-                return false;
-            }
-
-            //解析切孔生成带有位置的切孔
-            //验证数量是否正确
-            int nNum = Convert.ToInt32(lines[3]);
-            int nLines = lines.Length;
-            if (nNum != (lines.Length - 4))
-            {
-                return false;
-            }
+                //弹出打开txt文件的对话矿
+                a_FilePathName.Trim();
+                if (string.IsNullOrEmpty(a_FilePathName))
+                {
+                    //新建一个文件对话框
+                    OpenFileDialog pOpenFileDialog = new OpenFileDialog();
+                    //设置对话框标题
+                    pOpenFileDialog.Title = "打开电镜位置列表文件";
+                    //设置打开文件类型
+                    pOpenFileDialog.Filter = "txt文件(*.txt)|*.txt";
+                    //监测文件是否存在
+                    pOpenFileDialog.CheckFileExists = true;
+                    //文件打开后执行以下程序
+                    if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
+                    {
+                        a_FilePathName = System.IO.Path.GetFullPath(pOpenFileDialog.FileName);                             //绝对路径
+                    }
+                }
 
-            //行内标识的个数及位置
-            string[] titles = lines[2].Split(',');
-            int numPos = titles.Length;
+                //按行取出txt文件
+                string[] lines = File.ReadAllLines(a_FilePathName, System.Text.Encoding.Default);
 
-            int nLabelPos = Array.IndexOf(titles, "Label");
-            int nXPos = Array.IndexOf(titles, "X");
-            int nYPos = Array.IndexOf(titles, "Y");
-            int nZPos = Array.IndexOf(titles, "Z");
-            int nTPos = Array.IndexOf(titles, "T");
-            int nRPos = Array.IndexOf(titles, "R");
-            int nMPos = Array.IndexOf(titles, "M");
+                LogManager.AddHardwareLog("read " + lines.Count().ToString() + "lines", true);
+                //按现有的文件格式生成
+                string posMode = lines[1];
+                if (posMode.CompareTo(@"Absolute") != 0)
+                {
+                    return false;
+                }
 
-            for (int i = 0; i < nNum; i++)
-            {
-                int currentLine = i + 4;
-                string currentString = lines[currentLine];
+                //解析切孔生成带有位置的切孔
+                //验证数量是否正确
+                int nNum = Convert.ToInt32(lines[3]);
+                int nLines = lines.Length;
+                if (nNum != (lines.Length - 4))
+                {
+                    return false;
+                }
 
-                LogManager.AddHardwareLog(currentString, true);
+                //行内标识的个数及位置
+                string[] titles = lines[2].Split(',');
+                int numPos = titles.Length;
 
-                string[] CurrentPos = currentString.Split(',');
-                int nCurrentPosNum = CurrentPos.Length;
+                int nLabelPos = Array.IndexOf(titles, "Label");
+                int nXPos = Array.IndexOf(titles, "X");
+                int nYPos = Array.IndexOf(titles, "Y");
+                int nZPos = Array.IndexOf(titles, "Z");
+                int nTPos = Array.IndexOf(titles, "T");
+                int nRPos = Array.IndexOf(titles, "R");
+                int nMPos = Array.IndexOf(titles, "M");
 
-                //当前行内的标识及位置个数不够
-                if (nCurrentPosNum != numPos)
+                for (int i = 0; i < nNum; i++)
                 {
-                    return false;
-                }
+                    int currentLine = i + 4;
+                    string currentString = lines[currentLine];
+
+                    LogManager.AddHardwareLog(currentString, true);
+
+                    string[] CurrentPos = currentString.Split(',');
+                    int nCurrentPosNum = CurrentPos.Length;
+
+                    //当前行内的标识及位置个数不够
+                    if (nCurrentPosNum != numPos)
+                    {
+                        return false;
+                    }
+
+                    //切孔标识
+                    CutHole CHole = new CutHole();
+                    CHole.HoleName = CurrentPos[nLabelPos];
+                    //切孔位置
+                    SemPosition holePos = new SemPosition();
+                    holePos.X = Convert.ToSingle(CurrentPos[nXPos]);
+                    holePos.Y = Convert.ToSingle(CurrentPos[nYPos]);
+                    holePos.Z = Convert.ToSingle(CurrentPos[nZPos]);
+                    holePos.M = Convert.ToSingle(CurrentPos[nMPos]);
+                    holePos.T = Convert.ToSingle(CurrentPos[nTPos]);
+                    holePos.R = Convert.ToSingle(CurrentPos[nRPos]);
+                    CHole.Position = holePos;
+                    //默认切割点均参与测试
+                    CHole.SWITCH = true;
+
+                    //更新切孔链表
+                    this.ListCutHole.Add(CHole);
+                    LogManager.AddHardwareLog("X =" + CurrentPos[nXPos]
+                        + "Y =" + CurrentPos[nYPos]
+                        + "Z =" + CurrentPos[nZPos]
+                        + "M =" + CurrentPos[nTPos]
+                        + "T =" + CurrentPos[nRPos]
+                        + "R =" + CurrentPos[nMPos]
+                        , true);
 
-                //切孔标识
-                CutHole CHole = new CutHole();
-                CHole.HoleName = CurrentPos[nLabelPos];
-                //切孔位置
-                SemPosition holePos = new SemPosition();                
-                holePos.X = Convert.ToSingle(CurrentPos[nXPos]);
-                holePos.Y = Convert.ToSingle(CurrentPos[nYPos]);
-                holePos.Z = Convert.ToSingle(CurrentPos[nZPos]);
-                holePos.M = Convert.ToSingle(CurrentPos[nMPos]);
-                holePos.T = Convert.ToSingle(CurrentPos[nTPos]);
-                holePos.R = Convert.ToSingle(CurrentPos[nRPos]);
-                CHole.Position = holePos;
-                //默认切割点均参与测试
-                CHole.SWITCH = true;
-
-                //更新切孔链表
-                this.ListCutHole.Add(CHole);
-                LogManager.AddHardwareLog("X =" + CurrentPos[nXPos]
-                    + "Y =" + CurrentPos[nYPos]
-                    + "Z =" + CurrentPos[nZPos]
-                    + "M =" + CurrentPos[nTPos]
-                    + "T =" + CurrentPos[nRPos]
-                    + "R =" + CurrentPos[nMPos]
-                    , true);
+                }
 
+                return true;
             }
-
-            return true;            
+            catch (Exception ex)
+            {
+                LogManager.LogError(ex.Message);
+                return false;
+            }         
         }