Sfoglia il codice sorgente

修改布局与添加自动校准

wb_han 5 anni fa
parent
commit
6bdd2e052f

+ 72 - 70
HOZProject/FormShowImage.Designer.cs

@@ -32,13 +32,13 @@
             this.picexit = new System.Windows.Forms.PictureBox();
             this.pbImage = new System.Windows.Forms.PictureBox();
             this.plImageInfo = new System.Windows.Forms.Panel();
-            this.lblWD = new System.Windows.Forms.Label();
+            this.lblContent = new System.Windows.Forms.Label();
             this.lblMag = new System.Windows.Forms.Label();
-            this.lblHT = new System.Windows.Forms.Label();
+            this.lblKV = new System.Windows.Forms.Label();
             this.panel1 = new System.Windows.Forms.Panel();
-            this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            this.label3 = new System.Windows.Forms.Label();
+            this.lblAutoContent = new System.Windows.Forms.Label();
+            this.lblAutoMag = new System.Windows.Forms.Label();
+            this.lblAutoKV = new System.Windows.Forms.Label();
             this.pbAutoImage = new System.Windows.Forms.PictureBox();
             ((System.ComponentModel.ISupportInitialize)(this.pichide)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.picexit)).BeginInit();
@@ -85,32 +85,33 @@
             this.pbImage.Margin = new System.Windows.Forms.Padding(4);
             this.pbImage.Name = "pbImage";
             this.pbImage.Size = new System.Drawing.Size(768, 576);
+            this.pbImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             this.pbImage.TabIndex = 59;
             this.pbImage.TabStop = false;
             // 
             // plImageInfo
             // 
             this.plImageInfo.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(183)))), ((int)(((byte)(183)))), ((int)(((byte)(183)))));
-            this.plImageInfo.Controls.Add(this.lblWD);
+            this.plImageInfo.Controls.Add(this.lblContent);
             this.plImageInfo.Controls.Add(this.lblMag);
-            this.plImageInfo.Controls.Add(this.lblHT);
+            this.plImageInfo.Controls.Add(this.lblKV);
             this.plImageInfo.Location = new System.Drawing.Point(4, 620);
             this.plImageInfo.Margin = new System.Windows.Forms.Padding(4);
             this.plImageInfo.Name = "plImageInfo";
             this.plImageInfo.Size = new System.Drawing.Size(768, 64);
             this.plImageInfo.TabIndex = 60;
             // 
-            // lblWD
+            // lblContent
             // 
-            this.lblWD.AutoSize = true;
-            this.lblWD.Font = new System.Drawing.Font("宋体", 12F);
-            this.lblWD.ForeColor = System.Drawing.Color.White;
-            this.lblWD.Location = new System.Drawing.Point(532, 20);
-            this.lblWD.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.lblWD.Name = "lblWD";
-            this.lblWD.Size = new System.Drawing.Size(190, 24);
-            this.lblWD.TabIndex = 1;
-            this.lblWD.Text = "工作距离:8.2mm";
+            this.lblContent.AutoSize = true;
+            this.lblContent.Font = new System.Drawing.Font("宋体", 12F);
+            this.lblContent.ForeColor = System.Drawing.Color.White;
+            this.lblContent.Location = new System.Drawing.Point(532, 20);
+            this.lblContent.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.lblContent.Name = "lblContent";
+            this.lblContent.Size = new System.Drawing.Size(190, 24);
+            this.lblContent.TabIndex = 1;
+            this.lblContent.Text = "工作距离:8.2mm";
             // 
             // lblMag
             // 
@@ -124,65 +125,65 @@
             this.lblMag.TabIndex = 1;
             this.lblMag.Text = "放大倍数:200X";
             // 
-            // lblHT
+            // lblKV
             // 
