Explorar o código

添加自动亮度

wb_han %!s(int64=5) %!d(string=hai) anos
pai
achega
48ea647c81

+ 120 - 36
HOZProject/FormShowImage.Designer.cs

@@ -32,13 +32,20 @@
             this.picexit = new System.Windows.Forms.PictureBox();
             this.pbImage = new System.Windows.Forms.PictureBox();
             this.plImageInfo = new System.Windows.Forms.Panel();
-            this.lblHT = new System.Windows.Forms.Label();
-            this.lblMag = new System.Windows.Forms.Label();
             this.lblWD = new System.Windows.Forms.Label();
+            this.lblMag = new System.Windows.Forms.Label();
+            this.lblHT = 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.pbAutoImage = new System.Windows.Forms.PictureBox();
             ((System.ComponentModel.ISupportInitialize)(this.pichide)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.picexit)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pbImage)).BeginInit();
             this.plImageInfo.SuspendLayout();
+            this.panel1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pbAutoImage)).BeginInit();
             this.SuspendLayout();
             // 
             // pichide
@@ -47,13 +54,14 @@
             this.pichide.BackColor = System.Drawing.Color.Transparent;
             this.pichide.Cursor = System.Windows.Forms.Cursors.Hand;
             this.pichide.Image = global::HOZProject.Properties.Resources.Min_Gray;
-            this.pichide.Location = new System.Drawing.Point(486, 9);
-            this.pichide.Margin = new System.Windows.Forms.Padding(4);
+            this.pichide.Location = new System.Drawing.Point(1501, 14);
+            this.pichide.Margin = new System.Windows.Forms.Padding(6);
             this.pichide.Name = "pichide";
-            this.pichide.Size = new System.Drawing.Size(13, 13);
+            this.pichide.Size = new System.Drawing.Size(20, 20);
             this.pichide.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             this.pichide.TabIndex = 58;
             this.pichide.TabStop = false;
+            this.pichide.Visible = false;
             // 
             // picexit
             // 
@@ -61,20 +69,22 @@
             this.picexit.BackColor = System.Drawing.Color.Transparent;
             this.picexit.Cursor = System.Windows.Forms.Cursors.Hand;
             this.picexit.Image = global::HOZProject.Properties.Resources.exit_Gray;
-            this.picexit.Location = new System.Drawing.Point(502, 9);
-            this.picexit.Margin = new System.Windows.Forms.Padding(4);
+            this.picexit.Location = new System.Drawing.Point(1525, 14);
+            this.picexit.Margin = new System.Windows.Forms.Padding(6);
             this.picexit.Name = "picexit";
-            this.picexit.Size = new System.Drawing.Size(13, 13);
+            this.picexit.Size = new System.Drawing.Size(20, 20);
             this.picexit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             this.picexit.TabIndex = 57;
             this.picexit.TabStop = false;
+            this.picexit.Click += new System.EventHandler(this.picexit_Click);
             // 
             // pbImage
             // 
             this.pbImage.BackColor = System.Drawing.Color.White;
-            this.pbImage.Location = new System.Drawing.Point(3, 29);
+            this.pbImage.Location = new System.Drawing.Point(4, 44);
+            this.pbImage.Margin = new System.Windows.Forms.Padding(4);
             this.pbImage.Name = "pbImage";
-            this.pbImage.Size = new System.Drawing.Size(512, 384);
+            this.pbImage.Size = new System.Drawing.Size(768, 576);
             this.pbImage.TabIndex = 59;
             this.pbImage.TabStop = false;
             // 
@@ -84,56 +94,122 @@
             this.plImageInfo.Controls.Add(this.lblWD);
             this.plImageInfo.Controls.Add(this.lblMag);
             this.plImageInfo.Controls.Add(this.lblHT);
-            this.plImageInfo.Location = new System.Drawing.Point(3, 413);
+            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(512, 43);
+            this.plImageInfo.Size = new System.Drawing.Size(768, 64);
             this.plImageInfo.TabIndex = 60;
             // 
-            // lblHT
+            // lblWD
             // 
