Prechádzať zdrojové kódy

修复鼠标在“测量状态”页面移动报错的问题

zhangjiaxin 4 rokov pred
rodič
commit
84420ecbf2

+ 19 - 26
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSMeasureStatusWindow.cs

@@ -29,7 +29,7 @@ namespace OTSMeasureApp
         public byte[] Imagedata = new byte[m_iWidth];
 
         static int m_iWidth = 1024;
-        static int m_iHeight = 768;
+        static int m_iHeight = 704;
 
         OTSImageData m_ImageData = null;
         //获取BSE图时最初的位置
@@ -118,28 +118,19 @@ namespace OTSMeasureApp
 
         public OTSMeasureStatusWindow(OTSIncAMeasureAppForm MeasureApp)
         {
-            
-                InitializeComponent();
-
-                m_MeasureAppForm = MeasureApp;
-                if (m_ImageData == null)
-                {
-                    m_ImageData = new OTSImageData(this, m_MeasureAppForm);
-                }
-
-                //建立图像数据
-                bBseData = new byte[m_iWidth * m_iHeight];
-
-                m_ElementPointGDIObjects = new List<ARectangleGDIObject>();
-
-                //进入时首先对XRayTable进行隐藏
-                panelXray.Visible = false;
-
-                //国际化
-                lan = new OTSSysMgrTools.Language(this);
-                table = lan.GetNameTable(this.Name);
-         
 
+            InitializeComponent();
+            m_MeasureAppForm = MeasureApp;
+            if (m_ImageData == null)
+            {
+                m_ImageData = new OTSImageData(this, m_MeasureAppForm);
+            }
+            m_ElementPointGDIObjects = new List<ARectangleGDIObject>();
+            //进入时首先对XRayTable进行隐藏
+            panelXray.Visible = false;
+            //国际化
+            lan = new OTSSysMgrTools.Language(this);
+            table = lan.GetNameTable(this.Name);
         }
         /// <summary>
         /// 在控件中显示BSE图像
