Przeglądaj źródła

添加获取图像窗口与添加按钮事件

wb_han 5 lat temu
rodzic
commit
58cf29a126

+ 120 - 0
AutoDo/FormAutoDo.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 160 - 0
HOZProject/FormShowImage.Designer.cs

@@ -0,0 +1,160 @@
+namespace HOZProject
+{
+    partial class FormShowImage
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.pichide = new System.Windows.Forms.PictureBox();
+            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();
+            ((System.ComponentModel.ISupportInitialize)(this.pichide)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.picexit)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbImage)).BeginInit();
+            this.plImageInfo.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // pichide
+            // 
+            this.pichide.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            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.Name = "pichide";
+            this.pichide.Size = new System.Drawing.Size(13, 13);
+            this.pichide.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+            this.pichide.TabIndex = 58;
+            this.pichide.TabStop = false;
+            // 
+            // picexit
+            // 
+            this.picexit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            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.Name = "picexit";
+            this.picexit.Size = new System.Drawing.Size(13, 13);
+            this.picexit.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+            this.picexit.TabIndex = 57;
+            this.picexit.TabStop = false;
+            // 
+            // pbImage
+            // 
+            this.pbImage.BackColor = System.Drawing.Color.White;
+            this.pbImage.Location = new System.Drawing.Point(3, 29);
+            this.pbImage.Name = "pbImage";
+            this.pbImage.Size = new System.Drawing.Size(512, 384);
+            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.lblMag);
+            this.plImageInfo.Controls.Add(this.lblHT);
+            this.plImageInfo.Location = new System.Drawing.Point(3, 413);
+            this.plImageInfo.Name = "plImageInfo";
+            this.plImageInfo.Size = new System.Drawing.Size(512, 43);
+            this.plImageInfo.TabIndex = 60;
+            // 
+            // lblHT
+            // 
+            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";
+            // 
+            // lblMag
+            // 
+            this.lblMag.AutoSize = true;
+            this.lblMag.Font = new System.Drawing.Font("宋体", 14F);
+            this.lblMag.ForeColor = System.Drawing.Color.White;
+            this.lblMag.Location = new System.Drawing.Point(160, 13);
+            this.lblMag.Name = "lblMag";
+            this.lblMag.Size = new System.Drawing.Size(144, 19);
+            this.lblMag.TabIndex = 1;
+            this.lblMag.Text = "放大倍数:200X";
+            // 
+            // lblWD
+            // 
+            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";
+            // 
+            // FormShowImage
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.BackColor = System.Drawing.Color.Black;
+            this.ClientSize = new System.Drawing.Size(519, 459);
+            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.Name = "FormShowImage";
+            this.Text = "FormShowImage";
+            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FormShowImage_MouseDown);
+            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FormShowImage_MouseMove);
+            this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.FormShowImage_MouseUp);
+            ((System.ComponentModel.ISupportInitialize)(this.pichide)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.picexit)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pbImage)).EndInit();
+            this.plImageInfo.ResumeLayout(false);
+            this.plImageInfo.PerformLayout();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        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;
+    }
+}

+ 49 - 0
HOZProject/FormShowImage.cs

@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace HOZProject
+{
+    public partial class FormShowImage : Form
+    {
+        public FormShowImage()
+        {
+            InitializeComponent();
+        }
+
+        #region 拖动窗体
+        private Point mouseOff;//鼠标移动位置变量
+        private bool leftFlag;//标签是否为左键
+        private void FormShowImage_MouseDown(object sender, MouseEventArgs e)
+        {
+            if (e.Button == MouseButtons.Left)
+            {
+                mouseOff = new Point(-e.X, -e.Y); //得到变量的值
+                leftFlag = true;                  //点击左键按下时标注为true;
+            }
+        }
+        private void FormShowImage_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (leftFlag)
+            {
+                Point mouseSet = Control.MousePosition;
+                mouseSet.Offset(mouseOff.X, mouseOff.Y);  //设置移动后的位置
+                Location = mouseSet;
+            }
+        }
+        private void FormShowImage_MouseUp(object sender, MouseEventArgs e)
+        {
+            if (leftFlag)
+            {
+                leftFlag = false;//释放鼠标后标注为false;
+            }
+        }
+        #endregion
+    }
+}

+ 120 - 0
HOZProject/FormShowImage.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

Plik diff jest za duży
+ 176 - 213
HOZProject/FormUCMain.Designer.cs


+ 604 - 2
HOZProject/FormUCMain.cs

