using System; using System.Collections; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace OTSMeasureApp { public class CStageManage { #region 添加样品 /// /// 添加样品 /// /// /// /// /// /// public static bool AddSample(string SampleHoleName, string SampleName, ARectangleGDIObject m_MeasureGDIObjects, OTSSamplespaceWindow oTSSamplespaceWindow,float globalZoomNum) { try { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects != null) { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects.Count > 0) { ARectangleGDIObject itemAdd = null; //设置样品选择状态为非工作样品 foreach (ARectangleGDIObject itemSample in OTSSamplespaceWindow.m_SampleGDIObjects) { //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor); itemSample.SelColor = ColorTranslator.FromHtml(ColorStr); itemSample.IsWorkSample = false; } foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_SampleHoleGDIObjects) { itemAdd = items; if (items.Name == SampleHoleName) { //获取样品台类型 int shape = itemAdd.CreateType;// == (int)CreateRectangleType.Rectangle ? (int)CreateRectangleType.Rectangle: (int)CreateRectangleType.Ellipse; //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); Color selColor = ColorTranslator.FromHtml(ColorStr); CreateRectangle NewSample = new CreateRectangle(items.Region, (int)CreateRectangleType.SelectSample, shape, items.Name, selColor); //累加样品数量 items.SampleCount += 1; items.IsWorkSample = true; NewSample.SampleName = SampleName; NewSample.Name = itemAdd.Name; //设置当前添加的样品为工作样品 NewSample.IsWorkSample = true; // 获取样品孔的大小与初始大小 NewSample.Region = items.Region; NewSample.RegionF = items.RegionF; NewSample.DrawRegionF = items.DrawRegionF; //绘制样品路径 GraphicsPath NewSamplePath = new GraphicsPath(); if (NewSample.Shape == (int)CreateRectangleType.Circle) { NewSamplePath.AddEllipse(NewSample.Region); } else { NewSamplePath.AddRectangle(NewSample.Region); } NewSample.GPath = NewSamplePath; OTSSamplespaceWindow.m_SampleGDIObjects.Add(NewSample); //获取测量区域尺寸与位置 m_MeasureGDIObjects = GetSampleMeasureInfo(NewSample, m_MeasureGDIObjects, globalZoomNum); //设置样品孔名称 m_MeasureGDIObjects.Name = items.Name; //根据节点设置样品台窗口中所选择的样品名称 OTSSamplespaceWindow.m_SampleSelectName = SampleName; //添加测量区域 return AddMeasure(m_MeasureGDIObjects.CreateType, m_MeasureGDIObjects); } } } } } catch (Exception) { } return false; } #region 根据样品位置 获取测量区域位置 public static ARectangleGDIObject GetSampleMeasureInfo(ARectangleGDIObject NewSample, ARectangleGDIObject m_MeasureGDIObjects, float globalZoomNum) { //根据样品位置 获取测量区域位置 int MeasurePointX = (int)(NewSample.Region.Location.X + ((NewSample.Region.Size.Width - (m_MeasureGDIObjects.Region.Width * globalZoomNum)) / 2)); int MeasurePointY = (int)(NewSample.Region.Location.Y + ((NewSample.Region.Size.Height - (m_MeasureGDIObjects.Region.Height * globalZoomNum)) / 2)); int MeasureWidth = Convert.ToInt32(m_MeasureGDIObjects.Region.Width * globalZoomNum); int MeasureHeight = Convert.ToInt32(m_MeasureGDIObjects.Region.Height * globalZoomNum); float MeasureFPointX = (float)(NewSample.RegionF.Location.X + (NewSample.RegionF.Size.Width - m_MeasureGDIObjects.Region.Width ) / 2); float MeasureFPointY = (float)(NewSample.RegionF.Location.Y + (NewSample.RegionF.Size.Height - m_MeasureGDIObjects.Region.Height) / 2); float MeasureFWidth = Convert.ToSingle(m_MeasureGDIObjects.RegionF.Width); float MeasureFHeight = Convert.ToSingle(m_MeasureGDIObjects.RegionF.Height); float MeasureDrawPointX = (float)(NewSample.DrawRegionF.Location.X + (NewSample.DrawRegionF.Size.Width - m_MeasureGDIObjects.Region.Width) / 2); float MeasureDrawPointY = (float)(NewSample.DrawRegionF.Location.Y + (NewSample.DrawRegionF.Size.Height - m_MeasureGDIObjects.Region.Height) / 2); float MeasureDrawWidth = Convert.ToSingle(m_MeasureGDIObjects.DrawRegionF.Width); float MeasureDrawHeight = Convert.ToSingle(m_MeasureGDIObjects.DrawRegionF.Height); m_MeasureGDIObjects.Region = new Rectangle(new Point(MeasurePointX, MeasurePointY), new Size(MeasureWidth, MeasureHeight)); m_MeasureGDIObjects.RegionF = new RectangleF(new PointF(MeasureFPointX, MeasureFPointY), new SizeF(MeasureFWidth, MeasureFHeight)); m_MeasureGDIObjects.DrawRegionF = new RectangleF(new PointF(MeasureDrawPointX, MeasureDrawPointY), new SizeF(MeasureDrawWidth, MeasureDrawHeight)); return m_MeasureGDIObjects; } #endregion /// /// 添加样品 /// /// /// /// /// /// public static bool AddOnlySample(string SampleHoleName, string SampleName, OTSSamplespaceWindow oTSSamplespaceWindow) { try { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects != null) { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects.Count > 0) { ARectangleGDIObject itemAdd = null; //设置样品选择状态为非工作样品 foreach (ARectangleGDIObject itemSample in OTSSamplespaceWindow.m_SampleGDIObjects) { //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor); itemSample.SelColor = ColorTranslator.FromHtml(ColorStr); itemSample.IsWorkSample = false; } foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_SampleHoleGDIObjects) { itemAdd = items; if (items.Name == SampleHoleName) { //获取样品台类型 int shape = itemAdd.CreateType;// == (int)CreateRectangleType.Rectangle ? (int)CreateRectangleType.Rectangle: (int)CreateRectangleType.Ellipse; //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); Color selColor = ColorTranslator.FromHtml(ColorStr); CreateRectangle AddSample = new CreateRectangle(items.Region, (int)CreateRectangleType.SelectSample, shape, items.Name, selColor); //累加样品数量 items.SampleCount += 1; items.IsWorkSample = true; AddSample.SampleName = SampleName; AddSample.Name = itemAdd.Name; //绘制测量区域路径 GraphicsPath AddSamplePath = new GraphicsPath(); AddSamplePath.AddRectangle(AddSample.Region); AddSample.GPath = AddSamplePath; OTSSamplespaceWindow.m_SampleGDIObjects.Add(AddSample); return true; } } } } return false; } catch (Exception) { } return false; } #endregion #region 删除样品 /// /// 删除样品 /// /// 是否选择样品孔 0:未选择 1:选择 /// 样品孔名称 /// 是否成功 public static bool DeleteStage(int IsSelect, string SampleName) { try { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects != null) { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects.Count > 0) { ARectangleGDIObject itemAdd = null; if (OTSSamplespaceWindow.m_SampleGDIObjects.Count > 0) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_SampleGDIObjects) { itemAdd = items; if (IsSelect > 0) { if (items.SampleName == SampleName) { foreach (ARectangleGDIObject itemSampleHole in OTSSamplespaceWindow.m_SampleHoleGDIObjects) { if (itemSampleHole.Name == itemAdd.Name) { itemSampleHole.SampleCount -= 1; break; } } //将样品孔恢复未拖动状态 items.IsSelect = false; OTSSamplespaceWindow.m_SampleGDIObjects.Remove(items); return true; } } else { //删除样品测量 if (items.SampleName == SampleName) { //将样品孔恢复未拖动状态 items.IsSelect = false; OTSSamplespaceWindow.m_SampleGDIObjects.Remove(items); return true; } } } } } } } catch (Exception) { } return false; } #endregion #region 通过样品名称 删除样品 /// /// 删除样品 /// /// 样品孔名称 /// 是否成功 public static bool DeleteSample(string SampleName) { try { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects != null) { if (OTSSamplespaceWindow.m_SampleHoleGDIObjects.Count > 0) { ARectangleGDIObject itemAdd = null; if (OTSSamplespaceWindow.m_SampleGDIObjects.Count > 0) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_SampleGDIObjects) { itemAdd = items; if (items.SampleName == SampleName) { foreach (ARectangleGDIObject itemSampleHole in OTSSamplespaceWindow.m_SampleHoleGDIObjects) { if (itemSampleHole.Name == itemAdd.Name) { itemSampleHole.SampleCount -= 1; break; } } //将样品孔恢复未拖动状态 items.IsSelect = false; OTSSamplespaceWindow.m_SampleGDIObjects.Remove(items); if (DeleteMeasure(SampleName)) { return true; } } } } } } } catch (Exception) { } return false; } #endregion #region 修改测量区域选择状态 public static void SetMeasureState(Color setColor) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_MeasureGDIObjects) { items.SelColor = setColor; } } #endregion #region 修改样品选择状态 public static void SetSampleState(Color setColor) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_SampleGDIObjects) { if (items.IsDragging) { //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); items.SelColor = ColorTranslator.FromHtml(ColorStr); } else { items.SelColor = setColor; } } } #endregion #region 添加测量 /// /// 添加测量 /// /// 是否选择样品 0:未选择 1:选择 /// 样品名称 /// 是否成功 public static bool AddMeasure(int IsSelect, string sampleName) { try { if (OTSSamplespaceWindow.m_SampleGDIObjects != null) { if (OTSSamplespaceWindow.m_SampleGDIObjects.Count > 0) { ARectangleGDIObject itemAdd = null; if (IsSelect > 0) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_SampleGDIObjects) { //判断是否与传递的样品名称相同 itemAdd = items; if (items.Name == sampleName) { //添加测量区域 //获取样品台类型 int shape = itemAdd.CreateType;// == (int)CreateRectangleType.Rectangle ? (int)CreateRectangleType.Rectangle: (int)CreateRectangleType.Ellipse; GraphicsPath MeasurePath = new GraphicsPath(); if (shape == (int)CreateRectangleType.Rectangle) { MeasurePath.AddRectangle(itemAdd.Region); } else { MeasurePath.AddEllipse(itemAdd.Region); } //缩小与样品的尺寸 Rectangle rectMeasure = items.Region; rectMeasure.X = rectMeasure.X + 5; rectMeasure.Y = rectMeasure.Y + 5; rectMeasure.Width = rectMeasure.Width - 10; rectMeasure.Height = rectMeasure.Height - 10; //与样品中心相差的距离 Point sampleCenterDifferPoint = new Point(); //获取测量区域中心与样品中心相差的距离 sampleCenterDifferPoint = OTSSamplespaceGraphicsPanelFun.GetSampleCenterDifferCenterPoint(rectMeasure, items.Region); //创建测量区域 //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor); CreateRectangle selectState = new CreateRectangle(rectMeasure, sampleCenterDifferPoint, (int)CreateRectangleType.MeasureArea, shape, items.Name, items.Name, ColorTranslator.FromHtml(ColorStr)); selectState.GPath = MeasurePath; OTSSamplespaceWindow.m_MeasureGDIObjects.Add(selectState); return true; } } } else { //默认添加测量 itemAdd = OTSSamplespaceWindow.m_SampleGDIObjects[0]; CreateRectangle selectState = new CreateRectangle(itemAdd.Region, (int)CreateRectangleType.MeasureArea, sampleName); GraphicsPath MeasurePath = new GraphicsPath(); if (selectState.Shape == (int)CreateRectangleType.Rectangle) { MeasurePath.AddRectangle(itemAdd.Region); } else { MeasurePath.AddEllipse(itemAdd.Region); } selectState.GPath = MeasurePath; OTSSamplespaceWindow.m_MeasurePathGDIObjects.Add(selectState); return true; } } } } catch (Exception) { throw; } return false; } #endregion #region 添加测量 /// /// 添加测量 /// /// 是否选择样品 0:未选择 1:选择 /// 样品名称 /// 是否成功 public static bool AddMeasure(int CreateType, ARectangleGDIObject m_MeasureGDIObjects) { try { //添加测量区域 int shape = CreateType;// == 1 ? 1 : 0; GraphicsPath MeasurePath = new GraphicsPath(); if (shape == (int)CreateRectangleType.Rectangle) { MeasurePath.AddRectangle(m_MeasureGDIObjects.Region); } else { MeasurePath.AddEllipse(m_MeasureGDIObjects.Region); } //缩小与样品的尺寸 Rectangle rectMeasure = m_MeasureGDIObjects.Region; Color MeasureColor = Color.Red; CreateRectangle MeasureRect = new CreateRectangle(rectMeasure, m_MeasureGDIObjects.SampleCenterDifferCenterPoint, (int)CreateRectangleType.MeasureArea, shape, m_MeasureGDIObjects.Name, m_MeasureGDIObjects.SampleName, MeasureColor); MeasureRect.GPath = MeasurePath; MeasureRect.sampleName = m_MeasureGDIObjects.SampleName; MeasureRect.Name = m_MeasureGDIObjects.Name; //获取缩放前尺寸与位置 MeasureRect.RegionF = m_MeasureGDIObjects.RegionF; MeasureRect.DrawRegionF = m_MeasureGDIObjects.DrawRegionF; OTSSamplespaceWindow.m_MeasureGDIObjects.Add(MeasureRect); return true; } catch (Exception) { return false; } } #endregion #region 复位测量 /// /// 复位测量 /// /// 是否选择样品 0:圆形 3:矩形 /// 测量区域 /// 是否成功 public static ARectangleGDIObject ResetMeasure(int CreateType, ARectangleGDIObject m_SampleGDIObjects, ARectangleGDIObject m_MeasureGDIObjects, float globalZoomNum) { try { //复位测量 int shape = CreateType; GraphicsPath MeasurePath = new GraphicsPath(); if (shape == (int)CreateRectangleType.Rectangle) { MeasurePath.AddRectangle(m_SampleGDIObjects.Region); } else { MeasurePath.AddEllipse(m_SampleGDIObjects.Region); } //缩小与样品的尺寸 Rectangle rectMeasure = m_SampleGDIObjects.Region; Color MeasureColor = Color.Red; return GetSampleMeasureInfo(m_SampleGDIObjects, m_MeasureGDIObjects, globalZoomNum); } catch (Exception) { return null; } } #endregion #region 通过样品名称 删除测量 /// /// 通过样品名称 删除测量 /// /// 测量名称 /// 是否成功 public static bool DeleteMeasure(string sampleName) { try { if (OTSSamplespaceWindow.m_MeasureGDIObjects.Count > 0) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_MeasureGDIObjects) { //删除样品测量 if (items.SampleName == sampleName) { //将样品孔恢复未拖动状态 items.IsSelect = false; OTSSamplespaceWindow.m_MeasureGDIObjects.Remove(items); //设置样品与测量区域 //设置颜色 string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor); SetSampleState(ColorTranslator.FromHtml(ColorStr)); SetMeasureState(ColorTranslator.FromHtml(ColorStr)); OTSSamplespaceWindow.m_IsMeasure = false; foreach (ARectangleGDIObject sampleItem in OTSSamplespaceWindow.m_SampleGDIObjects) { if (sampleItem.SampleName == items.SampleName) { sampleItem.IsWorkSample = true; //设置颜色 string SampleSelColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); sampleItem.SelColor = ColorTranslator.FromHtml(SampleSelColor); } } return true; } } } } catch (Exception) { } return false; } #endregion #region 删除测量 /// /// 删除测量 /// /// 是否选择测量 0:未选择 1:选择 /// 测量名称 /// 是否成功 public static bool DeleteMeasure(int IsSelect, string sampleName) { try { if (OTSSamplespaceWindow.m_MeasureGDIObjects.Count > 0) { foreach (ARectangleGDIObject items in OTSSamplespaceWindow.m_MeasureGDIObjects) { //删除样品测量 if (items.SampleName == sampleName) { //将样品孔恢复未拖动状态 items.IsSelect = false; OTSSamplespaceWindow.m_MeasureGDIObjects.Remove(items); //设置样品与测量区域 //设置颜色 string SampleColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor); SetSampleState(ColorTranslator.FromHtml(SampleColor)); SetMeasureState(ColorTranslator.FromHtml(SampleColor)); OTSSamplespaceWindow.m_IsMeasure = false; foreach (ARectangleGDIObject sampleItem in OTSSamplespaceWindow.m_SampleGDIObjects) { if (sampleItem.Name == items.SampleName) { //设置颜色 string SampleSelColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); sampleItem.IsWorkSample = true; sampleItem.SelColor = ColorTranslator.FromHtml(SampleSelColor); } } return true; } } } } catch (Exception) { } return false; } #endregion #region 更换样品名称 /// /// 更换样品名称 /// /// 新样品名称 public static void ChangeSampleName(string sampleName) { //循环 样品与测量区域的名称修改为新名称 foreach (ARectangleGDIObject itemSample in OTSSamplespaceWindow.m_SampleGDIObjects) { if (itemSample.IsWorkSample) { foreach (ARectangleGDIObject measureItemSample in OTSSamplespaceWindow.m_MeasureGDIObjects) { if (measureItemSample.SampleName == itemSample.SampleName) { measureItemSample.SampleName = sampleName; itemSample.SampleName = sampleName; return; } } } } } #endregion #region 更换样品形状 /// /// 更换样品形状 /// /// 形状 public static bool ChangeSampleShape(int iShape) { foreach (ARectangleGDIObject itemSample in OTSSamplespaceWindow.m_SampleGDIObjects) { if (itemSample.IsWorkSample) { foreach (ARectangleGDIObject itemMeasure in OTSSamplespaceWindow.m_MeasureGDIObjects) { if (itemSample.SampleName == itemMeasure.SampleName) { if (itemMeasure.Shape != iShape) { //改变大小 itemMeasure.Region = new Rectangle(itemMeasure.Region.X, itemMeasure.Region.Y, itemMeasure.Region.Height, itemMeasure.Region.Height); itemMeasure.RegionF = new RectangleF(itemMeasure.RegionF.X, itemMeasure.RegionF.Y, itemMeasure.RegionF.Height, itemMeasure.RegionF.Height); itemMeasure.DrawRegionF = new RectangleF(itemMeasure.DrawRegionF.X, itemMeasure.DrawRegionF.Y, itemMeasure.DrawRegionF.Height, itemMeasure.DrawRegionF.Height); itemMeasure.Shape = iShape; GraphicsPath NewMeasurePath = new GraphicsPath(); if (itemMeasure.Shape == (int)CreateRectangleType.Circle) { NewMeasurePath.AddEllipse(itemMeasure.Region); } else { NewMeasurePath.AddRectangle(itemMeasure.Region); } itemMeasure.GPath = NewMeasurePath; return true; } return false; } } } } return false; } #endregion #region 设置工作样品 /// /// 设置工作样品与测量区域 /// /// 样品名称 public static void SetWorkSampleAndWorkMeasure(string sampleName) { foreach (ARectangleGDIObject itemSample in OTSSamplespaceWindow.m_SampleGDIObjects) { if (itemSample.SampleName == sampleName) { itemSample.IsWorkSample = true; string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); itemSample.SelColor = ColorTranslator.FromHtml(ColorStr); } else { itemSample.IsWorkSample = false; string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleColor); itemSample.SelColor = ColorTranslator.FromHtml(ColorStr); } } foreach (ARectangleGDIObject itemMeasure in OTSSamplespaceWindow.m_MeasureGDIObjects) { if (itemMeasure.SampleName == sampleName) { itemMeasure.IsWorkSample = true; itemMeasure.SelColor = Color.Red; } else { itemMeasure.IsWorkSample = false; itemMeasure.SelColor = Color.Transparent; } } //修改测量区域集合 索引 (添加样品或者切换样品时,将当前工作样品显示在样品孔的最上) OTSSamplespaceWindow.m_MeasureGDIObjects = OTSSamplespaceGraphicsPanelFun.SelectMeasureIndexIsTop(OTSSamplespaceWindow.m_MeasureGDIObjects, sampleName); //修改样品集合 索引 OTSSamplespaceWindow.m_SampleGDIObjects = OTSSamplespaceGraphicsPanelFun.SelectSampleIndexIsTop(OTSSamplespaceWindow.m_SampleGDIObjects, sampleName); } #endregion public static void SetShowCMStrip(int IsSelectType, ContextMenuStrip cmStrip, bool IsTrue) { /*不知道哪里用这个,若无影响日后可删 ////国际化 //OTSSysMgrTools.Language lan = new OTSSysMgrTools.Language(); //Hashtable table; //table = lan.GetNameTable("CStageManage"); //string str1 = "拍摄样品孔BSE照片"; //str1 = table["shootbsepicture1"].ToString(); //string str2 = "拍摄测量区域BSE照片"; //str2 = table["shootbsepicture2"].ToString(); //cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Text = str1; */ //鼠标右键选择的类型 0:样品台 1:样品 2:测量区域 cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Tag = (int)MessageState.ShotBSEPicture; switch (IsSelectType) { case (int)ContextMenuType.SampleHoleMenu: cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = false; cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = false; cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = false; cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = false; cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = false; cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.SEMStripSeparator].Enabled = false; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = false; cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false; break; case (int)ContextMenuType.SampleMenu: cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = true; cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = true; cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = false; cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = false; cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = false; cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.SEMStripSeparator].Enabled = false; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false; break; case (int)ContextMenuType.MeasureMenu: cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = true; cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = true; cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = true; cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = IsTrue; //cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Text = str2; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Tag = MessageState.MeasureBSEPicture; break; case (int)ContextMenuType.SingleMenu: cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = true; cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = true; cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = true; cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false; //cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Text = str2; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Tag = MessageState.MeasureBSEPicture; break; case (int)ContextMenuType.ThreadRunMenu: for (int i = 0; i < cmStrip.Items.Count; i++) { cmStrip.Items[i].Enabled = false; } break; case (int)ContextMenuType.SampleStateMenu: cmStrip.Items[(int)MenuIndex.AddSample].Enabled = false; cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = false; cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = false; cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = false; cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = false; cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = false; break; case (int)ContextMenuType.SampleHoleBSEImage: cmStrip.Items[(int)MenuIndex.AddSample].Enabled = true; cmStrip.Items[(int)MenuIndex.DeleteSample].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.ReadSEMData].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.SetSemData].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.SetSEMCenterLocation].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.DriveSEMToCenterLocation].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.DriveSEMToCurrentLocation].Enabled = true; cmStrip.Items[(int)MenuIndex.ShootBSEPicture].Enabled = IsTrue; cmStrip.Items[(int)MenuIndex.DeleteBSEPicture].Enabled = true; break; } } } }