@@ -287,13 +278,15 @@ namespace OTSMeasureApp
             try
             {
                 //获取电镜中图像大小
-                string str = m_MeasureAppForm.m_ProjParam.GetBSEImageSize();
+                string str = m_MeasureAppForm.m_ProjParam.GetBSEImageSize();// 举例:1024X768 
                 string[] sArray = str.Split('X');
-                if (sArray[(int)IndexNum.First] != "" && sArray[(int)IndexNum.Second] != "")
+                if (sArray[0] != "" && sArray[1] != "")
                 {
-                    m_iWidth = Convert.ToInt32(sArray[(int)IndexNum.First]);
-                    m_iHeight = Convert.ToInt32(sArray[(int)IndexNum.Second]);
+                    m_iWidth = Convert.ToInt32(sArray[0]);
+                    m_iHeight = Convert.ToInt32(sArray[1]);
                 }
+                //建立图像数据
+                bBseData = new byte[m_iWidth * m_iHeight];
                 //获取图像数据
                 int nDwellTime = 4;
                 try

+ 187 - 187
OTSSysMgrTools/ImageDispose.cs

@@ -88,182 +88,182 @@ namespace OTSSysMgrTools
         /// </summary>
         /// <param name="fileUrl">文件路径文件名称</param>
         /// <returns>byte[]</returns>
-        public static byte[] GetFileData(string fileUrl)
-        {
-            FileStream pFileStream = null;
-            byte[] pReadByte = new byte[0];
-            try
-            {
-                //读取文本文件
-                pFileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read);
-                //实例读取字节流对象
-                StreamReader sr = new StreamReader(pFileStream, System.Text.Encoding.Default);
-                string temp = sr.ReadToEnd();
-                //转换byte数组
-                byte[] byteArray = System.Text.Encoding.Default.GetBytes(temp);
-                //生成字符数组
-                string[] tempGroup = temp.Split(',');
-                //关闭读取对象
-                sr.Close();
-                string AppendStr = string.Empty;
-                for (int i = 0; i < tempGroup.Length; i++)
-                {
-                    //十进制转十六进制
-                    AppendStr += Convert.ToString(Convert.ToInt32(tempGroup[i]), 16) + " ";
-                }
-                //替换字符符号
-                AppendStr = AppendStr.Replace(" ", "");
-                if ((AppendStr.Length % 2) != 0)
-                {
-                    AppendStr += " ";
-                }
-                byte[] returnBytes = new byte[AppendStr.Length / 2];
-                //转换为byte[]数组
-                for (int i = 0; i < returnBytes.Length; i++)
-                {
-                    returnBytes[i] = Convert.ToByte(AppendStr.Substring(i * 2, 2), 16);
-                }
-                return returnBytes;
-            }
-            catch
-            {
-                return pReadByte;
-            }
-            finally
-            {
-                if (pFileStream != null)
-                    pFileStream.Close();
-            }
-        }
+        //public static byte[] GetFileData(string fileUrl)
+        //{
+        //    FileStream pFileStream = null;
+        //    byte[] pReadByte = new byte[0];
+        //    try
+        //    {
+        //        //读取文本文件
+        //        pFileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read);
+        //        //实例读取字节流对象
+        //        StreamReader sr = new StreamReader(pFileStream, System.Text.Encoding.Default);
+        //        string temp = sr.ReadToEnd();
+        //        //转换byte数组
+        //        byte[] byteArray = System.Text.Encoding.Default.GetBytes(temp);
+        //        //生成字符数组
+        //        string[] tempGroup = temp.Split(',');
+        //        //关闭读取对象
+        //        sr.Close();
+        //        string AppendStr = string.Empty;
+        //        for (int i = 0; i < tempGroup.Length; i++)
+        //        {
+        //            //十进制转十六进制
+        //            AppendStr += Convert.ToString(Convert.ToInt32(tempGroup[i]), 16) + " ";
+        //        }
+        //        //替换字符符号
+        //        AppendStr = AppendStr.Replace(" ", "");
+        //        if ((AppendStr.Length % 2) != 0)
+        //        {
+        //            AppendStr += " ";
+        //        }
+        //        byte[] returnBytes = new byte[AppendStr.Length / 2];
+        //        //转换为byte[]数组
+        //        for (int i = 0; i < returnBytes.Length; i++)
+        //        {
+        //            returnBytes[i] = Convert.ToByte(AppendStr.Substring(i * 2, 2), 16);
+        //        }
+        //        return returnBytes;
+        //    }
+        //    catch
+        //    {
+        //        return pReadByte;
+        //    }
+        //    finally
+        //    {
+        //        if (pFileStream != null)
+        //            pFileStream.Close();
+        //    }
+        //}
         #endregion
 
         #region 根据分辨率获取图像