-            this.lblHT.AutoSize = true;
-            this.lblHT.Font = new System.Drawing.Font("宋体", 12F);
-            this.lblHT.ForeColor = System.Drawing.Color.White;
-            this.lblHT.Location = new System.Drawing.Point(32, 20);
-            this.lblHT.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.lblHT.Name = "lblHT";
-            this.lblHT.Size = new System.Drawing.Size(130, 24);
-            this.lblHT.TabIndex = 1;
-            this.lblHT.Text = "电压:20KV";
+            this.lblKV.AutoSize = true;
+            this.lblKV.Font = new System.Drawing.Font("宋体", 12F);
+            this.lblKV.ForeColor = System.Drawing.Color.White;
+            this.lblKV.Location = new System.Drawing.Point(32, 20);
+            this.lblKV.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.lblKV.Name = "lblKV";
+            this.lblKV.Size = new System.Drawing.Size(130, 24);
+            this.lblKV.TabIndex = 1;
+            this.lblKV.Text = "电压:20KV";
             // 
             // panel1
             // 
             this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(183)))), ((int)(((byte)(183)))), ((int)(((byte)(183)))));
-            this.panel1.Controls.Add(this.label1);
-            this.panel1.Controls.Add(this.label2);
-            this.panel1.Controls.Add(this.label3);
+            this.panel1.Controls.Add(this.lblAutoContent);
+            this.panel1.Controls.Add(this.lblAutoMag);
+            this.panel1.Controls.Add(this.lblAutoKV);
             this.panel1.Location = new System.Drawing.Point(775, 620);
             this.panel1.Margin = new System.Windows.Forms.Padding(4);
             this.panel1.Name = "panel1";
             this.panel1.Size = new System.Drawing.Size(768, 64);
             this.panel1.TabIndex = 62;
             // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Font = new System.Drawing.Font("宋体", 12F);
-            this.label1.ForeColor = System.Drawing.Color.White;
-            this.label1.Location = new System.Drawing.Point(522, 20);
-            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(190, 24);
-            this.label1.TabIndex = 1;
-            this.label1.Text = "工作距离:8.2mm";
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("宋体", 12F);
-            this.label2.ForeColor = System.Drawing.Color.White;
-            this.label2.Location = new System.Drawing.Point(258, 20);
-            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(178, 24);
-            this.label2.TabIndex = 1;
-            this.label2.Text = "放大倍数:200X";
-            // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Font = new System.Drawing.Font("宋体", 12F);
-            this.label3.ForeColor = System.Drawing.Color.White;
-            this.label3.Location = new System.Drawing.Point(32, 20);
-            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(130, 24);
-            this.label3.TabIndex = 1;
-            this.label3.Text = "电压:20KV";
+            // lblAutoContent
+            // 
+            this.lblAutoContent.AutoSize = true;
+            this.lblAutoContent.Font = new System.Drawing.Font("宋体", 12F);
+            this.lblAutoContent.ForeColor = System.Drawing.Color.White;
+            this.lblAutoContent.Location = new System.Drawing.Point(522, 20);
+            this.lblAutoContent.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.lblAutoContent.Name = "lblAutoContent";
+            this.lblAutoContent.Size = new System.Drawing.Size(190, 24);
+            this.lblAutoContent.TabIndex = 1;
+            this.lblAutoContent.Text = "工作距离:8.2mm";
+            // 
+            // lblAutoMag
+            // 
+            this.lblAutoMag.AutoSize = true;
+            this.lblAutoMag.Font = new System.Drawing.Font("宋体", 12F);
+            this.lblAutoMag.ForeColor = System.Drawing.Color.White;
+            this.lblAutoMag.Location = new System.Drawing.Point(258, 20);
+            this.lblAutoMag.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.lblAutoMag.Name = "lblAutoMag";
+            this.lblAutoMag.Size = new System.Drawing.Size(178, 24);
+            this.lblAutoMag.TabIndex = 1;
+            this.lblAutoMag.Text = "放大倍数:200X";
+            // 
+            // lblAutoKV
+            // 
+            this.lblAutoKV.AutoSize = true;
+            this.lblAutoKV.Font = new System.Drawing.Font("宋体", 12F);
+            this.lblAutoKV.ForeColor = System.Drawing.Color.White;
+            this.lblAutoKV.Location = new System.Drawing.Point(32, 20);
+            this.lblAutoKV.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.lblAutoKV.Name = "lblAutoKV";
+            this.lblAutoKV.Size = new System.Drawing.Size(130, 24);
+            this.lblAutoKV.TabIndex = 1;
+            this.lblAutoKV.Text = "电压:20KV";
             // 
             // pbAutoImage
             // 
@@ -191,6 +192,7 @@
             this.pbAutoImage.Margin = new System.Windows.Forms.Padding(4);
             this.pbAutoImage.Name = "pbAutoImage";
             this.pbAutoImage.Size = new System.Drawing.Size(768, 576);
+            this.pbAutoImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             this.pbAutoImage.TabIndex = 61;
             this.pbAutoImage.TabStop = false;
             // 
@@ -231,13 +233,13 @@
         private System.Windows.Forms.PictureBox pichide;
         private System.Windows.Forms.PictureBox picexit;
         private System.Windows.Forms.Panel plImageInfo;
-        private System.Windows.Forms.Label lblHT;
-        private System.Windows.Forms.Label lblWD;
+        private System.Windows.Forms.Label lblKV;
+        private System.Windows.Forms.Label lblContent;
         private System.Windows.Forms.Label lblMag;
         private System.Windows.Forms.Panel panel1;
-        private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label lblAutoContent;
+        private System.Windows.Forms.Label lblAutoMag;
+        private System.Windows.Forms.Label lblAutoKV;
         public System.Windows.Forms.PictureBox pbImage;
         public System.Windows.Forms.PictureBox pbAutoImage;
     }

+ 32 - 12
HOZProject/FormShowImage.cs

@@ -21,18 +21,18 @@ namespace HOZProject
         /// <summary>
         /// 电压
         /// </summary>
-        private float kv;
-        public float Kv { get => kv; set => kv = value; }
+        private string kv;
+        public string Kv { get => kv; set => kv = value; }
         /// <summary>
         /// 放大倍数
         /// </summary>
-        private float mag;
-        public float Mag { get => mag; set => mag = value; }
+        private string mag;
+        public string Mag { get => mag; set => mag = value; }
         /// <summary>
         /// 属性信息(工作距离、消像散、亮度、对比度)
         /// </summary>
-        private float content;
-        public float Content { get => content; set => content = value; }
+        private string content;
+        public string Content { get => content; set => content = value; }
 
         /// <summary>
         /// Auto后显示的图像
@@ -42,18 +42,18 @@ namespace HOZProject
         /// <summary>
         /// Auto后电压
         /// </summary>
-        private float autoKv;
-        public float AutoKv { get => autoKv; set => autoKv = value; }
+        private string autoKv;
+        public string AutoKv { get => autoKv; set => autoKv = value; }
         /// <summary>
         /// Auto后放大倍数
         /// </summary>
-        private float autoMag;
-        public float AutoMag { get => autoMag; set => autoMag = value; }
+        private string autoMag;
+        public string AutoMag { get => autoMag; set => autoMag = value; }
         /// <summary>
         /// Auto后属性信息(工作距离、消像散、亮度、对比度)
         /// </summary>
-        private float autoContent;
-        public float AutoContent { get => autoContent; set => autoContent = value; }
+        private string autoContent;
+        public string AutoContent { get => autoContent; set => autoContent = value; }
         #endregion
 
 
@@ -95,5 +95,25 @@ namespace HOZProject
         {
             this.Close();
         }
+
+        #region 设置当前图像参数
+        public void SetParaInfo()
+        {
+            lblKV.Text = Kv;
+            lblMag.Text = Mag;
+            lblContent.Text = Content;
+
+            lblAutoKV.Text = "";
+            lblAutoMag.Text = "";
+            lblAutoContent.Text = "";
+        }
+
+        public void SetAutoParaInfo()
+        {
+            lblAutoKV.Text = AutoKv;
+            lblAutoMag.Text = AutoMag;
+            lblAutoContent.Text = AutoContent;
+        } 
+        #endregion
     }
 }

+ 7 - 40
HOZProject/FormUCMain.Designer.cs

@@ -108,10 +108,8 @@
             this.label22 = new System.Windows.Forms.Label();
             this.label23 = new System.Windows.Forms.Label();
             this.label24 = new System.Windows.Forms.Label();
-            this.pictureBox1 = new System.Windows.Forms.PictureBox();
             this.btnAutoWD = new System.Windows.Forms.Button();
             this.btnAutoAstigmatism = new System.Windows.Forms.Button();
-            this.btnContrast = new System.Windows.Forms.Button();
             this.btnAutoBrightness = new System.Windows.Forms.Button();
             this.btnGetStagePosition = new System.Windows.Forms.Button();
             this.pbHT = new System.Windows.Forms.PictureBox();
@@ -165,7 +163,6 @@
             this.panel14.SuspendLayout();
             this.panel15.SuspendLayout();
             this.panel16.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbHT)).BeginInit();
             this.panel6.SuspendLayout();
             this.panel20.SuspendLayout();
@@ -1188,21 +1185,12 @@
             this.label24.TabIndex = 78;
             this.label24.Text = "PT功能设置";
             // 
-            // pictureBox1
-            // 
-            this.pictureBox1.Location = new System.Drawing.Point(18, 39);
-            this.pictureBox1.Margin = new System.Windows.Forms.Padding(4);
-            this.pictureBox1.Name = "pictureBox1";
-            this.pictureBox1.Size = new System.Drawing.Size(250, 136);
-            this.pictureBox1.TabIndex = 79;
-            this.pictureBox1.TabStop = false;
-            // 
             // btnAutoWD
             // 
             this.btnAutoWD.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
             this.btnAutoWD.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
             this.btnAutoWD.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.btnAutoWD.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
+            this.btnAutoWD.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.btnAutoWD.Font = new System.Drawing.Font("宋体", 9F);
             this.btnAutoWD.ForeColor = System.Drawing.Color.White;
             this.btnAutoWD.Location = new System.Drawing.Point(1200, 327);
@@ -1219,7 +1207,7 @@
             this.btnAutoAstigmatism.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
             this.btnAutoAstigmatism.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
             this.btnAutoAstigmatism.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.btnAutoAstigmatism.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
+            this.btnAutoAstigmatism.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.btnAutoAstigmatism.Font = new System.Drawing.Font("宋体", 9F);
             this.btnAutoAstigmatism.ForeColor = System.Drawing.Color.White;
             this.btnAutoAstigmatism.Location = new System.Drawing.Point(1200, 357);
@@ -1229,37 +1217,22 @@
             this.btnAutoAstigmatism.TabIndex = 80;
             this.btnAutoAstigmatism.Text = " 自动消像散";
             this.btnAutoAstigmatism.UseVisualStyleBackColor = true;
-            // 
-            // btnContrast
-            // 
-            this.btnContrast.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
-            this.btnContrast.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.btnContrast.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.btnContrast.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
-            this.btnContrast.Font = new System.Drawing.Font("宋体", 9F);
-            this.btnContrast.ForeColor = System.Drawing.Color.White;
-            this.btnContrast.Location = new System.Drawing.Point(1318, 357);
-            this.btnContrast.Margin = new System.Windows.Forms.Padding(4);
-            this.btnContrast.Name = "btnContrast";
-            this.btnContrast.Size = new System.Drawing.Size(120, 32);
-            this.btnContrast.TabIndex = 81;
-            this.btnContrast.Text = "自动对比度";
-            this.btnContrast.UseVisualStyleBackColor = true;
+            this.btnAutoAstigmatism.Click += new System.EventHandler(this.btnAutoAstigmatism_Click);
             // 
             // btnAutoBrightness
             // 
             this.btnAutoBrightness.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
             this.btnAutoBrightness.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
             this.btnAutoBrightness.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.btnAutoBrightness.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
+            this.btnAutoBrightness.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.btnAutoBrightness.Font = new System.Drawing.Font("宋体", 9F);
             this.btnAutoBrightness.ForeColor = System.Drawing.Color.White;
             this.btnAutoBrightness.Location = new System.Drawing.Point(1318, 327);
             this.btnAutoBrightness.Margin = new System.Windows.Forms.Padding(4);
             this.btnAutoBrightness.Name = "btnAutoBrightness";
-            this.btnAutoBrightness.Size = new System.Drawing.Size(120, 32);
+            this.btnAutoBrightness.Size = new System.Drawing.Size(120, 62);
             this.btnAutoBrightness.TabIndex = 82;
-            this.btnAutoBrightness.Text = "自动亮度";
+            this.btnAutoBrightness.Text = "自动亮度  对比度";
             this.btnAutoBrightness.UseVisualStyleBackColor = true;
             this.btnAutoBrightness.Click += new System.EventHandler(this.btnAutoBrightness_Click);
             // 
@@ -1672,7 +1645,7 @@
             // 
             // btnGetImage
             // 
-            this.btnGetImage.BackgroundImage = global::HOZProject.Properties.Resources.ConnectImg;
+            this.btnGetImage.BackgroundImage = global::HOZProject.Properties.Resources.GetImage;
             this.btnGetImage.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
             this.btnGetImage.Cursor = System.Windows.Forms.Cursors.Hand;
             this.btnGetImage.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
@@ -1682,7 +1655,6 @@
             this.btnGetImage.Name = "btnGetImage";
             this.btnGetImage.Size = new System.Drawing.Size(166, 138);
             this.btnGetImage.TabIndex = 91;
-            this.btnGetImage.Text = "获取图像";
             this.btnGetImage.UseVisualStyleBackColor = true;
             this.btnGetImage.Click += new System.EventHandler(this.btnGetImage_Click);
             // 
@@ -1721,11 +1693,9 @@
             this.Controls.Add(this.lblState);
             this.Controls.Add(this.btnStop);
             this.Controls.Add(this.btnGetStagePosition);
-            this.Controls.Add(this.btnContrast);
             this.Controls.Add(this.btnAutoBrightness);
             this.Controls.Add(this.btnAutoAstigmatism);
             this.Controls.Add(this.btnAutoWD);
-            this.Controls.Add(this.pictureBox1);
             this.Controls.Add(this.label24);
             this.Controls.Add(this.label23);
             this.Controls.Add(this.label22);
@@ -1790,7 +1760,6 @@
             this.panel15.PerformLayout();
             this.panel16.ResumeLayout(false);
             this.panel16.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbHT)).EndInit();
             this.panel6.ResumeLayout(false);
             this.panel6.PerformLayout();
@@ -1891,10 +1860,8 @@
         private System.Windows.Forms.Label label22;
         private System.Windows.Forms.Label label23;
         private System.Windows.Forms.Label label24;
-        private System.Windows.Forms.PictureBox pictureBox1;
         private System.Windows.Forms.Button btnAutoWD;
         private System.Windows.Forms.Button btnAutoAstigmatism;
-        private System.Windows.Forms.Button btnContrast;
         private System.Windows.Forms.Button btnAutoBrightness;
         private System.Windows.Forms.Button btnGetStagePosition;
         private System.Windows.Forms.PictureBox pbHT;

+ 170 - 34
HOZProject/FormUCMain.cs

@@ -16,8 +16,8 @@ namespace HOZProject
     {
         #region 全局变量定义
         //全局只有一个fatorySEM
-        static FactoryHardware factorySEM = FactoryHardware.Instance;
-        ISEMControl iSEM = factorySEM.ISEM;
+        //static FactoryHardware factorySEM = FactoryHardware.Instance;
+        ISEMControl iSEM = null;//factorySEM.ISEM;
         //电镜连接状态变量
         bool m_SEMConnectState = false;
         //自动状态变量
@@ -28,7 +28,10 @@ namespace HOZProject
         bool m_StageStage = false;
         int m_ThreadTime = 1000;
         int m_ThreadCount = 5;
-        string imgFileSavePath = "D://tempImage.tif";
+        string m_ImgFileSavePath = "D://tempImage.tif";
+        string m_ImgAutoFileSavePath = "D://tempAutoImage.tif";
+        short m_ImgWidth = 1024;
+        short m_ImgHeight = 768;
         #endregion
 
         #region 构造
@@ -41,9 +44,9 @@ namespace HOZProject
         #region 窗体事件
         private void FormUCMain_Load(object sender, EventArgs e)
         {
-            //获取初始状态(电镜连接状态、自动函数的状态、样品台状态)
-            Thread thread = new Thread(new ThreadStart(GetInitState));
-            thread.Start();
+            ////获取初始状态(电镜连接状态、自动函数的状态、样品台状态)
+            //Thread thread = new Thread(new ThreadStart(GetInitState));
+            //thread.Start();
         }
         #endregion
 
@@ -122,7 +125,7 @@ namespace HOZProject
                             break;
                         case StateType.AutoFUNCState:
                             fResult = iSEM.GetAutoFunction();
-                            if (fResult > 0)
+                            if (fResult == 0)
                             {
                                 bResult = true;
                                 return bResult;
@@ -131,7 +134,7 @@ namespace HOZProject
                         case StateType.StageState:
 
                             fResult = iSEM.GetStageIs();
-                            if (fResult > 0)
+                            if (fResult == 0)
                             {
                                 bResult = true;
                                 return bResult;
@@ -505,6 +508,10 @@ namespace HOZProject
         #region 获取样品台六轴位置信息
         private void btnGetStagePosition_Click(object sender, EventArgs e)
         {
+            if (iSEM == null)
+            {
+                return;
+            }
             try
             {
                 float[] pt = iSEM.GetStagePosition();
@@ -687,6 +694,10 @@ namespace HOZProject
         #region 移动当前位置至SEM中心
         private void btnMoveSEMCenter_Click(object sender, EventArgs e)
         {
+            if (iSEM == null)
+            {
+                return;
+            }
             //设置当前样品台状态
             m_StageStage = false;
             float setX = 0;
@@ -727,29 +738,57 @@ namespace HOZProject
         /// <param name="e"></param>
         private void btnGetImage_Click(object sender, EventArgs e)
         {
+            if (iSEM == null)
+            {
+                return;
+            }
             fShowImage = new FormShowImage();
             //获取当前图像以及当前电镜参数
-            //iSEM.GrabImage
-            fShowImage.pbImage.Image = Properties.Resources.UCMain;
-            fShowImage.Width = fShowImage.Width / 2;
-            fShowImage.Show();
+            //放大倍数
+            float f_Mag = iSEM.GetMagnification();
+            //焦距
+            float f_WD = iSEM.GetWorkingDistance();
+            bool imageResult = iSEM.GrabImage(m_ImgFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
+            if (imageResult)
+            {
+                Bitmap bitmap = new Bitmap(m_ImgFileSavePath);
+                fShowImage.Width = fShowImage.Width / 2;
+                //设置当前图像与参数
+                fShowImage.pbImage.Image = (Image)bitmap;
+                fShowImage.Mag = "放大倍数:" + f_Mag;
+                fShowImage.Content = "焦距:" + f_WD;
+                fShowImage.SetParaInfo();
+                fShowImage.Show();
+            }
         }
         #endregion
 
         #region 自动对焦
         private void btnAutoWD_Click(object sender, EventArgs e)
         {
+            if (iSEM == null)
+            {
+                return;
+            }
             fShowImage = new FormShowImage();
             //获取图像尺寸
             int[] imageSize = iSEM.GetImageStore();
-            short width = Convert.ToInt16(imageSize[0]);
-            short height = Convert.ToInt16(imageSize[1]);
+            m_ImgWidth = Convert.ToInt16(imageSize[0]);
+            m_ImgHeight = Convert.ToInt16(imageSize[1]);
+            //放大倍数
+            float f_Mag = iSEM.GetMagnification();
+            //焦距
+            float f_WD = iSEM.GetWorkingDistance();
             //获取当前图像以及当前电镜参数
-            bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
+            bool imageResult = iSEM.GrabImage(m_ImgFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
             if (imageResult)
             {
-                Bitmap bitmap = new Bitmap(imgFileSavePath);
+                Bitmap bitmap = new Bitmap(m_ImgFileSavePath);
+                //设置当前图像与参数
                 fShowImage.pbImage.Image = (Image)bitmap;
+                fShowImage.Mag = "放大倍数:" + f_Mag;
+                fShowImage.Content = "焦距:" + f_WD;
+                fShowImage.SetParaInfo();
                 fShowImage.Show();
                 float result = iSEM.GetAutoVideo();
                 if (result > 0)
@@ -770,15 +809,19 @@ namespace HOZProject
                 bool result = GetAllState(StateType.AutoFUNCState);
                 if (result)
                 { 
-                    //获取图像尺寸
-                    int[] imageSize = iSEM.GetImageStore();
-                    short width = Convert.ToInt16(imageSize[0]);
-                    short height = Convert.ToInt16(imageSize[1]);
+                    //放大倍数
+                    float f_Mag = iSEM.GetMagnification();
+                    //焦距
+                    float f_WD = iSEM.GetWorkingDistance();
                     //获取自动对焦后图像以及电镜参数
-                    bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
-                    Bitmap bitmap = new Bitmap(imgFileSavePath);
+                    bool imageResult = iSEM.GrabImage(m_ImgAutoFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
+                    Bitmap bitmap = new Bitmap(m_ImgAutoFileSavePath);
                     fShowImage.pbImage.Image = (Image)bitmap;
+                    //自动后设置图像与参数
                     fShowImage.pbAutoImage.Image = Properties.Resources.UCMain;
+                    fShowImage.AutoMag = "放大倍数:" + f_Mag;
+                    fShowImage.AutoContent = "焦距:" + f_WD;
+                    fShowImage.SetAutoParaInfo();
                     fShowImage.Invalidate();
                 }
             }
@@ -788,20 +831,33 @@ namespace HOZProject
         #region 自动亮度
         private void btnAutoBrightness_Click(object sender, EventArgs e)
         {
+            if (iSEM == null)
+            {
+                return;
+            }
             fShowImage = new FormShowImage();
             //获取图像尺寸
             int[] imageSize = iSEM.GetImageStore();
-            short width = Convert.ToInt16(imageSize[0]);
-            short height = Convert.ToInt16(imageSize[1]);
+            m_ImgWidth = Convert.ToInt16(imageSize[0]);
+            m_ImgHeight = Convert.ToInt16(imageSize[1]);
+            //放大倍数
+            float f_Mag = iSEM.GetMagnification();
+            //亮度
+            float f_Brightness = iSEM.GetBrightness();
+            //对比度
+            float f_Contrast = iSEM.GetContrast();
             //获取当前图像以及当前电镜参数
-            bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
+            bool imageResult = iSEM.GrabImage(m_ImgFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
             if (imageResult)
             {
-                Bitmap bitmap = new Bitmap(imgFileSavePath);
+                Bitmap bitmap = new Bitmap(m_ImgFileSavePath);
                 fShowImage.pbImage.Image = (Image)bitmap;
+                fShowImage.Mag = "放大倍数:" + f_Mag;
+                fShowImage.Content = "亮度:"+f_Brightness+"对比度:"+ f_Contrast;
+                fShowImage.SetParaInfo();
                 fShowImage.Show();
                 float result = iSEM.GetAutoVideo();
-                if (result > 0)
+                if (result== 0)
                 {
                     Thread threadImg = new Thread(new ThreadStart(GetAutoBrightness));
                     threadImg.Start();
@@ -819,19 +875,99 @@ namespace HOZProject
                 bool result = GetAllState(StateType.AutoFUNCState);
                 if (result)
                 {
-                    //获取图像尺寸
-                    int[] imageSize = iSEM.GetImageStore();
-                    short width = Convert.ToInt16(imageSize[0]);
-                    short height = Convert.ToInt16(imageSize[1]);
+                    //放大倍数
+                    float f_Mag = iSEM.GetMagnification();
+                    //亮度
+                    float f_Brightness = iSEM.GetBrightness();
+                    //对比度
+                    float f_Contrast = iSEM.GetContrast();
                     //获取自动对焦后图像以及电镜参数
-                    bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
-                    Bitmap bitmap = new Bitmap(imgFileSavePath);
-                    fShowImage.pbImage.Image = (Image)bitmap;
+                    bool imageResult = iSEM.GrabImage(m_ImgAutoFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
+                    Bitmap bitmap = new Bitmap(m_ImgFileSavePath);
+                    fShowImage.pbAutoImage.Image = (Image)bitmap;
+                    fShowImage.AutoMag = "放大倍数:" + f_Mag;
+                    fShowImage.AutoContent = "亮度:" + f_Brightness + "对比度:" + f_Contrast;
+                    fShowImage.SetAutoParaInfo();
                     fShowImage.Invalidate();
                 }
             }
         }
         #endregion
+
+        #region 自动消像散
+        private void btnAutoAstigmatism_Click(object sender, EventArgs e)
+        {
+            if (iSEM == null)
+            {
+                return;
+            }
+            fShowImage = new FormShowImage();
+            //获取图像尺寸
+            int[] imageSize = iSEM.GetImageStore();
+            m_ImgWidth = Convert.ToInt16(imageSize[0]);
+            m_ImgHeight = Convert.ToInt16(imageSize[1]);
+            //放大倍数
+            float f_Mag = iSEM.GetMagnification();
+            //消像散X
+            float f_AstigmatismX = iSEM.GetAstigmatismX();
+            //消像散Y
+            float f_AstigmatismY = iSEM.GetAstigmatismY();
+            //获取当前图像以及当前电镜参数
+            bool imageResult = iSEM.GrabImage(m_ImgFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
+            if (imageResult)
+            {
+                Bitmap bitmap = new Bitmap(m_ImgFileSavePath);
+                fShowImage.pbImage.Image = (Image)bitmap;
+                fShowImage.Mag = "放大倍数:" + f_Mag;
+                fShowImage.Content = "消像散X:" + f_AstigmatismX + "消像散Y:" + f_AstigmatismY;
+                fShowImage.SetParaInfo();
+                fShowImage.Show();
+                float result = iSEM.GetAutoVideo();
+                if (result == 0)
+                {
+                    Thread threadImg = new Thread(new ThreadStart(GetAutoAstigmatism));
+                    threadImg.Start();
+                }
+            }
+        }
+        /// <summary>
+        /// 获取自动状态后
+        /// </summary>
+        private void GetAutoAstigmatism()
+        {
+            if (fShowImage != null)
+            {
+                //获取当前自动状态
+                bool result = GetAllState(StateType.AutoFUNCState);
+                if (result)
+                {
+                    //放大倍数
+                    float f_Mag = iSEM.GetMagnification();
+                    //消像散X
+                    float f_AstigmatismX = iSEM.GetAstigmatismX();
+                    //消像散Y
+                    float f_AstigmatismY = iSEM.GetAstigmatismY();
+                    //获取自动对焦后图像以及电镜参数
+                    bool imageResult = iSEM.GrabImage(m_ImgAutoFileSavePath, 0, 0, m_ImgWidth, m_ImgHeight, 0);
+                    Bitmap bitmap = new Bitmap(m_ImgFileSavePath);
+                    fShowImage.pbAutoImage.Image = (Image)bitmap;
+                    fShowImage.AutoMag = "放大倍数:" + f_Mag;
+                    fShowImage.AutoContent = "消像散X:" + f_AstigmatismX + "消像散Y:" + f_AstigmatismY;
+                    fShowImage.SetAutoParaInfo();
+                    fShowImage.Invalidate();
+                }
+            }
+        }
         #endregion
+
+        #endregion
+
+        private void btnContrast_Click(object sender, EventArgs e)
+        {
+            if (iSEM == null)
+            {
+                return;
+            }
+        }
     }
 }

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

@@ -130,6 +130,16 @@ namespace HOZProject.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap GetImage {
+            get {
+                object obj = ResourceManager.GetObject("GetImage", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>

+ 3 - 0
HOZProject/Properties/Resources.resx

@@ -160,4 +160,7 @@
   <data name="ConnectImg" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\ConnectImg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="GetImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\GetImage.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>

+ 3 - 0
HOZProject/UnitControl.csproj

@@ -147,5 +147,8 @@
   <ItemGroup>
     <None Include="Resources\UCMain.png" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\GetImage.jpg" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>