using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Text.RegularExpressions; using System.Collections; using System.Diagnostics; using OTSDataType; using OTSModelSharp; using System.IO; using static OTSModelSharp.ResourceManage.ResourceData; using static OTSDataType.otsdataconst; using OTSModelSharp.Measure.GetStageInfo; using OTSMeasureApp._3_OTSDisplaySourceGridData; using OTSPeriodicTable; namespace OTSMeasureApp { public partial class ProgMgrInfoForm :Form { #region 定义变量 //初始化函数功能类 public CStage m_cstage; //样品台类 public CStageParam m_cstagefile; //样品台文件类 public COTSDefaultParam m_cotsprogmgrparamfile; //参数类 public CSEMStageData m_csemstagedata; //SEM样品台处理类 public COTSImgScanPrm m_cotsimgscanprm; //图像扫描类 public COTSGeneralParam m_cgenparam; //一般参数类 public COTSImageProcParam m_cotsimgprocprm; //图像处理类 public COTSXRayParam m_cotsxrayprm; public bool m_b_checkstagefile = false; //定位程序管理路径用的变量 public string m_ParameterPath; frmMeasureStopMode StopModeDialog; _7_OTSProgMgrInfo.OtherSelectionForm otherSelectionForm; //国际化 OTSCommon.Language lan; Hashtable table; NLog.Logger log ; #endregion /// /// 样品台加载 /// /// public bool StageLoad() { if (!m_cstagefile.Load( true, !m_b_checkstagefile)) { log.Error("(OTSProgMgrInfoFun.StageLoad) 加载样品台信息失败"); return false; } return true; } #region 构造函数 /// /// 默认构造函数 /// public ProgMgrInfoForm() { log = NLog.LogManager.GetCurrentClassLogger(); m_cotsprogmgrparamfile = new COTSDefaultParam(); m_cstagefile = new CStageParam(); InitializeComponent(); //国际化 lan = new OTSCommon.Language(this); table = lan.GetNameTable(this.Name); } #endregion #region 绑定各combobox控件 /// /// 绑定各combobox控件下拉列表 /// public void BindComboBox() { //样品台 if (!StageLoad()) { this.Close(); return;//加载失败返回 } //绑定样品台列表信息 BindStageCombobox(); //初始化选项,下拉框--------------------------------------------- //绑定标准库 IDC_COMBO_STDSelect.Items.Clear(); string STDLibFolderName = m_cgenparam.GetPartSTDLibFolderName(); string[] files = System.IO.Directory.GetFiles(STDLibFolderName, "*.db"); System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(STDLibFolderName); foreach (System.IO.FileInfo file in folder.GetFiles("*.db")) { ComboBoxItem cbi = new ComboBoxItem(); string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName); cbi.Text = FileNameWithoutExtension; //cbi.Value = (int)enum_one; IDC_COMBO_STDSelect.Items.Add(cbi); } //添加下拉列表中null项 ComboBoxItem cbiNull = new ComboBoxItem(); cbiNull.Text = "NoSTDDB"; //cbi.Value = (int)enum_one; IDC_COMBO_STDSelect.Items.Add(cbiNull); this.IDC_COMBO_STDSelect.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_STDSelect_SelectedIndexChanged); if (IDC_COMBO_STDSelect.Items.Count > 0) IDC_COMBO_STDSelect.SelectedIndex = 0; //---------------------------------------------------------------------- this.IDC_COMBO_STDSelect.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_STDSelect_SelectedIndexChanged); //x轴方向 IDC_COMBO_XDIREC.Items.Clear(); foreach (otsdataconst.OTS_X_AXIS_DIRECTION enum_one in Enum.GetValues(typeof(otsdataconst.OTS_X_AXIS_DIRECTION))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetXAxisDirectionIdString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_XDIREC.Items.Add(cbi); } this.IDC_COMBO_XDIREC.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_XDIREC_SelectedIndexChanged); if (IDC_COMBO_XDIREC.Items.Count > 0) IDC_COMBO_XDIREC.SelectedIndex = 0; this.IDC_COMBO_XDIREC.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_XDIREC_SelectedIndexChanged); //y轴方向 IDC_COMBO_YDIRECT.Items.Clear(); foreach (otsdataconst.OTS_Y_AXIS_DIRECTION enum_one in Enum.GetValues(typeof(otsdataconst.OTS_Y_AXIS_DIRECTION))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetYAxisDirectionIdString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_YDIRECT.Items.Add(cbi); } this.IDC_COMBO_YDIRECT.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_YDIRECT_SelectedIndexChanged); if (IDC_COMBO_YDIRECT.Items.Count > 0) IDC_COMBO_YDIRECT.SelectedIndex = 0; this.IDC_COMBO_YDIRECT.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_YDIRECT_SelectedIndexChanged); //取图方式 IDC_COMBO_FETCHIMGMODE.Items.Clear(); foreach (otsdataconst.OTS_GET_IMAGE_MODE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_GET_IMAGE_MODE))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetGetImageIdString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_FETCHIMGMODE.Items.Add(cbi); } this.IDC_COMBO_FETCHIMGMODE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_FETCHIMGMODE_SelectedIndexChanged); if (IDC_COMBO_FETCHIMGMODE.Items.Count > 0) IDC_COMBO_FETCHIMGMODE.SelectedIndex = 0; this.IDC_COMBO_FETCHIMGMODE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_FETCHIMGMODE_SelectedIndexChanged); //扫描图精度 IDC_COMBO_IMGSCANSPEED.Items.Clear(); foreach (otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetScanSpeedString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_IMGSCANSPEED.Items.Add(cbi); } this.IDC_COMBO_IMGSCANSPEED.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_IMGSCANSPEED_SelectedIndexChanged); if (IDC_COMBO_IMGSCANSPEED.Items.Count > 0) IDC_COMBO_IMGSCANSPEED.SelectedIndex = 0; this.IDC_COMBO_IMGSCANSPEED.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_IMGSCANSPEED_SelectedIndexChanged); //扫描图尺寸 IDC_COMBO_IMGSIZE.Items.Clear(); foreach (otsdataconst.OTS_IMAGE_RESULOTION_OPTIONS enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_RESULOTION_OPTIONS))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetImageSizeIdString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_IMGSIZE.Items.Add(cbi); } this.IDC_COMBO_IMGSIZE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_IMGSIZE_SelectedIndexChanged); if (IDC_COMBO_IMGSIZE.Items.Count > 0) IDC_COMBO_IMGSIZE.SelectedIndex = 0; this.IDC_COMBO_IMGSIZE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_IMGSIZE_SelectedIndexChanged); //去背景方式 IDC_COMBO_BGREMOVETYPE.Items.Clear(); foreach (otsdataconst.OTS_AUTOBGREMOVETYPE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_AUTOBGREMOVETYPE))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetBGREMOVETYPEString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_BGREMOVETYPE.Items.Add(cbi); } this.IDC_COMBO_BGREMOVETYPE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_BGREMOVETYPE_SelectedIndexChanged); if (IDC_COMBO_BGREMOVETYPE.Items.Count > 0) IDC_COMBO_BGREMOVETYPE.SelectedIndex = 0; this.IDC_COMBO_BGREMOVETYPE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_BGREMOVETYPE_SelectedIndexChanged); //自动去背景方式 IDC_COMBO_AUTOBGREMOVETYP.Items.Clear(); foreach (otsdataconst.OTS_IMAGE_MODE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_MODE))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetAUTOBGREMOVETYPEString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_AUTOBGREMOVETYP.Items.Add(cbi); } this.IDC_COMBO_AUTOBGREMOVETYP.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_AUTOBGREMOVETYPE_SelectedIndexChanged); if (IDC_COMBO_AUTOBGREMOVETYP.Items.Count > 0) IDC_COMBO_AUTOBGREMOVETYP.SelectedIndex = 0; this.IDC_COMBO_AUTOBGREMOVETYP.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_AUTOBGREMOVETYPE_SelectedIndexChanged); //腐蚀膨胀系数 //IDC_COMBO_CorrosionExpansionCoefficient.Items.Clear(); //ComboBoxItem ci = new ComboBoxItem(); //ci.Text = "0"; //ci.Value = 0; //IDC_COMBO_CorrosionExpansionCoefficient.Items.Add(ci); //for (int i=1;i<6;i++) //{ // ComboBoxItem cbi = new ComboBoxItem(); // cbi.Text = (i*2+1).ToString(); // cbi.Value = i; // IDC_COMBO_CorrosionExpansionCoefficient.Items.Add(cbi); //} //X-Ray扫描方式 IDC_COMBO_XRAYSCANMODE.Items.Clear(); foreach (otsdataconst.OTS_X_RAY_SCAN_MODE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_X_RAY_SCAN_MODE))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetXRayScanModeIdString(enum_one); cbi.Value = (int)enum_one; //只添加点扫描 IDC_COMBO_XRAYSCANMODE.Items.Add(cbi); } this.IDC_COMBO_XRAYSCANMODE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_XRAYSCANMODE_SelectedIndexChanged); if (IDC_COMBO_XRAYSCANMODE.Items.Count > 0) IDC_COMBO_XRAYSCANMODE.SelectedIndex = 0; this.IDC_COMBO_XRAYSCANMODE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_XRAYSCANMODE_SelectedIndexChanged); //分析X-Ray精度 //IDC_COMBO_ANALYXRAYSPEED.Items.Clear(); //foreach (otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS))) //{ // ComboBoxItem cbi = new ComboBoxItem(); // cbi.Text = GetXRayAnalySpeedIdString(enum_one); // cbi.Value = (int)enum_one; // IDC_COMBO_ANALYXRAYSPEED.Items.Add(cbi); //} //this.IDC_COMBO_ANALYXRAYSPEED.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_ANALYXRAYSPEED_SelectedIndexChanged); //if (IDC_COMBO_ANALYXRAYSPEED.Items.Count > 0) // IDC_COMBO_ANALYXRAYSPEED.SelectedIndex = 0; //this.IDC_COMBO_ANALYXRAYSPEED.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_ANALYXRAYSPEED_SelectedIndexChanged); //精炼工艺下拉框选项 IDC_COMBO_TECHNOLOGY.Items.Clear(); foreach (STEEL_TECHNOLOGY enum_one in Enum.GetValues(typeof(STEEL_TECHNOLOGY))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetSteelTechIdString((otsdataconst.STEEL_TECHNOLOGY)enum_one); cbi.Value = (int)enum_one; IDC_COMBO_TECHNOLOGY.Items.Add(cbi); } this.IDC_COMBO_TECHNOLOGY.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_TECHNOLOGY_SelectedIndexChanged); if (IDC_COMBO_TECHNOLOGY.Items.Count > 0) IDC_COMBO_TECHNOLOGY.SelectedIndex = 0; this.IDC_COMBO_TECHNOLOGY.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_TECHNOLOGY_SelectedIndexChanged); //测量区域形状 cBMeasShape.Items.Clear(); foreach (otsdataconst.MEASURE_SHAPE enum_one in Enum.GetValues(typeof(otsdataconst.MEASURE_SHAPE))) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = GetAreaShapeString(enum_one); cbi.Value = (int)enum_one; cBMeasShape.Items.Add(cbi); } this.cBMeasShape.SelectedIndexChanged -= new System.EventHandler(this.cBMeasShape_SelectedIndexChanged); if (cBMeasShape.Items.Count > 0) cBMeasShape.SelectedIndex = 0; this.cBMeasShape.SelectedIndexChanged += new System.EventHandler(this.cBMeasShape_SelectedIndexChanged); //模式选择 IDC_COMBO_Model.Items.Clear(); foreach (otsdataconst.RunMode enum_one in Enum.GetValues(typeof(otsdataconst.RunMode))) { OTSPeriodicTable.ComboBoxItem cbi = new OTSPeriodicTable.ComboBoxItem(); cbi.Text = GetRunModeString(enum_one); cbi.Value = (int)enum_one; IDC_COMBO_Model.Items.Add(cbi); } this.IDC_COMBO_Model.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_Model_SelectedIndexChanged); if (IDC_COMBO_Model.Items.Count > 0) IDC_COMBO_Model.SelectedIndex = 0; this.IDC_COMBO_Model.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_Model_SelectedIndexChanged); } public CStage GetWorkingStage() { CStage ls_cstageclr = m_cstagefile.GetWorkingStage(); if (null == ls_cstageclr) { log.Error("(OTSProgMgrInfoFun.GetWorkingStage) 获取正在工作的样品台类失败"); return ls_cstageclr; } return ls_cstageclr; } /// /// 获取正在工作的样品台ID /// /// public int GetWorkingStageId() { int stageid = m_cstagefile.GetWorkingStageId(); return stageid; } /// /// 获取样品台信息列表 /// /// public List GetStageList() { List l_cstageclr = m_cstagefile.GetStagesList(); if (null == l_cstageclr) { log.Error("(OTSProgMgrInfoFun.GetStageList) 获取样品台信息列表失败"); return l_cstageclr; } return l_cstageclr; } /// /// 绑定样品台列表信息 /// private void BindStageCombobox() { //先插入正在工作的样品台 int ls_workingstageid = 0; IDC_COMBO_STAGE.Items.Clear(); CStage ls_cstageclr = GetWorkingStage(); ComboBoxItem ls_cbi = new ComboBoxItem(); ls_cbi.Text = ls_cstageclr.GetName(); ls_workingstageid = GetWorkingStageId(); ls_cbi.Value = ls_workingstageid; IDC_COMBO_STAGE.Items.Add(ls_cbi); //添加其它的样品台信息 List l_cstageclr = GetStageList(); for (int i = 0; i < l_cstageclr.Count(); i++) { if (ls_workingstageid != i)//将已经插入过的正在工作样品台信息跳过去 { ComboBoxItem cbi = new ComboBoxItem(); cbi.Text = l_cstageclr[i].GetName().ToString(); cbi.Value = i.ToString(); IDC_COMBO_STAGE.Items.Add(cbi); } } //防止进入窗体后,马上进入下拉项选择事件,先把事件去掉,一会再注册上 this.IDC_COMBO_STAGE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_STAGE_SelectedIndexChanged); //默认选择上 if (IDC_COMBO_STAGE.Items.Count > 0) { IDC_COMBO_STAGE.SelectedIndex = 0; } this.IDC_COMBO_STAGE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_STAGE_SelectedIndexChanged); } #endregion #region 参数相关方法封装 /// /// 读取SEM样品台参数信息 /// public void LoadSEMStageData() { //100倍时屏幕尺寸/mm IDC_EDIT_SCREENWIDTH.Text = m_csemstagedata.GetScanFieldSize100().ToString(); //x轴方向 foreach (ComboBoxItem cbi in IDC_COMBO_XDIREC.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_csemstagedata.GetXAxisDir()) { IDC_COMBO_XDIREC.SelectedItem = cbi; } } //x轴行程/mm 起,取值时,乘1000 IDC_EDIT_XSTART.Text = (m_csemstagedata.GetXAxis().GetStart() / 1000).ToString(); //x轴行程/mm 始 IDC_EDIT_XEND.Text = (m_csemstagedata.GetXAxis().GetEnd() / 1000).ToString(); //y轴方向 foreach (ComboBoxItem cbi in IDC_COMBO_YDIRECT.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_csemstagedata.GetYAxisDir()) { IDC_COMBO_YDIRECT.SelectedItem = cbi; } } //y轴行程/mm 起 IDC_EDIT_YSTART.Text = (m_csemstagedata.GetYAxis().GetStart() / 1000).ToString(); //y轴行程/mm 始 IDC_EDIT_YEND.Text = (m_csemstagedata.GetYAxis().GetEnd() / 1000).ToString(); //最小放大倍数 IDC_EDIT_MINMAG.Text = m_csemstagedata.GetMinMag().ToString(); } /// /// 加载图像扫描参数 /// public void LoadImageScanPrm() { //测量终止方式 tB_StopMode.Text = m_cotsimgscanprm.GetStopMode().ToString(); if (StopModeDialog == null) { StopModeDialog = new frmMeasureStopMode(); StopModeDialog.FieldMode = m_cotsimgscanprm.GetStopParamFields(); StopModeDialog.TimeMode = m_cotsimgscanprm.GetStopParamMeasTime(); StopModeDialog.ParticleMode = m_cotsimgscanprm.GetStopParamParticles(); StopModeDialog.AreaMode = m_cotsimgscanprm.GetStopParamArea(); StopModeDialog.StopMode = tB_StopMode.Text; } //取图方式 foreach (ComboBoxItem cbi in IDC_COMBO_FETCHIMGMODE.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgscanprm.GetFieldStartMode()) { IDC_COMBO_FETCHIMGMODE.SelectedItem = cbi; } } //扫描图精度 foreach (ComboBoxItem cbi in IDC_COMBO_IMGSCANSPEED.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgscanprm.GetScanImageSpeed()) { IDC_COMBO_IMGSCANSPEED.SelectedItem = cbi; } } //扫描图尺寸 foreach (ComboBoxItem cbi in IDC_COMBO_IMGSIZE.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgscanprm.GetImageResulotion()) { IDC_COMBO_IMGSIZE.SelectedItem = cbi; } } } /// /// 加载一般常规参数 /// public void LoadCGenParam() { //样品名 IDC_EDIT_SAMPLENAME.Text = m_cgenparam.GetSampleName().ToString(); //执行开关 IDC_MEAS_SWITCH.Checked = m_cgenparam.GetMeasurementSwitch(); //是否使用系统库开关 IDC_SYS_LIB.Checked = m_cgenparam.GetSysSTD(); //精炼工艺选项 foreach (ComboBoxItem cbi in IDC_COMBO_TECHNOLOGY.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == m_cgenparam.GetSteelTechnology()) { IDC_COMBO_TECHNOLOGY.SelectedItem = cbi; } } //测量区域形状 foreach (ComboBoxItem cbi in cBMeasShape.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_cgenparam.GetShape()) { cBMeasShape.SelectedItem = cbi; } } //测量区域面积 tBMeasArea.Text = m_cgenparam.GetArea().ToString(); //标准库选择 foreach (ComboBoxItem cbi in IDC_COMBO_STDSelect.Items) { if (cbi.Text.ToString() != "") if (cbi.Text.ToString() == m_cgenparam.GetSTDSelect()) { IDC_COMBO_STDSelect.SelectedItem = cbi; } } } /// /// 加载默认参数 /// public void LoadDefaultParam() { //模式 foreach (OTSPeriodicTable.ComboBoxItem cbi in IDC_COMBO_Model.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_cotsprogmgrparamfile.GetRunMode()) { IDC_COMBO_Model.SelectedItem = cbi; } } } /// /// 加载图像处理参数 /// public void LoadImageProc() { //颗粒面积范围 最小 IDC_EDIT_PARTAREAMIN.Text = m_cotsimgprocprm.GetIncAreaRange().GetStart().ToString(); //颗粒面积范围 最大 IDC_EDIT_PARTAREAMAX.Text = m_cotsimgprocprm.GetIncAreaRange().GetEnd().ToString(); //背景灰度范围 最小 IDC_EDIT_BACKMIN.Text = m_cotsimgprocprm.GetBGGray().GetStart().ToString(); //背景灰度范围 最大 IDC_EDIT_BACKMAX.Text = m_cotsimgprocprm.GetBGGray().GetEnd().ToString(); //颗粒灰度范围 最小 IDC_EDIT_PARTMIN.Text = m_cotsimgprocprm.GetParticleGray().GetStart().ToString(); //颗粒灰度范围 最大 IDC_EDIT_PARTMAX.Text = m_cotsimgprocprm.GetParticleGray().GetEnd().ToString(); //腐蚀膨胀系数 //IDC_COMBO_CorrosionExpansionCoefficient.Text = m_cotsimgprocprm.GetErrodDilateParam().ToString(); //重叠尺寸 IDC_EDIT_Overlap.Text = m_cotsimgprocprm.GetOverlapParam().ToString(); //去背景方式 foreach (ComboBoxItem cbi in IDC_COMBO_BGREMOVETYPE.Items) { if (cbi.Value.ToString() != "") { if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgprocprm.GetBGRemoveType()) { IDC_COMBO_BGREMOVETYPE.SelectedItem = cbi; break; } } } foreach (ComboBoxItem cbi in IDC_COMBO_AUTOBGREMOVETYP.Items) { if (cbi.Value.ToString() != "") { if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgprocprm.GetAutoBGRemoveType()) { IDC_COMBO_AUTOBGREMOVETYP.SelectedItem = cbi; break; } } } //重叠尺寸 IDC_EDIT_Overlap.Text = m_cotsimgprocprm.GetOverlapParam().ToString(); if (m_cotsimgprocprm.GetParticleSelectCondition().ToString() == "") { IDC_EDIT_OTHERSELECTION.Text = "NoFilter"; } else { IDC_EDIT_OTHERSELECTION.Text = m_cotsimgprocprm.GetParticleSelectCondition().ToString(); } } /// /// 加载X-Ray参数 /// public void LoadXRayParam() { //搜索X-ray精度对应的时间 //IDC_TEXTBOX_SEARCHXRAYSPEED_TIME.Text = m_cotsxrayprm.GetMidSearchAQTime().ToString(); foreach (ComboBoxItem cbi in IDC_COMBO_XRAYSCANMODE.Items) { if (cbi.Value.ToString() != "") if (Convert.ToInt32(cbi.Value) == (int)m_cotsxrayprm.GetScanMode()) { IDC_COMBO_XRAYSCANMODE.SelectedItem = cbi; } } //是否使用电镜 IDC_USINGXRAY_LIB.Checked = m_cotsxrayprm.GetUsingXray(); //分析X-ray精度对应的时间 IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Text = m_cotsxrayprm.GetMidAnalyAQTime().ToString(); //分析X-ray计数期望值 IDC_EDIT_ANALYXRAYAIMVALUE.Text = m_cotsxrayprm.GetAnalyExpCount().ToString(); IDC_EDIT_QuantifyMinSize.Text = m_cotsxrayprm.GetFeatureModeMinSize().ToString(); IDC_EDIT_SmallPartAQTime.Text = m_cotsxrayprm.GetSmallPartXrayTime().ToString(); IDC_EDIT_XrayLimit.Text = m_cotsxrayprm.GetXrayLimit().ToString(); if (m_cotsxrayprm.IfAutoId) { radioButton1.Checked =true; } else { radioButton2.Checked = true; } tb_xsys.Text = m_cotsxrayprm.AnalysisElements; } /// /// 保存SEM样品台参数 /// public void SaveSEMStageData() { //100倍时屏幕尺寸/mm m_csemstagedata.SetScanFieldSize100(Convert.ToInt32(IDC_EDIT_SCREENWIDTH.Text)); //x轴方向 ComboBoxItem cbi_x = (ComboBoxItem)IDC_COMBO_XDIREC.SelectedItem; m_csemstagedata.SetXAxisDir((otsdataconst.OTS_X_AXIS_DIRECTION)Convert.ToInt32(cbi_x.Value)); //x轴行程/mm 起,始 CIntRange crc_x = new CIntRange(Convert.ToInt32(IDC_EDIT_XSTART.Text) * 1000, Convert.ToInt32(IDC_EDIT_XEND.Text) * 1000); m_csemstagedata.SetXAxis(crc_x); //y轴方向 ComboBoxItem cbi_y = (ComboBoxItem)IDC_COMBO_YDIRECT.SelectedItem; m_csemstagedata.SetYAxisDir((otsdataconst.OTS_Y_AXIS_DIRECTION)Convert.ToInt32(cbi_y.Value)); //y轴行程/mm 起,始 CIntRange crc_y = new CIntRange(Convert.ToInt32(IDC_EDIT_YSTART.Text) * 1000, Convert.ToInt32(IDC_EDIT_YEND.Text) * 1000); m_csemstagedata.SetYAxis(crc_y); //最小放大倍数 m_csemstagedata.SetMinMag(Convert.ToDouble(IDC_EDIT_MINMAG.Text)); } /// /// 保存图像扫描参数 /// public void SaveImageScanPrm() { // 保存图像扫描参数"); //测量终止方式 m_cotsimgscanprm.SetStopMode(tB_StopMode.Text); //终止时间 m_cotsimgscanprm.SetStopParamMeasTime(StopModeDialog.TimeMode); ////终止帧图数 m_cotsimgscanprm.SetStopParamFields(StopModeDialog.FieldMode); ////终止夹杂物数 m_cotsimgscanprm.SetStopParamParticles(StopModeDialog.ParticleMode); ////终止面积 m_cotsimgscanprm.SetStopParamArea(StopModeDialog.AreaMode); //取图方式 ComboBoxItem enum_fetchimgmode = (ComboBoxItem)IDC_COMBO_FETCHIMGMODE.SelectedItem; m_cotsimgscanprm.SetStartImageMode((otsdataconst.OTS_GET_IMAGE_MODE)Convert.ToInt32(enum_fetchimgmode.Value)); //扫描图精度 ComboBoxItem enum_imgscanspeed = (ComboBoxItem)IDC_COMBO_IMGSCANSPEED.SelectedItem; m_cotsimgscanprm.SetScanImageSpeed((otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS)Convert.ToInt32(enum_imgscanspeed.Value)); //扫描图尺寸 ComboBoxItem enum_imgsize = (ComboBoxItem)IDC_COMBO_IMGSIZE.SelectedItem; m_cotsimgscanprm.SetImageResulotion((otsdataconst.OTS_IMAGE_RESULOTION_OPTIONS)Convert.ToInt32(enum_imgsize.Value)); } /// /// 保存一般常规参数 /// public void SaveCGenParam() { //样品名 m_cgenparam.SetSampleName(IDC_EDIT_SAMPLENAME.Text); //执行开关 m_cgenparam.SetMeasurementSwitch(IDC_MEAS_SWITCH.Checked); //是否使用系统库 m_cgenparam.SetSysSTD(IDC_SYS_LIB.Checked); //获取精炼工艺索引 ComboBoxItem cbiTECH = new ComboBoxItem(); cbiTECH = (ComboBoxItem)IDC_COMBO_TECHNOLOGY.SelectedItem; //设置参数文件类中精炼工艺索引值 m_cgenparam.SetSteelTechnology((int)cbiTECH.Value); //测量区域形状 ComboBoxItem enum_Shape = (ComboBoxItem)cBMeasShape.SelectedItem; m_cgenparam.SetShape((otsdataconst.DOMAIN_SHAPE)Convert.ToInt32(enum_Shape.Value)); //测量区域大小 m_cgenparam.SetArea(Convert.ToDouble(tBMeasArea.Text)); //标准库选择 ComboBoxItem enum_STDLIBSELECT = (ComboBoxItem)IDC_COMBO_STDSelect.SelectedItem; m_cgenparam.SetSTDSelect(enum_STDLIBSELECT.Text.ToString()); } /// /// 保存图像处理参数 /// public void SaveImageProc() { //颗粒面积范围 最小 最大 CDoubleRange crc_partareamin = new CDoubleRange(Math.Round(Convert.ToDouble(IDC_EDIT_PARTAREAMIN.Text), 2), Math.Round(Convert.ToDouble(IDC_EDIT_PARTAREAMAX.Text), 2)); m_cotsimgprocprm.SetIncAreaRange(crc_partareamin); //背景灰度范围 最小 最大 CIntRange crc_backmin = new CIntRange(Convert.ToInt32(IDC_EDIT_BACKMIN.Text), Convert.ToInt32(IDC_EDIT_BACKMAX.Text)); m_cotsimgprocprm.SetBGGray(crc_backmin); //颗粒灰度范围 最小 最大 CIntRange crc_partmin = new CIntRange(Convert.ToInt32(IDC_EDIT_PARTMIN.Text), Convert.ToInt32(IDC_EDIT_PARTMAX.Text)); m_cotsimgprocprm.SetParticleGray(crc_partmin); //去背景方式 ComboBoxItem enum_BGREMOVETYPE = (ComboBoxItem)IDC_COMBO_BGREMOVETYPE.SelectedItem; m_cotsimgprocprm.SetBGRemoveType((otsdataconst.OTS_BGREMOVE_TYPE)enum_BGREMOVETYPE.Value); //去背景方式 ComboBoxItem enum_AUTOBGREMOVETYP = (ComboBoxItem)IDC_COMBO_AUTOBGREMOVETYP.SelectedItem; m_cotsimgprocprm.SetAutoBGRemoveType((otsdataconst.OTS_AUTOBGREMOVE_TYPE)enum_AUTOBGREMOVETYP.Value); //重叠像素 m_cotsimgprocprm.SetOverlapParam(Convert.ToInt32(IDC_EDIT_Overlap.Text)); if (IDC_EDIT_OTHERSELECTION.Text != "NoFilter") { m_cotsimgprocprm.SetParticleSelectCondition(IDC_EDIT_OTHERSELECTION.Text); } else { m_cotsimgprocprm.SetParticleSelectCondition(""); } } /// /// 保存X-Ray参数 /// public void SaveXRayParam() { //X-ray扫描方式 ComboBoxItem enum_xrayscanmode = (ComboBoxItem)IDC_COMBO_XRAYSCANMODE.SelectedItem; m_cotsxrayprm.SetScanMode((otsdataconst.OTS_X_RAY_SCAN_MODE)Convert.ToInt32(enum_xrayscanmode.Value)); //是否使用X-ray m_cotsxrayprm.SetUsingXray(IDC_USINGXRAY_LIB.Checked); //分析X-ray精度对应的时间 m_cotsxrayprm.SetMidAnalyAQTime(Convert.ToInt32(IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Text.Trim())); //分析X-ray计数期望值 m_cotsxrayprm.SetAnalyExpCount(Convert.ToInt32(IDC_EDIT_ANALYXRAYAIMVALUE.Text)); m_cotsxrayprm.SetFeatureModeMinSize(Convert.ToDouble(IDC_EDIT_QuantifyMinSize.Text)); m_cotsxrayprm.SetSmallPartXrayTime(Convert.ToInt32(IDC_EDIT_SmallPartAQTime.Text)); m_cotsxrayprm.SetXrayLimit(Convert.ToInt32(IDC_EDIT_XrayLimit.Text)); m_cotsxrayprm.IfAutoId=radioButton1.Checked ; m_cotsxrayprm.AnalysisElements=tb_xsys.Text ; } /// /// 将参数保存到文件 /// /// /// /// /// /// /// /// public bool SaveInfoToProgMgrFile() { //SaveInfoToProgMgrFile() if (false == m_cotsprogmgrparamfile.SaveInfoToProgMgrFile()) { log.Error("(OTSProgMgrInfoFun.SaveInfoToProgMgrFile) Failed to save parameters to file"); return false; } return true; } /// /// 加载参数各个类 /// public bool LoadParamFun() { bool result = m_cotsprogmgrparamfile.LoadInfoFromProgMgrFile(); if (!result) { log.Error("(OTSProgMgrInfoFun.LoadParamFun) LoadInfoFromProgMgrFile Failed"); return false; } m_csemstagedata = m_cotsprogmgrparamfile.GetStageDataParam(); if (null == m_csemstagedata) { log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetStageData Failed"); return false; } m_cotsimgscanprm = m_cotsprogmgrparamfile.GetImageScanParam(); if (null == m_cotsimgscanprm) { log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetImageScanParam Failed"); return false; } m_cgenparam = m_cotsprogmgrparamfile.GetGenParam(); if (null == m_cgenparam) { log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetGenParam Failed"); return false; } m_cotsimgprocprm = m_cotsprogmgrparamfile.GetImageProcParam(); if (null == m_cotsimgprocprm) { log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetImageProcParam Failed"); return false; } m_cotsxrayprm = m_cotsprogmgrparamfile.GetXRayParam(); if (null == m_cotsxrayprm) { log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetXRayParam Failed"); return false; } return true; } #endregion #region 窗体加载 private void ProgMgrInfoForm_Load(object sender, EventArgs e) { //加载各参数类 LoadParamFun(); //初始化combobox下拉框列表 BindComboBox(); //加载相关参数信息 LoadDefaultParam(); LoadSEMStageData(); LoadImageScanPrm(); LoadCGenParam(); LoadImageProc(); LoadXRayParam(); if (m_b_checkstagefile == false) btnok.Enabled = true; else btnok.Enabled = false; if(m_cotsprogmgrparamfile.GetSysTypeName() == "IncA") { label42.Visible = true; IDC_COMBO_TECHNOLOGY.Visible = true; } else { label42.Visible = false; IDC_COMBO_TECHNOLOGY.Visible = false; } } #endregion #region 各按钮控件点击事件 private void IDC_BUTTON_KLFX_Click(object sender, EventArgs e) { try { if (IDC_COMBO_STDSelect.Text != "NoSTDDB") { Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", Application.StartupPath + "\\Config\\SysData\\" + IDC_COMBO_STDSelect.Text+".db"); p.WaitForExit(); } else { string message = table["message55"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { log.Error("OTSPartA_STDEditor:" + ex.ToString()); } } /// /// 弹出样品台管理窗体 /// /// /// /// public void ShowStageDialogExport() { DlgStageMgr dlgStageMgr = new DlgStageMgr(m_cstagefile); dlgStageMgr.ShowDialog(); return; } /// /// 保存样品台信息 /// /// public bool CStageFileClrSave() { if (m_cstagefile == null) { //报错 log.Error("(OTSProgMgrInfoFun.CStageFileClrSave) Error saving sample station information!"); } else { bool b_ret = m_cstagefile.Save(); if (false == b_ret) { log.Error("(OTSProgMgrInfoFun.CStageFileClrSave) Error saving sample table information!"); } } return false; } private void IDC_BUTTON_STAGE_Click(object sender, EventArgs e) { //弹出管理样品台管理窗体 ShowStageDialogExport(); //弹出后再保存样品台信息 CStageFileClrSave(); //刷新绑定样品台列表 BindStageCombobox(); //检测是否已经有修改 ThisSetIsModify(); } /// /// 判断各控件值是否正确 /// /// private bool CheckSetupValues(int bz) { if ("" == IDC_COMBO_STAGE.Text) { string message = table["message1"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_STAGE.Focus(); IDC_COMBO_STAGE.SelectAll(); return false; } if ("" == IDC_EDIT_SCREENWIDTH.Text) { string message = table["message2"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_SCREENWIDTH.Focus(); IDC_EDIT_SCREENWIDTH.SelectAll(); return false; } if ("" == IDC_COMBO_XDIREC.Text) { string message = table["message3"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_XDIREC.Focus(); IDC_COMBO_XDIREC.SelectAll(); return false; } if ("" == IDC_EDIT_XSTART.Text) { string message = table["message4"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_XSTART.Focus(); IDC_EDIT_XSTART.SelectAll(); return false; } if ("" == IDC_EDIT_XEND.Text) { string message = table["message4"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_XEND.Focus(); IDC_EDIT_XEND.SelectAll(); return false; } if ("" == IDC_COMBO_YDIRECT.Text) { string message = table["message5"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_YDIRECT.Focus(); IDC_COMBO_YDIRECT.SelectAll(); return false; } if ("" == IDC_EDIT_YSTART.Text) { string message = table["message6"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_YSTART.Focus(); IDC_EDIT_YSTART.SelectAll(); return false; } if ("" == IDC_EDIT_YEND.Text) { string message = table["message6"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_YEND.Focus(); IDC_EDIT_YEND.SelectAll(); return false; } if ("" == tB_StopMode.Text) { string message = table["message7"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); //IDC_EDIT_STOP_TIME.Focus(); //IDC_EDIT_STOP_TIME.SelectAll(); return false; } if ("" == IDC_COMBO_FETCHIMGMODE.Text) { string message = table["message10"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_FETCHIMGMODE.Focus(); IDC_COMBO_FETCHIMGMODE.SelectAll(); return false; } if ("" == IDC_COMBO_IMGSCANSPEED.Text) { string message = table["message11"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_IMGSCANSPEED.Focus(); IDC_COMBO_IMGSCANSPEED.SelectAll(); return false; } if ("" == IDC_COMBO_IMGSIZE.Text) { string message = table["message12"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_IMGSIZE.Focus(); IDC_COMBO_IMGSIZE.SelectAll(); return false; } if ("" == IDC_EDIT_MINMAG.Text) { string message = table["message13"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_MINMAG.Focus(); IDC_EDIT_MINMAG.SelectAll(); return false; } if ("" == IDC_EDIT_PARTAREAMIN.Text) { string message = table["message14"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_PARTAREAMIN.Focus(); IDC_EDIT_PARTAREAMIN.SelectAll(); return false; } if ("" == IDC_EDIT_PARTAREAMAX.Text) { string message = table["message15"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_PARTAREAMAX.Focus(); IDC_EDIT_PARTAREAMAX.SelectAll(); return false; } if ("" == IDC_EDIT_BACKMIN.Text) { string message = table["message16"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_BACKMIN.Focus(); IDC_EDIT_BACKMIN.SelectAll(); return false; } if ("" == IDC_EDIT_BACKMAX.Text) { string message = table["message17"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_BACKMAX.Focus(); IDC_EDIT_BACKMAX.SelectAll(); return false; } if ("" == IDC_EDIT_PARTMIN.Text) { string message = table["message18"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_PARTMIN.Focus(); IDC_EDIT_PARTMIN.SelectAll(); return false; } if ("" == IDC_EDIT_PARTMAX.Text) { string message = table["message19"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_PARTMAX.Focus(); IDC_EDIT_PARTMAX.SelectAll(); return false; } if ("" == IDC_COMBO_XRAYSCANMODE.Text) { string message = table["message20"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_COMBO_XRAYSCANMODE.Focus(); IDC_COMBO_XRAYSCANMODE.SelectAll(); return false; } //if ("" == IDC_COMBO_ANALYXRAYSPEED.Text) //{ // string message = table["message21"].ToString(); // MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); // IDC_COMBO_ANALYXRAYSPEED.Focus(); // IDC_COMBO_ANALYXRAYSPEED.SelectAll(); // return false; //} if ("" == IDC_EDIT_ANALYXRAYAIMVALUE.Text) { string message = table["message22"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); IDC_EDIT_ANALYXRAYAIMVALUE.Focus(); IDC_EDIT_ANALYXRAYAIMVALUE.SelectAll(); return false; } if ("" == tBMeasArea.Text) { string message = table["message62"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); tBMeasArea.Focus(); tBMeasArea.SelectAll(); return false; } //if ("" == IDC_COMBO_CorrosionExpansionCoefficient.Text) //{ // string message = table["message62"].ToString(); // MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); // IDC_COMBO_CorrosionExpansionCoefficient.Focus(); // IDC_COMBO_CorrosionExpansionCoefficient.SelectAll(); // return false; //} //string pat = @"^(-|\+)?\d{1,8}$";//只能输入1到3位的正负整数 string pat = @"^-?[0-9]\d*$";//只能限定正负整数,包含0 string scope = @"^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$"; string PositiveDecimals = @"^(([1-9]\d*)(\.\d+)?)$|^0\.\d*[1-9]$"; //正浮点数 string positiveInteger = @"^?[0-9]\d*$";//只能限定正整数,包含0 string positiveOddNumber = @"[^1,3,5,7,9]";//只能限定正奇数 Regex rg = new Regex(pat); Regex rgScope = new Regex(scope); Regex rgPositiveDecimals = new Regex(PositiveDecimals); Regex rgpositiveInteger = new Regex(positiveInteger); Regex rgpositiveOddNumber = new Regex(positiveOddNumber); //是否是正确的数值格式类型判断 //if(IDC_COMBO_CorrosionExpansionCoefficient.Text!="0") //{ // if (rgpositiveOddNumber.Match(IDC_COMBO_CorrosionExpansionCoefficient.Text.Trim()).Success) // { // IDC_COMBO_CorrosionExpansionCoefficient.Focus(); // IDC_COMBO_CorrosionExpansionCoefficient.SelectAll(); // string message = table["message66"].ToString(); // MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); // return false; // } //} //100倍时屏幕尺寸 if (false == rg.Match(IDC_EDIT_SCREENWIDTH.Text.Trim()).Success) { IDC_EDIT_SCREENWIDTH.Focus(); IDC_EDIT_SCREENWIDTH.SelectAll(); string message = table["message23"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //x轴行程/mm 起 if (false == rg.Match(IDC_EDIT_XSTART.Text.Trim()).Success) { IDC_EDIT_XSTART.Focus(); IDC_EDIT_XSTART.SelectAll(); string message = table["message24"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //x轴行程/mm 止 if (false == rg.Match(IDC_EDIT_XEND.Text.Trim()).Success) { IDC_EDIT_XEND.Focus(); IDC_EDIT_XEND.SelectAll(); string message = table["message25"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //y轴行程/mm 起 if (false == rg.Match(IDC_EDIT_YSTART.Text.Trim()).Success) { IDC_EDIT_YSTART.Focus(); IDC_EDIT_YSTART.SelectAll(); string message = table["message26"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //y轴行程/mm 止 if (false == rg.Match(IDC_EDIT_YEND.Text.Trim()).Success) { IDC_EDIT_YEND.Focus(); IDC_EDIT_YEND.SelectAll(); string message = table["message27"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //颗粒面积范围 最小 if (false == rgPositiveDecimals.Match(IDC_EDIT_PARTAREAMIN.Text.Trim()).Success) { IDC_EDIT_PARTAREAMIN.Focus(); IDC_EDIT_PARTAREAMIN.SelectAll(); string message = table["message31"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //颗粒面积范围 最大 if (false == rgPositiveDecimals.Match(IDC_EDIT_PARTAREAMAX.Text.Trim()).Success) { IDC_EDIT_PARTAREAMAX.Focus(); IDC_EDIT_PARTAREAMAX.SelectAll(); string message = table["message32"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //背景灰度范围 最小 if (false == rg.Match(IDC_EDIT_BACKMIN.Text.Trim()).Success) { IDC_EDIT_BACKMIN.Focus(); IDC_EDIT_BACKMIN.SelectAll(); string message = table["message33"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { if (false == rgScope.Match(IDC_EDIT_BACKMIN.Text.Trim()).Success) { IDC_EDIT_BACKMIN.Focus(); IDC_EDIT_BACKMIN.SelectAll(); string message = table["message34"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } //背景灰度范围 最大 if (false == rg.Match(IDC_EDIT_BACKMAX.Text.Trim()).Success) { IDC_EDIT_BACKMAX.Focus(); IDC_EDIT_BACKMAX.SelectAll(); string message = table["message35"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { if (false == rgScope.Match(IDC_EDIT_BACKMAX.Text.Trim()).Success) { IDC_EDIT_BACKMAX.Focus(); IDC_EDIT_BACKMAX.SelectAll(); string message = table["message36"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } //颗粒灰度范围 最小 if (false == rg.Match(IDC_EDIT_PARTMIN.Text.Trim()).Success) { IDC_EDIT_PARTMIN.Focus(); IDC_EDIT_PARTMIN.SelectAll(); string message = table["message37"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { if (false == rgScope.Match(IDC_EDIT_PARTMIN.Text.Trim()).Success) { IDC_EDIT_PARTMIN.Focus(); IDC_EDIT_PARTMIN.SelectAll(); string message = table["message38"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } //颗粒灰度范围 最大 if (false == rg.Match(IDC_EDIT_PARTMAX.Text.Trim()).Success) { IDC_EDIT_PARTMAX.Focus(); IDC_EDIT_PARTMAX.SelectAll(); string message = table["message39"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { if (false == rgScope.Match(IDC_EDIT_PARTMAX.Text.Trim()).Success) { IDC_EDIT_PARTMAX.Focus(); IDC_EDIT_PARTMAX.SelectAll(); string message = table["message40"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } } //分析X-ray计数期望值 最大 if (false == rg.Match(IDC_EDIT_ANALYXRAYAIMVALUE.Text.Trim()).Success) { IDC_EDIT_ANALYXRAYAIMVALUE.Focus(); IDC_EDIT_ANALYXRAYAIMVALUE.SelectAll(); string message = table["message41"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //分析X-ray精度对应的时间 if (false == rg.Match(IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Text.Trim()).Success) { IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Focus(); IDC_TEXTBOX_ANALYXRAYSPEED_TIME.SelectAll(); string message = table["message42"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //if (false == rgPositiveDecimals.Match(IDC_EDIT_QuantifyMinSize.Text.Trim()).Success) //{ // IDC_EDIT_QuantifyMinSize.Focus(); // IDC_EDIT_QuantifyMinSize.SelectAll(); // string message = table["message63"].ToString(); // MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); // return false; //} pat = @"^[0-9]+(\.[0-9]{1,3})?$"; //只能输入,1到3位小数的正数 rg = new Regex(pat); //最小放大倍数 if (false == rg.Match(IDC_EDIT_MINMAG.Text.Trim()).Success) { IDC_EDIT_MINMAG.Focus(); IDC_EDIT_MINMAG.SelectAll(); string message = table["message43"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } ////最小放大倍数不得小于45倍 //if (Convert.ToInt32(IDC_EDIT_MINMAG.Text.Trim()) < 45) //{ // IDC_EDIT_MINMAG.Focus(); // IDC_EDIT_MINMAG.SelectAll(); // string message = "The minimum magnification cannot be less than 45 times"; // MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); // return false; //} //再限制,x轴,y轴,的起止的,输入长度,因为现在已经有在mm和um之间的转换,所以这里要限制一下 //x轴行程/mm 起 if (IDC_EDIT_XSTART.Text.Length > 4) { IDC_EDIT_XSTART.Focus(); IDC_EDIT_XSTART.SelectAll(); string message = table["message44"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //x轴行程/mm 止 if (IDC_EDIT_XEND.Text.Length > 4) { IDC_EDIT_XEND.Focus(); IDC_EDIT_XEND.SelectAll(); string message = table["message45"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //y轴行程/mm 起 if (IDC_EDIT_YSTART.Text.Length > 4) { IDC_EDIT_YSTART.Focus(); IDC_EDIT_YSTART.SelectAll(); string message = table["message46"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //y轴行程/mm 止 if (IDC_EDIT_YEND.Text.Length > 4) { IDC_EDIT_YEND.Focus(); IDC_EDIT_YEND.SelectAll(); string message = table["message47"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } if (Convert.ToInt32(IDC_EDIT_XSTART.Text.Trim()) > Convert.ToInt32(IDC_EDIT_XEND.Text.Trim())) { IDC_EDIT_XEND.Focus(); IDC_EDIT_XEND.SelectAll(); string message = table["message50"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } if (Convert.ToInt32(IDC_EDIT_YSTART.Text.Trim()) > Convert.ToInt32(IDC_EDIT_YEND.Text.Trim())) { IDC_EDIT_YEND.Focus(); IDC_EDIT_YEND.SelectAll(); string message = table["message53"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //颗粒尺寸范围 if (Convert.ToDouble(IDC_EDIT_PARTAREAMIN.Text.Trim()) > Convert.ToDouble(IDC_EDIT_PARTAREAMAX.Text.Trim())) { IDC_EDIT_PARTAREAMIN.Focus(); IDC_EDIT_PARTAREAMIN.SelectAll(); string message = table["message56"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //背景灰度范围 if (Convert.ToInt32(IDC_EDIT_BACKMIN.Text.Trim()) > Convert.ToInt32(IDC_EDIT_BACKMAX.Text.Trim())) { IDC_EDIT_BACKMIN.Focus(); IDC_EDIT_BACKMIN.SelectAll(); string message = table["message57"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //颗粒灰度范围 if (Convert.ToInt32(IDC_EDIT_PARTMIN.Text.Trim()) > Convert.ToInt32(IDC_EDIT_PARTMAX.Text.Trim())) { IDC_EDIT_PARTMIN.Focus(); IDC_EDIT_PARTMIN.SelectAll(); string message = table["message58"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } //最小放大倍数 if (false == rgpositiveInteger.Match(IDC_EDIT_XrayLimit.Text.Trim()).Success) { IDC_EDIT_XrayLimit.Focus(); IDC_EDIT_XrayLimit.SelectAll(); string message = table["message64"].ToString(); MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } return true; } /// /// 判断当前样品台是否在被修改 /// /// public bool IsModified() { return m_cstagefile.IsModified(); } /// /// 样品台保存 /// /// public bool StageSave() { if (!m_cstagefile.Save()) { log.Error("(OTSProgMgrInfoFun.StageLoad) Failed to save sample station information!"); return false; } return true; } private void btnok_Click(object sender, EventArgs e) { //先判断 if (false == CheckSetupValues(1)) { return; } //先把各个值都保存到各类 m_cotsprogmgrparamfile.m_runmode = (RunMode)IDC_COMBO_Model.SelectedIndex; SaveSEMStageData(); SaveImageScanPrm(); SaveCGenParam(); SaveImageProc(); SaveXRayParam(); //然后再把各类传入到SaveInfoToProgMgrFile函数中 if (false == SaveInfoToProgMgrFile()) { return; } //保存样品台到文件,在被修改时进行保存 if (true == IsModified()) { if (true == StageSave()) { this.DialogResult = DialogResult.OK; this.Close(); return; } else { string message = table["message54"].ToString(); log.Error("(ProgMgrInfoForm.btnok_Click) " + message); this.Close(); return; } } } //关闭窗体 private void btncancel_Click(object sender, EventArgs e) { this.Close(); } #endregion #region 选择样品台事件 private void IDC_COMBO_STAGE_SelectedIndexChanged(object sender, EventArgs e) { //样品台 if (!StageLoad()) { this.Close(); return;//加载失败返回 } ThisSetIsModify(); //加载相关参数信息 //StageLoad(); //LoadSEMStageData(); //LoadImageScanPrm(); //LoadCGenParam(); //LoadImageProc(); //LoadXRayParam(); } /// /// 通过id设置当前正在工作的样品台 /// /// public void SetWorkingStageId(int id) { m_cstagefile.SetWorkingStageId(id); } /// /// 设置当前样品台正在被修改中 /// /// public void SetModify(bool yn) { m_cstagefile.SetModify(true); } /// /// 设置当前窗体可以保存了 /// private void ThisSetIsModify() { ComboBoxItem cbi = new ComboBoxItem(); if (IDC_COMBO_STAGE.Items.Count > 0) if (null != IDC_COMBO_STAGE.SelectedItem) { cbi = (ComboBoxItem)IDC_COMBO_STAGE.SelectedItem; SetWorkingStageId(Convert.ToInt32(cbi.Value)); SetModify(true); btnok.Enabled = true; } } #endregion #region 监视控件改变状态事件 private void IDC_EDIT_SCREENWIDTH_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_XDIREC_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_XSTART_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_XEND_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_YDIRECT_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_YSTART_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_YEND_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_MINMAG_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_STOPMODE_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_STOP_TIME_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_STOP_FIELD_NUM_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_STOP_INCA_NUM_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_FETCHIMGMODE_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_IMGSCANSPEED_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_IMGSIZE_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_SAMPLENAME_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_MEAS_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_MEASUREPARAMPATH_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_ANALYSESTDLIBPATH_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_STDLIBNAME_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_PARTAREAMIN_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_PARTAREAMAX_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_BACKMIN_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_BACKMAX_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_PARTMIN_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_PARTMAX_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_AUTOBGREMOVETYPE_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_BGREMOVETYPE_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cbBGREMOVETYPE = (ComboBox)sender; int selectValue=Convert.ToInt32(((OTSMeasureApp.ComboBoxItem)cbBGREMOVETYPE.Items[cbBGREMOVETYPE.SelectedIndex]).Value); if (selectValue == (int)otsdataconst.OTS_AUTOBGREMOVETYPE.MANUAL) { IDC_COMBO_AUTOBGREMOVETYP.Enabled = false; } else { IDC_COMBO_AUTOBGREMOVETYP.Enabled = true; } ThisSetIsModify(); } private void IDC_COMBO_SEARCHXRAYSPEED_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_SEARCHXRAYCOUNTLIMIT_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_XRAYSCANMODE_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_ANALYXRAYSPEED_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_EDIT_ANALYXRAYAIMVALUE_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_TECHNOLOGY_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_STOP_MODE_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_STOP_TIME_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_STOP_FIELD_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_STOP_PARTICAL_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_FETCH_IMAGE_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_SCAN_SPEED_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_IMAGE_SIZE_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_PART_MIN_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_PART_MAX_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_BACK_MIN_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_BACK_MAX_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_PART_GRAY_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_PART_GRAY_MAX_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_XRAY_MODE_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_XRAY_TIME_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_XRAY_COUNT_SWITCH_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void cBMeasShape_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void tBMeasArea_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_SYS_LIB_CheckedChanged(object sender, EventArgs e) { ThisSetIsModify(); } #endregion private void IDC_COMBO_STDSelect_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_USINGXRAYS_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void IDC_COMBO_Model_SelectedIndexChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void btn_StopMode_Click(object sender, EventArgs e) { if (StopModeDialog == null) { StopModeDialog = new frmMeasureStopMode(); StopModeDialog.FieldMode = m_cotsimgscanprm.GetStopParamFields(); StopModeDialog.TimeMode = m_cotsimgscanprm.GetStopParamMeasTime(); StopModeDialog.ParticleMode = m_cotsimgscanprm.GetStopParamParticles(); StopModeDialog.AreaMode = m_cotsimgscanprm.GetStopParamArea(); StopModeDialog.StopMode = tB_StopMode.Text; } DialogResult result = StopModeDialog.ShowDialog(); if (result == DialogResult.OK) { string[] rst = StopModeDialog.StopMode.Split(','); string str = ""; for (int k = 0; k < rst.Length; k++) { str += rst[k].Split(':')[0] + " + "; } tB_StopMode.Text = str.Substring(0, str.Length - 3); } } private void IDC_COMBO_CorrosionExpansionCoefficient_TextChanged(object sender, EventArgs e) { ThisSetIsModify(); } private void button_SpPart_Click(object sender, EventArgs e) { } private void checkBox_Run_CheckedChanged(object sender, EventArgs e) { } private void btn_otherselection_Click(object sender, EventArgs e) { if (otherSelectionForm == null) { otherSelectionForm = new _7_OTSProgMgrInfo.OtherSelectionForm(); otherSelectionForm.OtherSelection = m_cotsimgprocprm.GetParticleSelectCondition(); } DialogResult result = otherSelectionForm.ShowDialog(); if (result == DialogResult.OK) { m_cotsimgprocprm.SetParticleSelectCondition(otherSelectionForm.OtherSelection); if (otherSelectionForm.OtherSelection == "") { IDC_EDIT_OTHERSELECTION.Text = "NoFilter"; } else { IDC_EDIT_OTHERSELECTION.Text = otherSelectionForm.OtherSelection; } } } private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked) { elementchoose.Enabled = false; } } int ReturnsAtomicNumberByElementName(string ElementName) { switch (ElementName) { case "H": return 1; case "He": return 2; case "Li": return 3; case "Be": return 4; case "B": return 5; case "C": return 6; case "N": return 7; case "O": return 8; case "F": return 9; case "Ne": return 10; case "Na": return 11; case "Mg": return 12; case "Al": return 13; case "Si": return 14; case "P": return 15; case "S": return 16; case "Cl": return 17; case "Ar": return 18; case "K": return 19; case "Ca": return 20; case "Sc": return 21; case "Ti": return 22; case "V": return 23; case "Cr": return 24; case "Mn": return 25; case "Fe": return 26; case "Co": return 27; case "Ni": return 28; case "Cu": return 29; case "Zn": return 30; case "Ga": return 31; case "Ge": return 32; case "As": return 33; case "Se": return 34; case "Br": return 35; case "Kr": return 36; case "Rb": return 37; case "Sr": return 38; case "Y": return 39; case "Zr": return 40; case "Nb": return 41; case "Mo": return 42; case "Tc": return 43; case "Ru": return 44; case "Rh": return 45; case "Pd": return 46; case "Ag": return 47; case "Cd": return 48; case "In": return 49; case "Sn": return 50; case "Sb": return 51; case "Te": return 52; case "I": return 53; case "Xe": return 54; case "Cs": return 55; case "Ba": return 56; case "La": return 57; case "Ce": return 58; case "Pr": return 59; case "Nd": return 60; case "Pm": return 61; case "Sm": return 62; case "Eu": return 63; case "Gd": return 64; case "Tb": return 65; case "Dy": return 66; case "Ho": return 67; case "Er": return 68; case "Tm": return 69; case "Yb": return 70; case "Lu": return 71; case "Hf": return 72; case "Ta": return 73; case "W": return 74; case "Re": return 75; case "Os": return 76; case "Ir": return 77; case "Pt": return 78; case "Au": return 79; case "Hq": return 80; case "TI": return 81; case "Pb": return 82; case "Bi": return 83; case "Po": return 84; case "At": return 85; case "Rn": return 86; case "Fr": return 87; case "Ra": return 88; case "Ac": return 89; case "Th": return 90; case "Pa": return 91; case "U": return 92; case "Np": return 93; case "Pu": return 94; case "Am": return 95; case "Cm": return 96; case "Bk": return 97; case "Cf": return 98; case "Es": return 99; case "Fm": return 100; case "Mc": return 101; case "No": return 102; case "Lr": return 103; case "Rf": return 104; case "Db": return 105; case "Sg": return 106; case "Bh": return 107; case "Hs": return 108; case "Mt": return 109; case "Ds": return 110; case "Rg": return 111; case "Unb": return 112; default: return 1000; } } private void button1_Click(object sender, EventArgs e) { OTSPeriodicTable.OTSPeriodicTableForm_Small opts = new OTSPeriodicTable.OTSPeriodicTableForm_Small(); //获取需要显示的元素列表,并转换成元素周期表窗体可接受的格式,传入---------------------- string str_xsys = tb_xsys.Text.Trim(); List list_str = new List(); string[] strs = str_xsys.Split(','); for (int i = 0; i < strs.Length; i++) { list_str.Add(strs[i]); } //清除元素周期表中所有的记录 opts.m_List_Periodic.Clear(); //将该分类下的元素添加到元素周期表窗体的List_periodic中 for (int i = 0; i < strs.Length; i++) { string str_ysm = strs[i]; Periodic ls_periodic = new Periodic(); ls_periodic = CListPeriodic.GetPeriodicByEleName(str_ysm); opts.m_List_Periodic.Add(ls_periodic); } //---------------------------------------------------------------------------------------- opts.StartPosition = FormStartPosition.CenterScreen; opts.ShowDialog(); List PeriodicFH = new List(); for (int j = 0; j < opts.m_List_Periodic.Count; j++) { PeriodicFH.Add(opts.m_List_Periodic[j].Symbol); } PeriodicFH.Sort(delegate (string a, string b) { return ReturnsAtomicNumberByElementName(a).CompareTo(ReturnsAtomicNumberByElementName(b)); });//排序 从小到大原子序数 list_str = list_str.FindAll(delegate (string a) { return PeriodicFH.Contains(a); }); PeriodicFH = PeriodicFH.FindAll(delegate (string a) { return !list_str.Contains(a); }); //先清空元素 str_xsys = ""; //然后再将选择的元素,组合起来,返回显示到该窗体上 for (int i = 0; i < list_str.Count; i++) { if (str_xsys == "") { str_xsys = list_str[i]; } else { str_xsys = str_xsys + "," + list_str[i]; } } for (int i = 0; i < PeriodicFH.Count; i++) { if (str_xsys == "") { str_xsys = PeriodicFH[i]; } else { str_xsys = str_xsys + "," + PeriodicFH[i]; } } //再对选择的元素进行显示 tb_xsys.Text = str_xsys; } private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked) { elementchoose.Enabled = true; } } } public class ComboBoxItem { private string _text = null; private object _value = null; public string Text { get { return this._text; } set { this._text = value; } } public object Value { get { return this._value; } set { this._value = value; } } public override string ToString() { return this._text; } } }