@@ -1,10 +1,12 @@
-using System;
+using SmartSEMControl;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
@@ -12,14 +14,38 @@ namespace HOZProject
 {
     public partial class FormUCMain : Form
     {
+        //全局只有一个fatorySEM
+        static FactoryHardware factorySEM = FactoryHardware.Instance;
+        ISEMControl iSEM = factorySEM.ISEM;
+        //电镜连接状态变量
+        bool m_SEMConnectState = false;
+        //电压状态变量
+        bool m_HTState = false;
+        //样品台状态变量
+        bool m_StageStage = false;
+        int ThreadTime = 1000;
         public FormUCMain()
         {
             InitializeComponent();
         }
 
-        private void FormUCMain_LocationChanged(object sender, EventArgs e)
+        #region 窗体事件
+        private void FormUCMain_Load(object sender, EventArgs e)
         {
+            //获取电镜状态
+            Thread thread = new Thread(new ThreadStart(GetSEMConnectState));
+            thread.Start();
         }
+        #endregion
+        #region 获取初始参数
+        public void GetInitState()
+        {
+            if (iSEM != null)
+            {
+                
+            }
+        }
+        #endregion
 
         #region 关闭与最小化按钮事件
         private void pichide_MouseEnter(object sender, EventArgs e)
@@ -81,5 +107,581 @@ namespace HOZProject
             }
         }
         #endregion