-        public static bool GetScanImage(string ImgWidth, string ImgHeight, string DwellTime, COTSControlFunExport cfun, ref byte[] ImageByte)
-        {
-            try
-            {
-
-                //设置图像分辨率
-                int width = 0;
-                int height = 0;
-                //获取宽度
-                width = Convert.ToInt32(ImgWidth);
-                height = Convert.ToInt32(ImgHeight);
+        //public static bool GetScanImage(string ImgWidth, string ImgHeight, string DwellTime, COTSControlFunExport cfun, ref byte[] ImageByte)
+        //{
+        //    try
+        //    {
+
+        //        //设置图像分辨率
+        //        int width = 0;
+        //        int height = 0;
+        //        //获取宽度
+        //        width = Convert.ToInt32(ImgWidth);
+        //        height = Convert.ToInt32(ImgHeight);
                 
-                int a_ExternalMode = 0;
-                //获取终止模式
-                a_ExternalMode = cfun.GetSemExternalMode();
+        //        int a_ExternalMode = 0;
+        //        //获取终止模式
+        //        a_ExternalMode = cfun.GetSemExternalMode();
                 
-                //保存初始模式变量
-                int a_oldMode = 0;
-                //获取初始模式
-                if (!cfun.GetSemScanMode(ref a_oldMode))
-                {
-                    return false;
-                }
-                //设置当前模式
-                if (!cfun.SetSemScanMode(a_ExternalMode))
-                {
-                    return false;
-                }
+        //        //保存初始模式变量
+        //        int a_oldMode = 0;
+        //        //获取初始模式
+        //        if (!cfun.GetSemScanMode(ref a_oldMode))
+        //        {
+        //            return false;
+        //        }
+        //        //设置当前模式
+        //        if (!cfun.SetSemScanMode(a_ExternalMode))
+        //        {
+        //            return false;
+        //        }
                 
-                #region BeamBlank
-                int a_nBeamBlank = 0;
-                //获取参数
-                if (!cfun.GetSemBeamBlank(ref a_nBeamBlank))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return false;
-                }
-                //设置参数
-                if (!cfun.SetSemBeamBlank(0))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return false;
-                }
-                #endregion
+        //        #region BeamBlank
+        //        int a_nBeamBlank = 0;
+        //        //获取参数
+        //        if (!cfun.GetSemBeamBlank(ref a_nBeamBlank))
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //            return false;
+        //        }
+        //        //设置参数
+        //        if (!cfun.SetSemBeamBlank(0))
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //            return false;
+        //        }
+        //        #endregion
                
-                #region 获得放大倍数
-                //获得放大倍数
-                double a_dMagnification = 0;
-                //获取参数
-                if (!cfun.GetSemMagnification(ref a_dMagnification))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return false;
-                }
-                #endregion
+        //        #region 获得放大倍数
+        //        //获得放大倍数
+        //        double a_dMagnification = 0;
+        //        //获取参数
+        //        if (!cfun.GetSemMagnification(ref a_dMagnification))
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //            return false;
+        //        }
+        //        #endregion
 
 
                 
 
-                #region 获取 电镜 X、Y轴 与角度
-                //获取 电镜 X、Y轴 与角度
-                double PositionX = 0;
-                double PositionY = 0;
-                double PositionR = 0;
-                //获取参数
-                if (!cfun.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return false;
-                }
-                #endregion
-
-                #region 设置图像分辨率
-                //设置宽度
-                if (!cfun.SetImageSize(width))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return false;
-                }
-                #endregion
-
-                #region 采集时间
-                //采集时间
-                int nDwellTime = 16;
-                nDwellTime = Convert.ToInt32(DwellTime);
-                //nDwellTime = Convert.ToInt32(tbCollectionTime.Text);
-                //设置采集时间
-                if (!cfun.SetDwellTime(nDwellTime))
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                    return false;
-                }
-                #endregion
-
-                #region MatrixSize
-                //获得放大倍数
-                int a_MatrixSize = 0;
-                Size size = new Size();
-                //获取参数
-                size = cfun.GetMatrixSize(a_MatrixSize);
-                #endregion
+        //        #region 获取 电镜 X、Y轴 与角度
+        //        //获取 电镜 X、Y轴 与角度
+        //        double PositionX = 0;
+        //        double PositionY = 0;
+        //        double PositionR = 0;
+        //        //获取参数
+        //        if (!cfun.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR))
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //            return false;
+        //        }
+        //        #endregion
+
+        //        #region 设置图像分辨率
+        //        //设置宽度
+        //        if (!cfun.SetImageSize(width, height))
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //            return false;
+        //        }
+        //        #endregion
+
+        //        #region 采集时间
+        //        //采集时间
+        //        int nDwellTime = 16;
+        //        nDwellTime = Convert.ToInt32(DwellTime);
+        //        //nDwellTime = Convert.ToInt32(tbCollectionTime.Text);
+        //        //设置采集时间
+        //        if (!cfun.SetDwellTime(nDwellTime))
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //            return false;
+        //        }
+        //        #endregion
+
+        //        #region MatrixSize
+        //        //获得放大倍数
+        //        int a_MatrixSize = 0;
+        //        Size size = new Size();
+        //        //获取参数
+        //        size = cfun.GetMatrixSize(a_MatrixSize);
+        //        #endregion
                 
-                //获取图像数据
-                int resultCount = width * height;
-                int GetImgCount = cfun.AcquireBSEImage(0, 0, 0, ref ImageByte);
-
-                if (resultCount == GetImgCount)
-                {
-                    //设置为原始 扫描模式
-                    cfun.SetSemScanMode(a_oldMode);
-                }
-                else
-                {
-                    cfun.SetSemScanMode(a_oldMode);
-                }
-                return true;
-
-            }
-            catch (Exception ex)
-            {
-                //记录日志
-                 //NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
-                 // log.Error(ex.Message.ToString());
-                return false;
-            }
-        }
+        //        //获取图像数据
+        //        int resultCount = width * height;
+        //        int GetImgCount = cfun.AcquireBSEImage(0, 0, 0, ref ImageByte);
+
+        //        if (resultCount == GetImgCount)
+        //        {
+        //            //设置为原始 扫描模式
+        //            cfun.SetSemScanMode(a_oldMode);
+        //        }
+        //        else
+        //        {
+        //            cfun.SetSemScanMode(a_oldMode);
+        //        }
+        //        return true;
+
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        //记录日志
+        //         //NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
+        //         // log.Error(ex.Message.ToString());
+        //        return false;
+        //    }
+        //}
         #endregion
 
         public static int GetScanImage(int iWidth, int iHeigh, string DwellTime, ref byte[] bImageData)
@@ -348,7 +348,7 @@ namespace OTSSysMgrTools
 
                 #region 设置图像分辨率
                 //设置宽度
-                if (!cfun.SetImageSize(iWidth))
+                if (!cfun.SetImageSize(iWidth, iHeigh))
                 {
                     cfun.SetSemScanMode(a_oldMode);
                     return 0;
@@ -423,30 +423,30 @@ namespace OTSSysMgrTools
         /// </summary>
         /// <param name="buff">byte数组</param>
         /// <param name="savepath">保存地址</param>
-        public static void BytesConvertToFile(byte[] buff, string savepath, string fileName)
-        {
-            try
-            {
-
-                //如果不存在就创建Enclosure文件夹 
-                if (Directory.Exists(savepath + @"\Enclosure\") == false)
-                {
-                    Directory.CreateDirectory(savepath + @"\Enclosure\");
-                }
-
-                if (System.IO.File.Exists(savepath + @"\Enclosure\" + fileName))
-                {
-                    System.IO.File.Delete(savepath + @"\Enclosure\" + fileName);
-                }
-                Bitmap bitmap=ToGrayBitmap(buff, 1024, 768);
+        //public static void BytesConvertToFile(byte[] buff, string savepath, string fileName)
+        //{
+        //    try
+        //    {
+
+        //        //如果不存在就创建Enclosure文件夹 
+        //        if (Directory.Exists(savepath + @"\Enclosure\") == false)
+        //        {
+        //            Directory.CreateDirectory(savepath + @"\Enclosure\");
+        //        }
+
+        //        if (System.IO.File.Exists(savepath + @"\Enclosure\" + fileName))
+        //        {
+        //            System.IO.File.Delete(savepath + @"\Enclosure\" + fileName);
+        //        }
+        //        Bitmap bitmap=ToGrayBitmap(buff, 1024, 768);
                
-                bitmap.Save(savepath + @"\Enclosure\" + fileName);
+        //        bitmap.Save(savepath + @"\Enclosure\" + fileName);
                 
-            }
-            catch (Exception)
-            {
+        //    }
+        //    catch (Exception)
+        //    {
 
-            }
-        }
+        //    }
+        //}
     }
 }