-            this.lblHT.AutoSize = true;
-            this.lblHT.Font = new System.Drawing.Font("宋体", 14F);
-            this.lblHT.ForeColor = System.Drawing.Color.White;
-            this.lblHT.Location = new System.Drawing.Point(9, 13);
-            this.lblHT.Name = "lblHT";
-            this.lblHT.Size = new System.Drawing.Size(106, 19);
-            this.lblHT.TabIndex = 1;
-            this.lblHT.Text = "电压:20KV";
+            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";
             // 
             // lblMag
             // 
             this.lblMag.AutoSize = true;
-            this.lblMag.Font = new System.Drawing.Font("宋体", 14F);
+            this.lblMag.Font = new System.Drawing.Font("宋体", 12F);
             this.lblMag.ForeColor = System.Drawing.Color.White;
-            this.lblMag.Location = new System.Drawing.Point(160, 13);
+            this.lblMag.Location = new System.Drawing.Point(258, 20);
+            this.lblMag.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.lblMag.Name = "lblMag";
-            this.lblMag.Size = new System.Drawing.Size(144, 19);
+            this.lblMag.Size = new System.Drawing.Size(178, 24);
             this.lblMag.TabIndex = 1;
             this.lblMag.Text = "放大倍数:200X";
             // 
-            // lblWD
+            // lblHT
             // 
-            this.lblWD.AutoSize = true;
-            this.lblWD.Font = new System.Drawing.Font("宋体", 14F);
-            this.lblWD.ForeColor = System.Drawing.Color.White;
-            this.lblWD.Location = new System.Drawing.Point(349, 13);
-            this.lblWD.Name = "lblWD";
-            this.lblWD.Size = new System.Drawing.Size(154, 19);
-            this.lblWD.TabIndex = 1;
-            this.lblWD.Text = "工作距离:8.2mm";
+            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";
+            // 
+            // 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.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";
+            // 
+            // pbAutoImage
+            // 
+            this.pbAutoImage.BackColor = System.Drawing.Color.White;
+            this.pbAutoImage.Location = new System.Drawing.Point(775, 44);
+            this.pbAutoImage.Margin = new System.Windows.Forms.Padding(4);
+            this.pbAutoImage.Name = "pbAutoImage";
+            this.pbAutoImage.Size = new System.Drawing.Size(768, 576);
+            this.pbAutoImage.TabIndex = 61;
+            this.pbAutoImage.TabStop = false;
             // 
             // FormShowImage
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.Black;
-            this.ClientSize = new System.Drawing.Size(519, 459);
+            this.ClientSize = new System.Drawing.Size(1550, 688);
+            this.Controls.Add(this.panel1);
+            this.Controls.Add(this.pbAutoImage);
             this.Controls.Add(this.plImageInfo);
             this.Controls.Add(this.pbImage);
             this.Controls.Add(this.pichide);
             this.Controls.Add(this.picexit);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "FormShowImage";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "FormShowImage";
             this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FormShowImage_MouseDown);
             this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FormShowImage_MouseMove);
@@ -143,6 +219,9 @@
             ((System.ComponentModel.ISupportInitialize)(this.pbImage)).EndInit();
             this.plImageInfo.ResumeLayout(false);
             this.plImageInfo.PerformLayout();
+            this.panel1.ResumeLayout(false);
+            this.panel1.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pbAutoImage)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -151,10 +230,15 @@
 
         private System.Windows.Forms.PictureBox pichide;
         private System.Windows.Forms.PictureBox picexit;
-        private System.Windows.Forms.PictureBox pbImage;
         private System.Windows.Forms.Panel plImageInfo;
         private System.Windows.Forms.Label lblHT;
         private System.Windows.Forms.Label lblWD;
         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;
+        public System.Windows.Forms.PictureBox pbImage;
+        public System.Windows.Forms.PictureBox pbAutoImage;
     }
 }

+ 50 - 0
HOZProject/FormShowImage.cs

@@ -12,6 +12,51 @@ namespace HOZProject
 {
     public partial class FormShowImage : Form
     {
+        #region 属性
+        /// <summary>
+        /// 显示的图像
+        /// </summary>
+        private Image showImg;
+        public Image ShowImg { get => showImg; set => showImg = value; }
+        /// <summary>
+        /// 电压
+        /// </summary>
+        private float kv;
+        public float Kv { get => kv; set => kv = value; }
+        /// <summary>
+        /// 放大倍数
+        /// </summary>
+        private float mag;
+        public float Mag { get => mag; set => mag = value; }
+        /// <summary>
+        /// 属性信息(工作距离、消像散、亮度、对比度)
+        /// </summary>
+        private float content;
+        public float Content { get => content; set => content = value; }
+
+        /// <summary>
+        /// Auto后显示的图像
+        /// </summary>
+        private Image showAutoImg;
+        public Image ShowAutoImg { get => showAutoImg; set => showAutoImg = value; }
+        /// <summary>
+        /// Auto后电压
+        /// </summary>
+        private float autoKv;
+        public float AutoKv { get => autoKv; set => autoKv = value; }
+        /// <summary>
+        /// Auto后放大倍数
+        /// </summary>
+        private float autoMag;
+        public float AutoMag { get => autoMag; set => autoMag = value; }
+        /// <summary>
+        /// Auto后属性信息(工作距离、消像散、亮度、对比度)
+        /// </summary>
+        private float autoContent;
+        public float AutoContent { get => autoContent; set => autoContent = value; }
+        #endregion
+
+
         public FormShowImage()
         {
             InitializeComponent();
@@ -45,5 +90,10 @@ namespace HOZProject
             }
         }
         #endregion
+
+        private void picexit_Click(object sender, EventArgs e)
+        {
+            this.Close();
+        }
     }
 }

+ 95 - 93
HOZProject/FormUCMain.Designer.cs

@@ -109,10 +109,10 @@
             this.label23 = new System.Windows.Forms.Label();
             this.label24 = new System.Windows.Forms.Label();
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
-            this.button13 = new System.Windows.Forms.Button();
-            this.button14 = new System.Windows.Forms.Button();
-            this.button15 = new System.Windows.Forms.Button();
-            this.button16 = new System.Windows.Forms.Button();
+            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();
             this.lblState = new System.Windows.Forms.Label();
@@ -141,9 +141,9 @@
             this.label19 = new System.Windows.Forms.Label();
             this.groupBox1 = new System.Windows.Forms.GroupBox();
             this.btnMoveSEMCenter = new System.Windows.Forms.Button();
-            this.textBox5 = new System.Windows.Forms.TextBox();
+            this.txtMoveStageY = new System.Windows.Forms.TextBox();
             this.label25 = new System.Windows.Forms.Label();
-            this.textBox4 = new System.Windows.Forms.TextBox();
+            this.txtMoveStageX = new System.Windows.Forms.TextBox();
             this.label21 = new System.Windows.Forms.Label();
             this.btnConnect = new System.Windows.Forms.Button();
             this.btnGetImage = new System.Windows.Forms.Button();
@@ -1197,69 +1197,71 @@
             this.pictureBox1.TabIndex = 79;
             this.pictureBox1.TabStop = false;
             // 
-            // button13
-            // 
-            this.button13.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
-            this.button13.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.button13.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.button13.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
-            this.button13.Font = new System.Drawing.Font("宋体", 9F);
-            this.button13.ForeColor = System.Drawing.Color.White;
-            this.button13.Location = new System.Drawing.Point(1200, 327);
-            this.button13.Margin = new System.Windows.Forms.Padding(4);
-            this.button13.Name = "button13";
-            this.button13.Size = new System.Drawing.Size(120, 32);
-            this.button13.TabIndex = 80;
-            this.button13.Text = "自动对焦";
-            this.button13.UseVisualStyleBackColor = true;
-            // 
-            // button14
-            // 
-            this.button14.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
-            this.button14.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.button14.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.button14.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
-            this.button14.Font = new System.Drawing.Font("宋体", 9F);
-            this.button14.ForeColor = System.Drawing.Color.White;
-            this.button14.Location = new System.Drawing.Point(1200, 357);
-            this.button14.Margin = new System.Windows.Forms.Padding(4);
-            this.button14.Name = "button14";
-            this.button14.Size = new System.Drawing.Size(120, 32);
-            this.button14.TabIndex = 80;
-            this.button14.Text = " 自动消像散";
-            this.button14.UseVisualStyleBackColor = true;
-            // 
-            // button15
-            // 
-            this.button15.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
-            this.button15.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.button15.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.button15.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
-            this.button15.Font = new System.Drawing.Font("宋体", 9F);
-            this.button15.ForeColor = System.Drawing.Color.White;
-            this.button15.Location = new System.Drawing.Point(1318, 357);
-            this.button15.Margin = new System.Windows.Forms.Padding(4);
-            this.button15.Name = "button15";
-            this.button15.Size = new System.Drawing.Size(120, 32);
-            this.button15.TabIndex = 81;
-            this.button15.Text = "自动对比度";
-            this.button15.UseVisualStyleBackColor = true;
-            // 
-            // button16
-            // 
-            this.button16.BackgroundImage = global::HOZProject.Properties.Resources.buttonBG;
-            this.button16.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            this.button16.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.button16.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
-            this.button16.Font = new System.Drawing.Font("宋体", 9F);
-            this.button16.ForeColor = System.Drawing.Color.White;
-            this.button16.Location = new System.Drawing.Point(1318, 327);
-            this.button16.Margin = new System.Windows.Forms.Padding(4);
-            this.button16.Name = "button16";
-            this.button16.Size = new System.Drawing.Size(120, 32);
-            this.button16.TabIndex = 82;
-            this.button16.Text = "自动亮度";
-            this.button16.UseVisualStyleBackColor = true;
+            // 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.Font = new System.Drawing.Font("宋体", 9F);
+            this.btnAutoWD.ForeColor = System.Drawing.Color.White;
+            this.btnAutoWD.Location = new System.Drawing.Point(1200, 327);
+            this.btnAutoWD.Margin = new System.Windows.Forms.Padding(4);
+            this.btnAutoWD.Name = "btnAutoWD";
+            this.btnAutoWD.Size = new System.Drawing.Size(120, 32);
+            this.btnAutoWD.TabIndex = 80;
+            this.btnAutoWD.Text = "自动对焦";
+            this.btnAutoWD.UseVisualStyleBackColor = true;
+            this.btnAutoWD.Click += new System.EventHandler(this.btnAutoWD_Click);
+            // 
+            // btnAutoAstigmatism
+            // 
+            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.Font = new System.Drawing.Font("宋体", 9F);
+            this.btnAutoAstigmatism.ForeColor = System.Drawing.Color.White;
+            this.btnAutoAstigmatism.Location = new System.Drawing.Point(1200, 357);
+            this.btnAutoAstigmatism.Margin = new System.Windows.Forms.Padding(4);
+            this.btnAutoAstigmatism.Name = "btnAutoAstigmatism";
+            this.btnAutoAstigmatism.Size = new System.Drawing.Size(120, 32);
+            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;
+            // 
+            // 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.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.TabIndex = 82;
+            this.btnAutoBrightness.Text = "自动亮度";
+            this.btnAutoBrightness.UseVisualStyleBackColor = true;
+            this.btnAutoBrightness.Click += new System.EventHandler(this.btnAutoBrightness_Click);
             // 
             // btnGetStagePosition
             // 
@@ -1587,9 +1589,9 @@
             // 
             this.groupBox1.BackColor = System.Drawing.Color.Transparent;
             this.groupBox1.Controls.Add(this.btnMoveSEMCenter);
-            this.groupBox1.Controls.Add(this.textBox5);
+            this.groupBox1.Controls.Add(this.txtMoveStageY);
             this.groupBox1.Controls.Add(this.label25);
-            this.groupBox1.Controls.Add(this.textBox4);
+            this.groupBox1.Controls.Add(this.txtMoveStageX);
             this.groupBox1.Controls.Add(this.label21);
             this.groupBox1.ForeColor = System.Drawing.Color.White;
             this.groupBox1.Location = new System.Drawing.Point(1057, 422);
@@ -1599,7 +1601,7 @@
             this.groupBox1.Size = new System.Drawing.Size(237, 106);
             this.groupBox1.TabIndex = 90;
             this.groupBox1.TabStop = false;
-            this.groupBox1.Text = "SEM中心移动当前位置";
+            this.groupBox1.Text = "移动当前位置至SEM中心";
             // 
             // btnMoveSEMCenter
             // 
@@ -1618,12 +1620,12 @@
             this.btnMoveSEMCenter.UseVisualStyleBackColor = true;
             this.btnMoveSEMCenter.Click += new System.EventHandler(this.btnMoveSEMCenter_Click);
             // 
-            // textBox5
+            // txtMoveStageY
             // 
-            this.textBox5.Location = new System.Drawing.Point(48, 63);
-            this.textBox5.Name = "textBox5";
-            this.textBox5.Size = new System.Drawing.Size(109, 28);
-            this.textBox5.TabIndex = 62;
+            this.txtMoveStageY.Location = new System.Drawing.Point(48, 63);
+            this.txtMoveStageY.Name = "txtMoveStageY";
+            this.txtMoveStageY.Size = new System.Drawing.Size(109, 28);
+            this.txtMoveStageY.TabIndex = 62;
             // 
             // label25
             // 
@@ -1636,12 +1638,12 @@
             this.label25.TabIndex = 63;
             this.label25.Text = "Y轴";
             // 
-            // textBox4
+            // txtMoveStageX
             // 
-            this.textBox4.Location = new System.Drawing.Point(48, 26);
-            this.textBox4.Name = "textBox4";
-            this.textBox4.Size = new System.Drawing.Size(109, 28);
-            this.textBox4.TabIndex = 60;
+            this.txtMoveStageX.Location = new System.Drawing.Point(48, 26);
+            this.txtMoveStageX.Name = "txtMoveStageX";
+            this.txtMoveStageX.Size = new System.Drawing.Size(109, 28);
+            this.txtMoveStageX.TabIndex = 60;
             // 
             // label21
             // 
@@ -1719,10 +1721,10 @@
             this.Controls.Add(this.lblState);
             this.Controls.Add(this.btnStop);
             this.Controls.Add(this.btnGetStagePosition);
-            this.Controls.Add(this.button15);
-            this.Controls.Add(this.button16);
-            this.Controls.Add(this.button14);
-            this.Controls.Add(this.button13);
+            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);
@@ -1750,8 +1752,8 @@
             this.DoubleBuffered = true;
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
             this.Name = "FormUCMain";
+            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
-            this.Text = "FormUCMain";
             this.Load += new System.EventHandler(this.FormUCMain_Load);
             this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FormUCMain_MouseDown);
             this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FormUCMain_MouseMove);
@@ -1890,10 +1892,10 @@
         private System.Windows.Forms.Label label23;
         private System.Windows.Forms.Label label24;
         private System.Windows.Forms.PictureBox pictureBox1;
-        private System.Windows.Forms.Button button13;
-        private System.Windows.Forms.Button button14;
-        private System.Windows.Forms.Button button15;
-        private System.Windows.Forms.Button button16;
+        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;
         private System.Windows.Forms.Label lblState;
@@ -1921,9 +1923,9 @@
         private System.Windows.Forms.ComboBox comboBox2;
         private System.Windows.Forms.Label label19;
         private System.Windows.Forms.GroupBox groupBox1;
-        private System.Windows.Forms.TextBox textBox5;
+        private System.Windows.Forms.TextBox txtMoveStageY;
         private System.Windows.Forms.Label label25;
-        private System.Windows.Forms.TextBox textBox4;
+        private System.Windows.Forms.TextBox txtMoveStageX;
         private System.Windows.Forms.Label label21;
         private System.Windows.Forms.Button btnMoveSEMCenter;
         private System.Windows.Forms.Button btnConnect;

+ 258 - 108
HOZProject/FormUCMain.cs

@@ -14,37 +14,148 @@ namespace HOZProject
 {
     public partial class FormUCMain : Form
     {
+        #region 全局变量定义
         //全局只有一个fatorySEM
         static FactoryHardware factorySEM = FactoryHardware.Instance;
         ISEMControl iSEM = factorySEM.ISEM;
         //电镜连接状态变量
         bool m_SEMConnectState = false;
+        //自动状态变量
+        bool m_AutoState = false;
         //电压状态变量
         bool m_HTState = false;
         //样品台状态变量
         bool m_StageStage = false;
-        int ThreadTime = 1000;
+        int m_ThreadTime = 1000;
+        int m_ThreadCount = 5;
+        string imgFileSavePath = "D://tempImage.tif";
+        #endregion
+
+        #region 构造
         public FormUCMain()
         {
             InitializeComponent();
-        }
+        } 
+        #endregion
 
         #region 窗体事件
         private void FormUCMain_Load(object sender, EventArgs e)
         {
-            //获取电镜状态
-            Thread thread = new Thread(new ThreadStart(GetSEMConnectState));
+            //获取初始状态(电镜连接状态、自动函数的状态、样品台状态)
+            Thread thread = new Thread(new ThreadStart(GetInitState));
             thread.Start();
         }
         #endregion
-        #region 获取初始参数
+
+        #region 获取初始状态
         public void GetInitState()
         {
             if (iSEM != null)
             {
-                
+                //电镜连接状态
+                GetSEMConnectState();
+                //自动函数的状态
+                GetAutoFUNCState();
+                //样品台状态
+                GetStageState();
+            }
+        }
+        #endregion
+
+        #region 获取状态(电镜连接状态、自动函数的状态、样品台状态)
+        public bool GetSEMConnectState()
+        {
+            bool result = GetAllState(StateType.SEMConnectState);
+            if (result)
+            {
+                //已连接,设置按钮图像
+                btnConnect.BackgroundImage = Properties.Resources.CloseImg;
+                btnConnect.Invalidate();
+            }
+            else
+            {
+                btnConnect.BackgroundImage = Properties.Resources.ConnectImg;
+                btnConnect.Invalidate();
+            }
+            //设置电镜连接状态:True
+            m_SEMConnectState = result;
+            return result;
+        }
+        public bool GetAutoFUNCState()
+        {
+            bool result = GetAllState(StateType.AutoFUNCState);
+            m_AutoState = result;
+            return result;
+        }
+        public bool GetStageState()
+        {
+            bool result = GetAllState(StateType.StageState);
+            if (result)
+            {
+                btnConnect.BackgroundImage = Properties.Resources.CloseImg;
+            }
+            else
+            {
+                btnConnect.BackgroundImage = Properties.Resources.ConnectImg;
+            }
+            m_StageStage = result;
+            return result;
+        }
+        public bool GetAllState(StateType stateType)
+        {
+            //线程循环计数器
+            int threadCount = 0;
+            bool bResult = false;
+            float fResult = 0;
+            while (true)
+            {
+                if (threadCount <= m_ThreadCount)
+                {
+                    switch (stateType)
+                    {
+                        case StateType.SEMConnectState:
+                            bResult = iSEM.ConnectStatus();
+                            if (bResult)
+                            {
+                                return bResult;
+                            }
+                            break;
+                        case StateType.AutoFUNCState:
+                            fResult = iSEM.GetAutoFunction();
+                            if (fResult > 0)
+                            {
+                                bResult = true;
+                                return bResult;
+                            }
+                            break;
+                        case StateType.StageState:
+
+                            fResult = iSEM.GetStageIs();
+                            if (fResult > 0)
+                            {
+                                bResult = true;
+                                return bResult;
+                            }
+                            break;
+                    }
+                }
+                else
+                {
+                    return false;
+                }
+                threadCount++;
+                Thread.Sleep(m_ThreadTime);
             }
         }
+        /// <summary>
+        /// 状态枚举
+        /// </summary>
+        public enum StateType
+        {
+            SEMConnectState = 0,
+            AutoFUNCState = 1,
+            StageState = 2
+        }
         #endregion
 
         #region 关闭与最小化按钮事件
@@ -365,19 +476,28 @@ namespace HOZProject
         #region 切换电压状态
         private void pbHT_Click(object sender, EventArgs e)
         {
+            bool result = true;
             if (!m_HTState)
             {
                 //打开电压
-                iSEM.CmdOpenVoltage();
-                m_HTState = true;
-                pbHT.BackgroundImage = Properties.Resources.OFF;
+                result = iSEM.CmdOpenVoltage();
+                if (result)
+                {
+                    m_HTState = true;
+                    pbHT.Image = Properties.Resources.OFF;
+                    pbHT.Invalidate();
+                }
             }
             else
             {
                 //关闭电压
-                iSEM.CmdCloseVoltage();
-                m_HTState = false;
-                pbHT.BackgroundImage = Properties.Resources.ON;
+                result = iSEM.CmdCloseVoltage();
+                if (result)
+                {
+                    m_HTState = false;
+                    pbHT.Image = Properties.Resources.ON;
+                    pbHT.Invalidate();
+                }
             }
         }
         #endregion
@@ -563,125 +683,155 @@ namespace HOZProject
             }
         }
         #endregion
-        #endregion
 
-        #region 获取状态(电镜连接状态、自动函数的状态、样品台状态)
-        public void GetSEMConnectState()
+        #region 移动当前位置至SEM中心
+        private void btnMoveSEMCenter_Click(object sender, EventArgs e)
         {
-            bool result = GetAllState(StateType.SEMConnectState);
-            if (result)
-            {
-                //已连接,设置按钮图像
-                btnConnect.BackgroundImage = Properties.Resources.CloseImg;
-            }
-            else
+            //设置当前样品台状态
+            m_StageStage = false;
+            float setX = 0;
+            float setY = 0;
+            bool GotoResult = false;
+            //判断X、Y轴信息
+            if (float.TryParse(txtMoveStageX.Text, out setX) && float.TryParse(txtMoveStageY.Text, out setY))
             {
-                btnConnect.BackgroundImage = Properties.Resources.ConnectImg;
+                GotoResult = iSEM.MoveStageXY(setX, setY);
             }
-            //设置电镜连接状态:True
-            m_SEMConnectState = result;
         }
-        public void GetAutoFUNCState()
+        #endregion
+
+        #region 停止
+        /// <summary>
+        /// 停止
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnStop_Click(object sender, EventArgs e)
         {
-            bool result = GetAllState(StateType.AutoFUNCState);
-            if (result)
-            {
-            }
-            else
+            if (iSEM != null)
             {
+                //停止
+                iSEM.CmdStageAbort();
             }
         }
-        public void GetStageState()
+        #endregion
+        #endregion
+        
+        #region 自动函数处理
+        FormShowImage fShowImage = null;
+        #region 获取图像
+        /// <summary>
+        /// 获取图像
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnGetImage_Click(object sender, EventArgs e)
         {
-            bool result = GetAllState(StateType.StageState);
-            if (result)
-            {
-                btnConnect.BackgroundImage = Properties.Resources.CloseImg;
-            }
-            else
-            {
-                btnConnect.BackgroundImage = Properties.Resources.ConnectImg;
-            }
+            fShowImage = new FormShowImage();
+            //获取当前图像以及当前电镜参数
+            //iSEM.GrabImage
+            fShowImage.pbImage.Image = Properties.Resources.UCMain;
+            fShowImage.Width = fShowImage.Width / 2;
+            fShowImage.Show();
         }
-        public bool GetAllState(StateType stateType)
-        {
-            bool bResult = false;
-            float fResult = 0;
-            switch (stateType)
-            {
-                case StateType.SEMConnectState:
-                    while (true)
-                    {
-                        bResult = iSEM.ConnectStatus();
-                        if (bResult)
-                        {
-                            return bResult;
-                        }
-                        Thread.Sleep(ThreadTime);
-                    }
-                case StateType.AutoFUNCState:
-                    while (true)
-                    {
-                        fResult = iSEM.GetAutoFunction();
-                        if (fResult > 0)
-                        {
-                            bResult = true;
-                            return bResult;
-                        }
-                        Thread.Sleep(ThreadTime);
-                    }
-                case StateType.StageState:
-                    while (true)
-                    {
-                        fResult = iSEM.GetStageIs();
-                        if (fResult > 0)
-                        {
-                            bResult = true;
-                            return bResult;
-                        }
-                        Thread.Sleep(ThreadTime);
-                    }
+        #endregion
+
+        #region 自动对焦
+        private void btnAutoWD_Click(object sender, EventArgs e)
+        {
+            fShowImage = new FormShowImage();
+            //获取图像尺寸
+            int[] imageSize = iSEM.GetImageStore();
+            short width = Convert.ToInt16(imageSize[0]);
+            short height = Convert.ToInt16(imageSize[1]);
+            //获取当前图像以及当前电镜参数
+            bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
+            if (imageResult)
+            {
+                Bitmap bitmap = new Bitmap(imgFileSavePath);
+                fShowImage.pbImage.Image = (Image)bitmap;
+                fShowImage.Show();
+                float result = iSEM.GetAutoVideo();
+                if (result > 0)
+                {
+                    Thread threadImg = new Thread(new ThreadStart(GetAutoWDImage));
+                    threadImg.Start();
+                }
             }
-            return bResult;
         }
         /// <summary>
-        /// 状态枚举
+        /// 获取自动状态后
         /// </summary>
-        public enum StateType
-        {
-            SEMConnectState = 0,
-            AutoFUNCState = 1,
-            StageState = 2
+        private void GetAutoWDImage()
+        {
+            if (fShowImage != null)
+            {
+                //获取当前自动状态
+                bool result = GetAllState(StateType.AutoFUNCState);
+                if (result)
+                { 
+                    //获取图像尺寸
+                    int[] imageSize = iSEM.GetImageStore();
+                    short width = Convert.ToInt16(imageSize[0]);
+                    short height = Convert.ToInt16(imageSize[1]);
+                    //获取自动对焦后图像以及电镜参数
+                    bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
+                    Bitmap bitmap = new Bitmap(imgFileSavePath);
+                    fShowImage.pbImage.Image = (Image)bitmap;
+                    fShowImage.pbAutoImage.Image = Properties.Resources.UCMain;
+                    fShowImage.Invalidate();
+                }
+            }
         }
         #endregion
 
-        private void btnMoveSEMCenter_Click(object sender, EventArgs e)
-        {
-            //设置当前样品台状态
-            m_StageStage = false;
-            float setX = 0;
-            float setY = 0;
-            bool GotoResult = false;
-            //判断X、Y轴信息
-            if (float.TryParse(txtStageX.Text, out setX)&&float.TryParse(txtStageY.Text, out setY))
-            {
-                GotoResult = iSEM.MoveStageXY(setX,setY);
+        #region 自动亮度
+        private void btnAutoBrightness_Click(object sender, EventArgs e)
+        {
+            fShowImage = new FormShowImage();
+            //获取图像尺寸
+            int[] imageSize = iSEM.GetImageStore();
+            short width = Convert.ToInt16(imageSize[0]);
+            short height = Convert.ToInt16(imageSize[1]);
+            //获取当前图像以及当前电镜参数
+            bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
+            if (imageResult)
+            {
+                Bitmap bitmap = new Bitmap(imgFileSavePath);
+                fShowImage.pbImage.Image = (Image)bitmap;
+                fShowImage.Show();
+                float result = iSEM.GetAutoVideo();
+                if (result > 0)
+                {
+                    Thread threadImg = new Thread(new ThreadStart(GetAutoBrightness));
+                    threadImg.Start();
+                }
             }
         }
-
-        private void btnStop_Click(object sender, EventArgs e)
+        /// <summary>
+        /// 获取自动状态后
+        /// </summary>
+        private void GetAutoBrightness()
         {
-            if (iSEM != null)
+            if (fShowImage != null)
             {
-                //即刻停止
-                iSEM.CmdStageAbort();
+                //获取当前自动状态
+                bool result = GetAllState(StateType.AutoFUNCState);
+                if (result)
+                {
+                    //获取图像尺寸
+                    int[] imageSize = iSEM.GetImageStore();
+                    short width = Convert.ToInt16(imageSize[0]);
+                    short height = Convert.ToInt16(imageSize[1]);
+                    //获取自动对焦后图像以及电镜参数
+                    bool imageResult = iSEM.GrabImage(imgFileSavePath, 0, 0, width, height, 0);
+                    Bitmap bitmap = new Bitmap(imgFileSavePath);
+                    fShowImage.pbImage.Image = (Image)bitmap;
+                    fShowImage.Invalidate();
+                }
             }
         }
-
-        private void btnGetImage_Click(object sender, EventArgs e)
-        {
-            FormShowImage fShowImage = new FormShowImage();
-            fShowImage.ShowDialog();
-        }
+        #endregion
+        #endregion
     }
 }

+ 1 - 4
HOZProject/FormUnitControl.cs

@@ -57,7 +57,6 @@ namespace HOZProject
         }
         #endregion
 		
-		
         #region 设备关闭按键
         private void btnCloseCtrl_Click(object sender, EventArgs e)
         {
@@ -188,9 +187,7 @@ namespace HOZProject
             // }
         }
         #endregion
-
-
-
+        
         #region 缩放Get
         private void btnenlargeGet_Click(object sender, EventArgs e)
         {