+
+        #region SEM功能按钮读写事件
+        #region 连接、关闭设备
+        /// <summary>
+        /// 初始化连接设备
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnConnect_Click(object sender, EventArgs e)
+        {
+            //1.判断当前连接状态
+            if (m_SEMConnectState)
+            {
+                if (iSEM != null)
+                {
+                    iSEM.Dispose();
+                }
+            }
+        }
+
+        #endregion
+
+        #region 获取与设置缩放参数
+        /// <summary>
+        /// 获取缩放参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnenlargeGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetMagnification();
+            if (float.IsNaN(ret))
+            {
+                txtenlarge.Enabled = false;
+                btnenlargeSet.Enabled = false;
+            }
+            else
+            {
+                txtenlarge.Text = ret.ToString();
+                btnenlargeSet.Enabled = true;
+            }
+        }
+        /// <summary>
+        /// 获取缩放参数
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btnenlargeSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtenlarge.Text, out set))
+            {
+                iSEM.SetMagnification(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置亮度参数
+        private void btnBrightnessGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetBrightness();
+            if (float.IsNaN(ret))
+            {
+                txtBrightness.Enabled = false;
+                btnBrightnessSet.Enabled = false;
+            }
+            else
+            {
+                txtBrightness.Text = ret.ToString();
+                btnBrightnessSet.Enabled = true;
+            }
+        }
+
+        private void btnBrightnessSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtBrightness.Text, out set))
+            {
+                iSEM.SetBrightness(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置焦距参数
+        private void btnWDGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetWorkingDistance();
+            if (float.IsNaN(ret))
+            {
+                txtWD.Enabled = false;
+                btnWDSet.Enabled = false;
+            }
+            else
+            {
+                txtWD.Text = ret.ToString();
+                btnWDSet.Enabled = true;
+            }
+        }
+
+        private void btnWDSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtWD.Text, out set))
+            {
+                iSEM.SetWorkingDistance(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置对比度参数
+        private void btnContrastGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetContrast();
+            if (float.IsNaN(ret))
+            {
+                txtContrast.Enabled = false;
+                btnContrastSet.Enabled = false;
+            }
+            else
+            {
+                txtContrast.Text = ret.ToString();
+                btnContrastSet.Enabled = true;
+            }
+        }
+
+        private void btnContrastSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtContrast.Text, out set))
+            {
+                iSEM.SetContrast(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置倾斜矫正参数
+        private void btnTiltAngleGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetTiltAngle();
+            if (float.IsNaN(ret))
+            {
+                txtTiltAngle.Enabled = false;
+                btnTiltAngleSet.Enabled = false;
+            }
+            else
+            {
+                txtTiltAngle.Text = ret.ToString();
+                btnTiltAngleSet.Enabled = true;
+            }
+        }
+
+        private void btnTiltAngleSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtTiltAngle.Text, out set))
+            {
+                iSEM.SetTiltAngle(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置旋转角度参数
+        private void btnScanRotationGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetScanRotation();
+            if (float.IsNaN(ret))
+            {
+                txtScanRotation.Enabled = false;
+                btnScanRotationSet.Enabled = false;
+            }
+            else
+            {
+                txtScanRotation.Text = ret.ToString();
+                btnScanRotationSet.Enabled = true;
+            }
+        }
+
+        private void btnScanRotationSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtScanRotation.Text, out set))
+            {
+
+                iSEM.SetScanRotation(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置像散Y参数
+        private void btnAstigmatismXGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetAstigmatismX();
+            if (float.IsNaN(ret))
+            {
+                txtAstigmatismX.Enabled = false;
+                btnAstigmatismXSet.Enabled = false;
+            }
+            else
+            {
+                txtAstigmatismX.Text = ret.ToString();
+                btnAstigmatismXSet.Enabled = true;
+            }
+        }
+
+        private void btnAstigmatismXSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtAstigmatismX.Text, out set))
+            {
+                iSEM.SetAstigmatismX(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置像散Y参数
+        private void btnAstigmatismYGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetAstigmatismY();
+            if (float.IsNaN(ret))
+            {
+                txtAstigmatismY.Enabled = false;
+                btnAstigmatismYSet.Enabled = false;
+            }
+            else
+            {
+                txtAstigmatismY.Text = ret.ToString();
+                btnAstigmatismYSet.Enabled = true;
+            }
+        }
+
+        private void btnAstigmatismYSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtAstigmatismY.Text, out set))
+            {
+                iSEM.SetAstigmatismY(set);
+            }
+        }
+        #endregion
+
+        #region 获取像素尺寸
+        private void btnPixelSizeGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetPixelSize();
+            if (float.IsNaN(ret))
+            {
+                txtPixelSize.Text = "NaN";
+            }
+            else
+            {
+                txtPixelSize.Text = ret.ToString();
+            }
+        }
+        #endregion
+
+        #region 切换电压状态
+        private void pbHT_Click(object sender, EventArgs e)
+        {
+            if (!m_HTState)
+            {
+                //打开电压
+                iSEM.CmdOpenVoltage();
+                m_HTState = true;
+                pbHT.BackgroundImage = Properties.Resources.OFF;
+            }
+            else
+            {
+                //关闭电压
+                iSEM.CmdCloseVoltage();
+                m_HTState = false;
+                pbHT.BackgroundImage = Properties.Resources.ON;
+            }
+        }
+        #endregion
+
+        #region 获取样品台六轴位置信息
+        private void btnGetStagePosition_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                float[] pt = iSEM.GetStagePosition();
+                if (!float.IsNaN(pt[0]))
+                {
+                    txtStageX.Text = pt[0].ToString();
+                }
+                if (!float.IsNaN(pt[1]))
+                {
+                    txtStageY.Text = pt[1].ToString();
+                }
+                if (!float.IsNaN(pt[2]))
+                {
+                    txtStageZ.Text = pt[2].ToString();
+                }
+                if (!float.IsNaN(pt[3]))
+                {
+                    txtStageT.Text = pt[3].ToString();
+                }
+                if (!float.IsNaN(pt[4]))
+                {
+                    txtStageR.Text = pt[4].ToString();
+                }
+                if (!float.IsNaN(pt[5]))
+                {
+                    txtStageM.Text = pt[5].ToString();
+                }
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+        #endregion
+
+        #region 获取与设置样品台X轴参数
+        private void btnStageGetX_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetStageAtX();
+            if (float.IsNaN(ret))
+            {
+                txtStageX.Text = "NaN";
+            }
+            else
+            {
+                txtStageX.Text = ret.ToString();
+            }
+        }
+
+        private void btnStageSetX_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtStageX.Text, out set))
+            {
+                iSEM.SetStageGotoX(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置样品台T轴参数
+        private void btnStageGetT_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetStageAtT();
+            if (float.IsNaN(ret))
+            {
+                txtStageT.Text = "NaN";
+            }
+            else
+            {
+                txtStageT.Text = ret.ToString();
+            }
+        }
+
+        private void btnStageSetT_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtStageT.Text, out set))
+            {
+                iSEM.SetStageGotoT(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置样品台Y轴参数
+        private void btnStageGetY_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetStageAtY();
+            if (float.IsNaN(ret))
+            {
+                txtStageY.Text = "NaN";
+            }
+            else
+            {
+                txtStageY.Text = ret.ToString();
+            }
+        }
+
+        private void btnStageSetY_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtStageY.Text, out set))
+            {
+                iSEM.SetStageGotoY(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置样品台R轴参数
+        private void btnStageGetR_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetStageAtR();
+            if (float.IsNaN(ret))
+            {
+                txtStageR.Text = "NaN";
+            }
+            else
+            {
+                txtStageR.Text = ret.ToString();
+            }
+        }
+
+        private void btnStageSetR_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtStageR.Text, out set))
+            {
+                iSEM.SetStageGotoR(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置样品台Z轴参数
+        private void btnStageGetZ_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetStageAtZ();
+            if (float.IsNaN(ret))
+            {
+                txtStageZ.Text = "NaN";
+            }
+            else
+            {
+                txtStageZ.Text = ret.ToString();
+            }
+        }
+
+        private void btnStageSetZ_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtStageZ.Text, out set))
+            {
+                iSEM.SetStageGotoZ(set);
+            }
+        }
+        #endregion
+
+        #region 获取与设置样品台M轴参数
+        private void btnStageGetM_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetStageAtM();
+            if (float.IsNaN(ret))
+            {
+                txtStageM.Text = "NaN";
+            }
+            else
+            {
+                txtStageM.Text = ret.ToString();
+            }
+        }
+
+        private void btnStageSetM_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtStageM.Text, out set))
+            {
+                iSEM.SetStageGotoM(set);
+            }
+        }
+        #endregion
+        #endregion
+
+        #region 获取状态(电镜连接状态、自动函数的状态、样品台状态)
+        public void GetSEMConnectState()
+        {
+            bool result = GetAllState(StateType.SEMConnectState);
+            if (result)
+            {
+                //已连接,设置按钮图像
+                btnConnect.BackgroundImage = Properties.Resources.CloseImg;
+            }
+            else
+            {
+                btnConnect.BackgroundImage = Properties.Resources.ConnectImg;
+            }
+            //设置电镜连接状态:True
+            m_SEMConnectState = result;
+        }
+        public void GetAutoFUNCState()
+        {
+            bool result = GetAllState(StateType.AutoFUNCState);
+            if (result)
+            {
+            }
+            else
+            {
+            }
+        }
+        public void GetStageState()
+        {
+            bool result = GetAllState(StateType.StageState);
+            if (result)
+            {
+                btnConnect.BackgroundImage = Properties.Resources.CloseImg;
+            }
+            else
+            {
+                btnConnect.BackgroundImage = Properties.Resources.ConnectImg;
+            }
+        }
+        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);
+                    }
+            }
+            return bResult;
+        }
+        /// <summary>
+        /// 状态枚举
+        /// </summary>
+        public enum StateType
+        {
+            SEMConnectState = 0,
+            AutoFUNCState = 1,
+            StageState = 2
+        }
+        #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);
+            }
+        }
+
+        private void btnStop_Click(object sender, EventArgs e)
+        {
+            if (iSEM != null)
+            {
+                //即刻停止
+                iSEM.CmdStageAbort();
+            }
+        }
+
+        private void btnGetImage_Click(object sender, EventArgs e)
+        {
+            FormShowImage fShowImage = new FormShowImage();
+            fShowImage.ShowDialog();
+        }
     }
 }

+ 3 - 3
HOZProject/FormUnitControl.Designer.cs

@@ -140,7 +140,7 @@
             this.btnInit.TabIndex = 1;
             this.btnInit.Text = "初始化设备";
             this.btnInit.UseVisualStyleBackColor = true;
-            this.btnInit.Click += new System.EventHandler(this.btnInit_Click);
+            //this.btnInit.Click += new System.EventHandler(this.btnInit_Click);
             // 
             // btnCloseCtrl
             // 
@@ -152,7 +152,7 @@
             this.btnCloseCtrl.TabIndex = 2;
             this.btnCloseCtrl.Text = "关闭设备";
             this.btnCloseCtrl.UseVisualStyleBackColor = true;
-            this.btnCloseCtrl.Click += new System.EventHandler(this.btnCloseCtrl_Click);
+            //this.btnCloseCtrl.Click += new System.EventHandler(this.btnCloseCtrl_Click);
             // 
             // btnSetNotify
             // 
@@ -164,7 +164,7 @@
             this.btnSetNotify.TabIndex = 3;
             this.btnSetNotify.Text = "设置通知";
             this.btnSetNotify.UseVisualStyleBackColor = true;
-            this.btnSetNotify.Click += new System.EventHandler(this.btnSetNotify_Click);
+            //this.btnSetNotify.Click += new System.EventHandler(this.btnSetNotify_Click);
             // 
             // btnenlargeGet
             // 

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

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

+ 6 - 0
HOZProject/Properties/Resources.resx

@@ -154,4 +154,10 @@
   <data name="GetLocationBG" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\GetLocationBG.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="CloseImg" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\CloseImg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <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>
 </root>

BIN
HOZProject/Resources/CloseImg.jpg


BIN
HOZProject/Resources/ConnectImg.jpg


BIN
HOZProject/Resources/UCMain.png


+ 15 - 0
HOZProject/UnitControl.csproj

@@ -47,6 +47,12 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="FormShowImage.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FormShowImage.Designer.cs">
+      <DependentUpon>FormShowImage.cs</DependentUpon>
+    </Compile>
     <Compile Include="FormUCMain.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -61,6 +67,9 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="FormShowImage.resx">
+      <DependentUpon>FormShowImage.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FormUCMain.resx">
       <DependentUpon>FormUCMain.cs</DependentUpon>
     </EmbeddedResource>
@@ -129,6 +138,12 @@
   <ItemGroup>
     <None Include="Resources\buttonBG.jpg" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\CloseImg.jpg" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\ConnectImg.jpg" />
+  </ItemGroup>
   <ItemGroup>
     <None Include="Resources\UCMain.png" />
   </ItemGroup>

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików