ProgMgrInfoForm.cs 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using System.Text.RegularExpressions;
  6. using System.Collections;
  7. using System.Diagnostics;
  8. using OTSDataType;
  9. using OTSModelSharp;
  10. using System.IO;
  11. using static OTSModelSharp.ResourceManage.ResourceData;
  12. using static OTSDataType.otsdataconst;
  13. using OTSModelSharp.Measure.GetStageInfo;
  14. using OTSMeasureApp._3_OTSDisplaySourceGridData;
  15. using OTSPeriodicTable;
  16. namespace OTSMeasureApp
  17. {
  18. public partial class ProgMgrInfoForm :Form
  19. {
  20. #region 定义变量
  21. //初始化函数功能类
  22. public CSampleHolder m_cstage; //样品台类
  23. public CStageHolderParam m_cstagefile; //样品台文件类
  24. public COTSDefaultParam m_cotsprogmgrparamfile; //参数类
  25. public CSEMStageData m_csemstagedata; //SEM样品台处理类
  26. public COTSImgScanPrm m_cotsimgscanprm; //图像扫描类
  27. public COTSCommonParam m_cgenparam; //一般参数类
  28. public COTSImageProcParam m_cotsimgprocprm; //图像处理类
  29. public COTSXRayParam m_cotsxrayprm;
  30. public bool m_b_checkstagefile = false;
  31. //定位程序管理路径用的变量
  32. public string m_ParameterPath;
  33. frmMeasureStopMode StopModeDialog;
  34. _7_OTSProgMgrInfo.OtherSelectionForm otherSelectionForm;
  35. //国际化
  36. OTSCommon.Language lan;
  37. Hashtable table;
  38. NLog.Logger log ;
  39. #endregion
  40. /// <summary>
  41. /// 样品台加载
  42. /// </summary>
  43. /// <returns></returns>
  44. public bool StageLoad()
  45. {
  46. if (!m_cstagefile.Load( true, !m_b_checkstagefile))
  47. {
  48. log.Error("(OTSProgMgrInfoFun.StageLoad) 加载样品台信息失败");
  49. return false;
  50. }
  51. return true;
  52. }
  53. #region 构造函数
  54. /// <summary>
  55. /// 默认构造函数
  56. /// </summary>
  57. public ProgMgrInfoForm()
  58. {
  59. log = NLog.LogManager.GetCurrentClassLogger();
  60. m_cotsprogmgrparamfile = new COTSDefaultParam();
  61. m_cstagefile = new CStageHolderParam();
  62. InitializeComponent();
  63. //国际化
  64. lan = new OTSCommon.Language(this);
  65. table = lan.GetNameTable(this.Name);
  66. }
  67. #endregion
  68. #region 绑定各combobox控件
  69. /// <summary>
  70. /// 绑定各combobox控件下拉列表
  71. /// </summary>
  72. public void BindComboBox()
  73. {
  74. //样品台
  75. if (!StageLoad())
  76. {
  77. this.Close();
  78. return;//加载失败返回
  79. }
  80. //绑定样品台列表信息
  81. BindStageCombobox();
  82. //初始化选项,下拉框---------------------------------------------
  83. //classify engine type
  84. comboEngineType.Items.Clear();
  85. if (m_cotsprogmgrparamfile.GetSysTypeName() == "IncA")
  86. {
  87. foreach (otsdataconst.OTS_CLASSIFY_ENGINE_TYPE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_CLASSIFY_ENGINE_TYPE)))
  88. {
  89. ComboBoxItem cbi = new ComboBoxItem();
  90. cbi.Text = enum_one.ToString();
  91. cbi.Value = (int)enum_one;
  92. comboEngineType.Items.Add(cbi);
  93. }
  94. }
  95. else if(m_cotsprogmgrparamfile.GetSysTypeName() == "SteelMineral")
  96. {
  97. foreach (otsdataconst.OTS_CLASSIFY_ENGINE_TYPE_SteelMineral enum_one in Enum.GetValues(typeof(otsdataconst.OTS_CLASSIFY_ENGINE_TYPE_SteelMineral)))
  98. {
  99. ComboBoxItem cbi = new ComboBoxItem();
  100. cbi.Text = enum_one.ToString();
  101. cbi.Value = (int)enum_one;
  102. comboEngineType.Items.Add(cbi);
  103. }
  104. }
  105. else
  106. {
  107. foreach (otsdataconst.OTS_CLASSIFY_ENGINE_TYPE_Cleanness enum_one in Enum.GetValues(typeof(otsdataconst.OTS_CLASSIFY_ENGINE_TYPE_Cleanness)))
  108. {
  109. ComboBoxItem cbi = new ComboBoxItem();
  110. cbi.Text = enum_one.ToString();
  111. cbi.Value = (int)enum_one;
  112. comboEngineType.Items.Add(cbi);
  113. }
  114. }
  115. this.comboEngineType.SelectedIndexChanged -= new System.EventHandler(this.comboEngineType_SelectedIndexChanged);
  116. if (comboEngineType.Items.Count > 0)
  117. comboEngineType.SelectedIndex = 0;
  118. this.comboEngineType.SelectedIndexChanged += new System.EventHandler(this.comboEngineType_SelectedIndexChanged);
  119. //绑定标准库
  120. IDC_COMBO_STDSelect.Items.Clear();
  121. string STDLibFolderName = m_cgenparam.GetPartSTDLibFolderName();
  122. string[] files = System.IO.Directory.GetFiles(STDLibFolderName, "*.db");
  123. System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(STDLibFolderName);
  124. foreach (System.IO.FileInfo file in folder.GetFiles("*.db"))
  125. {
  126. ComboBoxItem cbi = new ComboBoxItem();
  127. string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
  128. cbi.Text = FileNameWithoutExtension;
  129. //cbi.Value = (int)enum_one;
  130. IDC_COMBO_STDSelect.Items.Add(cbi);
  131. }
  132. //添加下拉列表中null项
  133. ComboBoxItem cbiNull = new ComboBoxItem();
  134. cbiNull.Text = "NoSTDDB";
  135. //cbi.Value = (int)enum_one;
  136. IDC_COMBO_STDSelect.Items.Add(cbiNull);
  137. this.IDC_COMBO_STDSelect.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_STDSelect_SelectedIndexChanged);
  138. if (IDC_COMBO_STDSelect.Items.Count > 0)
  139. IDC_COMBO_STDSelect.SelectedIndex = 0;
  140. //----------------------------------------------------------------------
  141. this.IDC_COMBO_STDSelect.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_STDSelect_SelectedIndexChanged);
  142. //x轴方向
  143. IDC_COMBO_XDIREC.Items.Clear();
  144. foreach (otsdataconst.OTS_X_AXIS_DIRECTION enum_one in Enum.GetValues(typeof(otsdataconst.OTS_X_AXIS_DIRECTION)))
  145. {
  146. ComboBoxItem cbi = new ComboBoxItem();
  147. cbi.Text = GetXAxisDirectionIdString(enum_one);
  148. cbi.Value = (int)enum_one;
  149. IDC_COMBO_XDIREC.Items.Add(cbi);
  150. }
  151. this.IDC_COMBO_XDIREC.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_XDIREC_SelectedIndexChanged);
  152. if (IDC_COMBO_XDIREC.Items.Count > 0)
  153. IDC_COMBO_XDIREC.SelectedIndex = 0;
  154. this.IDC_COMBO_XDIREC.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_XDIREC_SelectedIndexChanged);
  155. //y轴方向
  156. IDC_COMBO_YDIRECT.Items.Clear();
  157. foreach (otsdataconst.OTS_Y_AXIS_DIRECTION enum_one in Enum.GetValues(typeof(otsdataconst.OTS_Y_AXIS_DIRECTION)))
  158. {
  159. ComboBoxItem cbi = new ComboBoxItem();
  160. cbi.Text = GetYAxisDirectionIdString(enum_one);
  161. cbi.Value = (int)enum_one;
  162. IDC_COMBO_YDIRECT.Items.Add(cbi);
  163. }
  164. this.IDC_COMBO_YDIRECT.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_YDIRECT_SelectedIndexChanged);
  165. if (IDC_COMBO_YDIRECT.Items.Count > 0)
  166. IDC_COMBO_YDIRECT.SelectedIndex = 0;
  167. this.IDC_COMBO_YDIRECT.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_YDIRECT_SelectedIndexChanged);
  168. //取图方式
  169. IDC_COMBO_FETCHIMGMODE.Items.Clear();
  170. foreach (otsdataconst.OTS_GET_IMAGE_MODE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_GET_IMAGE_MODE)))
  171. {
  172. ComboBoxItem cbi = new ComboBoxItem();
  173. cbi.Text = GetImageModeString(enum_one);
  174. cbi.Value = (int)enum_one;
  175. IDC_COMBO_FETCHIMGMODE.Items.Add(cbi);
  176. }
  177. this.IDC_COMBO_FETCHIMGMODE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_FETCHIMGMODE_SelectedIndexChanged);
  178. if (IDC_COMBO_FETCHIMGMODE.Items.Count > 0)
  179. IDC_COMBO_FETCHIMGMODE.SelectedIndex = 0;
  180. this.IDC_COMBO_FETCHIMGMODE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_FETCHIMGMODE_SelectedIndexChanged);
  181. //扫描图精度
  182. IDC_COMBO_IMGSCANSPEED.Items.Clear();
  183. foreach (otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS)))
  184. {
  185. ComboBoxItem cbi = new ComboBoxItem();
  186. cbi.Text = GetScanSpeedString(enum_one);
  187. cbi.Value = (int)enum_one;
  188. IDC_COMBO_IMGSCANSPEED.Items.Add(cbi);
  189. }
  190. this.IDC_COMBO_IMGSCANSPEED.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_IMGSCANSPEED_SelectedIndexChanged);
  191. if (IDC_COMBO_IMGSCANSPEED.Items.Count > 0)
  192. IDC_COMBO_IMGSCANSPEED.SelectedIndex = 0;
  193. this.IDC_COMBO_IMGSCANSPEED.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_IMGSCANSPEED_SelectedIndexChanged);
  194. //扫描图尺寸
  195. IDC_COMBO_IMGSIZE.Items.Clear();
  196. foreach (otsdataconst.OTS_IMAGE_RESULOTION_OPTIONS enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_RESULOTION_OPTIONS)))
  197. {
  198. ComboBoxItem cbi = new ComboBoxItem();
  199. cbi.Text = enum_one.ToString();
  200. cbi.Value = (int)enum_one;
  201. IDC_COMBO_IMGSIZE.Items.Add(cbi);
  202. }
  203. this.IDC_COMBO_IMGSIZE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_IMGSIZE_SelectedIndexChanged);
  204. if (IDC_COMBO_IMGSIZE.Items.Count > 0)
  205. IDC_COMBO_IMGSIZE.SelectedIndex = 0;
  206. this.IDC_COMBO_IMGSIZE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_IMGSIZE_SelectedIndexChanged);
  207. //去背景方式
  208. IDC_COMBO_BGREMOVETYPE.Items.Clear();
  209. foreach (otsdataconst.OTS_AUTOBGREMOVETYPE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_AUTOBGREMOVETYPE)))
  210. {
  211. ComboBoxItem cbi = new ComboBoxItem();
  212. cbi.Text = GetBGREMOVETYPEString(enum_one);
  213. cbi.Value = (int)enum_one;
  214. IDC_COMBO_BGREMOVETYPE.Items.Add(cbi);
  215. }
  216. this.IDC_COMBO_BGREMOVETYPE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_BGREMOVETYPE_SelectedIndexChanged);
  217. if (IDC_COMBO_BGREMOVETYPE.Items.Count > 0)
  218. IDC_COMBO_BGREMOVETYPE.SelectedIndex = 0;
  219. this.IDC_COMBO_BGREMOVETYPE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_BGREMOVETYPE_SelectedIndexChanged);
  220. //自动去背景方式
  221. IDC_COMBO_AUTOBGREMOVETYP.Items.Clear();
  222. foreach (otsdataconst.OTS_IMAGE_MODE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_IMAGE_MODE)))
  223. {
  224. ComboBoxItem cbi = new ComboBoxItem();
  225. cbi.Text = GetAUTOBGREMOVETYPEString(enum_one);
  226. cbi.Value = (int)enum_one;
  227. IDC_COMBO_AUTOBGREMOVETYP.Items.Add(cbi);
  228. }
  229. this.IDC_COMBO_AUTOBGREMOVETYP.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_AUTOBGREMOVETYPE_SelectedIndexChanged);
  230. if (IDC_COMBO_AUTOBGREMOVETYP.Items.Count > 0)
  231. IDC_COMBO_AUTOBGREMOVETYP.SelectedIndex = 0;
  232. this.IDC_COMBO_AUTOBGREMOVETYP.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_AUTOBGREMOVETYPE_SelectedIndexChanged);
  233. //X-Ray扫描方式
  234. IDC_COMBO_XRAYSCANMODE.Items.Clear();
  235. foreach (otsdataconst.OTS_X_RAY_SCAN_MODE enum_one in Enum.GetValues(typeof(otsdataconst.OTS_X_RAY_SCAN_MODE)))
  236. {
  237. ComboBoxItem cbi = new ComboBoxItem();
  238. cbi.Text = GetXRayScanModeIdString(enum_one);
  239. cbi.Value = (int)enum_one;
  240. IDC_COMBO_XRAYSCANMODE.Items.Add(cbi);
  241. }
  242. this.IDC_COMBO_XRAYSCANMODE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_XRAYSCANMODE_SelectedIndexChanged);
  243. if (IDC_COMBO_XRAYSCANMODE.Items.Count > 0)
  244. IDC_COMBO_XRAYSCANMODE.SelectedIndex = 0;
  245. this.IDC_COMBO_XRAYSCANMODE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_XRAYSCANMODE_SelectedIndexChanged);
  246. //精炼工艺下拉框选项
  247. IDC_COMBO_TECHNOLOGY.Items.Clear();
  248. foreach (STEEL_TECHNOLOGY enum_one in Enum.GetValues(typeof(STEEL_TECHNOLOGY)))
  249. {
  250. ComboBoxItem cbi = new ComboBoxItem();
  251. cbi.Text = GetSteelTechIdString((otsdataconst.STEEL_TECHNOLOGY)enum_one);
  252. cbi.Value = (int)enum_one;
  253. IDC_COMBO_TECHNOLOGY.Items.Add(cbi);
  254. }
  255. this.IDC_COMBO_TECHNOLOGY.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_TECHNOLOGY_SelectedIndexChanged);
  256. if (IDC_COMBO_TECHNOLOGY.Items.Count > 0)
  257. IDC_COMBO_TECHNOLOGY.SelectedIndex = 0;
  258. this.IDC_COMBO_TECHNOLOGY.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_TECHNOLOGY_SelectedIndexChanged);
  259. //测量区域形状
  260. cBMeasShape.Items.Clear();
  261. foreach (otsdataconst.MEASURE_SHAPE enum_one in Enum.GetValues(typeof(otsdataconst.MEASURE_SHAPE)))
  262. {
  263. ComboBoxItem cbi = new ComboBoxItem();
  264. cbi.Text = GetAreaShapeString(enum_one);
  265. cbi.Value = (int)enum_one;
  266. cBMeasShape.Items.Add(cbi);
  267. }
  268. this.cBMeasShape.SelectedIndexChanged -= new System.EventHandler(this.cBMeasShape_SelectedIndexChanged);
  269. if (cBMeasShape.Items.Count > 0)
  270. cBMeasShape.SelectedIndex = 0;
  271. this.cBMeasShape.SelectedIndexChanged += new System.EventHandler(this.cBMeasShape_SelectedIndexChanged);
  272. //模式选择
  273. IDC_COMBO_Model.Items.Clear();
  274. foreach (otsdataconst.RunMode enum_one in Enum.GetValues(typeof(otsdataconst.RunMode)))
  275. {
  276. OTSPeriodicTable.ComboBoxItem cbi = new OTSPeriodicTable.ComboBoxItem();
  277. cbi.Text = GetRunModeString(enum_one);
  278. cbi.Value = (int)enum_one;
  279. IDC_COMBO_Model.Items.Add(cbi);
  280. }
  281. this.IDC_COMBO_Model.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_Model_SelectedIndexChanged);
  282. if (IDC_COMBO_Model.Items.Count > 0)
  283. IDC_COMBO_Model.SelectedIndex = 0;
  284. this.IDC_COMBO_Model.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_Model_SelectedIndexChanged);
  285. }
  286. private void comboEngineType_SelectedIndexChanged(object sender, EventArgs e)
  287. {
  288. ThisSetIsModify();
  289. }
  290. public CSampleHolder GetWorkingStage()
  291. {
  292. CSampleHolder ls_cstageclr = m_cstagefile.GetWorkingStage();
  293. if (null == ls_cstageclr)
  294. {
  295. log.Error("(OTSProgMgrInfoFun.GetWorkingStage) 获取正在工作的样品台类失败");
  296. return ls_cstageclr;
  297. }
  298. return ls_cstageclr;
  299. }
  300. /// <summary>
  301. /// 获取正在工作的样品台ID
  302. /// </summary>
  303. /// <returns></returns>
  304. public int GetWorkingStageId()
  305. {
  306. int stageid = m_cstagefile.GetWorkingStageId();
  307. return stageid;
  308. }
  309. /// <summary>
  310. /// 获取样品台信息列表
  311. /// </summary>
  312. /// <returns></returns>
  313. public List<CSampleHolder> GetStageList()
  314. {
  315. List<CSampleHolder> l_cstageclr = m_cstagefile.GetStagesList();
  316. if (null == l_cstageclr)
  317. {
  318. log.Error("(OTSProgMgrInfoFun.GetStageList) 获取样品台信息列表失败");
  319. return l_cstageclr;
  320. }
  321. return l_cstageclr;
  322. }
  323. /// <summary>
  324. /// 绑定样品台列表信息
  325. /// </summary>
  326. private void BindStageCombobox()
  327. {
  328. //先插入正在工作的样品台
  329. int ls_workingstageid = 0;
  330. IDC_COMBO_STAGE.Items.Clear();
  331. CSampleHolder ls_cstageclr = GetWorkingStage();
  332. ComboBoxItem ls_cbi = new ComboBoxItem();
  333. ls_cbi.Text = ls_cstageclr.GetName();
  334. ls_workingstageid = GetWorkingStageId();
  335. ls_cbi.Value = ls_workingstageid;
  336. IDC_COMBO_STAGE.Items.Add(ls_cbi);
  337. //添加其它的样品台信息
  338. List<CSampleHolder> l_cstageclr = GetStageList();
  339. for (int i = 0; i < l_cstageclr.Count(); i++)
  340. {
  341. if (ls_workingstageid != i)//将已经插入过的正在工作样品台信息跳过去
  342. {
  343. ComboBoxItem cbi = new ComboBoxItem();
  344. cbi.Text = l_cstageclr[i].GetName().ToString();
  345. cbi.Value = i.ToString();
  346. IDC_COMBO_STAGE.Items.Add(cbi);
  347. }
  348. }
  349. //防止进入窗体后,马上进入下拉项选择事件,先把事件去掉,一会再注册上
  350. this.IDC_COMBO_STAGE.SelectedIndexChanged -= new System.EventHandler(this.IDC_COMBO_STAGE_SelectedIndexChanged);
  351. //默认选择上
  352. if (IDC_COMBO_STAGE.Items.Count > 0)
  353. {
  354. IDC_COMBO_STAGE.SelectedIndex = 0;
  355. }
  356. this.IDC_COMBO_STAGE.SelectedIndexChanged += new System.EventHandler(this.IDC_COMBO_STAGE_SelectedIndexChanged);
  357. }
  358. #endregion
  359. #region 参数相关方法封装
  360. /// <summary>
  361. /// 读取SEM样品台参数信息
  362. /// </summary>
  363. public void LoadSEMStageData()
  364. {
  365. //100倍时屏幕尺寸/mm
  366. IDC_EDIT_SCREENWIDTH.Text = m_csemstagedata.GetScanFieldSize100().ToString();
  367. //x轴方向
  368. foreach (ComboBoxItem cbi in IDC_COMBO_XDIREC.Items)
  369. {
  370. if (cbi.Value.ToString() != "")
  371. if (Convert.ToInt32(cbi.Value) == (int)m_csemstagedata.GetXAxisDir())
  372. {
  373. IDC_COMBO_XDIREC.SelectedItem = cbi;
  374. }
  375. }
  376. //x轴行程/mm 起,取值时,乘1000
  377. IDC_EDIT_XSTART.Text = (m_csemstagedata.GetXAxis().GetStart() / 1000).ToString();
  378. //x轴行程/mm 始
  379. IDC_EDIT_XEND.Text = (m_csemstagedata.GetXAxis().GetEnd() / 1000).ToString();
  380. //y轴方向
  381. foreach (ComboBoxItem cbi in IDC_COMBO_YDIRECT.Items)
  382. {
  383. if (cbi.Value.ToString() != "")
  384. if (Convert.ToInt32(cbi.Value) == (int)m_csemstagedata.GetYAxisDir())
  385. {
  386. IDC_COMBO_YDIRECT.SelectedItem = cbi;
  387. }
  388. }
  389. //y轴行程/mm 起
  390. IDC_EDIT_YSTART.Text = (m_csemstagedata.GetYAxis().GetStart() / 1000).ToString();
  391. //y轴行程/mm 始
  392. IDC_EDIT_YEND.Text = (m_csemstagedata.GetYAxis().GetEnd() / 1000).ToString();
  393. //最小放大倍数
  394. IDC_EDIT_MINMAG.Text = m_csemstagedata.GetMinMag().ToString();
  395. }
  396. /// <summary>
  397. /// 加载图像扫描参数
  398. /// </summary>
  399. public void LoadImageScanPrm()
  400. {
  401. //测量终止方式
  402. tB_StopMode.Text = m_cotsimgscanprm.GetStopMode().ToString();
  403. if (StopModeDialog == null)
  404. {
  405. StopModeDialog = new frmMeasureStopMode();
  406. StopModeDialog.FieldMode = m_cotsimgscanprm.GetStopParamFields();
  407. StopModeDialog.TimeMode = m_cotsimgscanprm.GetStopParamMeasTime();
  408. StopModeDialog.ParticleMode = m_cotsimgscanprm.GetStopParamParticles();
  409. StopModeDialog.AreaMode = m_cotsimgscanprm.GetStopParamArea();
  410. StopModeDialog.StopMode = tB_StopMode.Text;
  411. }
  412. //取图方式
  413. foreach (ComboBoxItem cbi in IDC_COMBO_FETCHIMGMODE.Items)
  414. {
  415. if (cbi.Value.ToString() != "")
  416. if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgscanprm.GetFieldStartMode())
  417. {
  418. IDC_COMBO_FETCHIMGMODE.SelectedItem = cbi;
  419. }
  420. }
  421. //扫描图精度
  422. foreach (ComboBoxItem cbi in IDC_COMBO_IMGSCANSPEED.Items)
  423. {
  424. if (cbi.Value.ToString() != "")
  425. if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgscanprm.GetScanImageSpeed())
  426. {
  427. IDC_COMBO_IMGSCANSPEED.SelectedItem = cbi;
  428. }
  429. }
  430. //扫描图尺寸
  431. foreach (ComboBoxItem cbi in IDC_COMBO_IMGSIZE.Items)
  432. {
  433. if (cbi.Value.ToString() != "")
  434. if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgscanprm.GetImageResulotion())
  435. {
  436. IDC_COMBO_IMGSIZE.SelectedItem = cbi;
  437. }
  438. }
  439. }
  440. /// <summary>
  441. /// 加载一般常规参数
  442. /// </summary>
  443. public void LoadCGenParam()
  444. {
  445. //样品名
  446. IDC_EDIT_SAMPLENAME.Text = m_cgenparam.GetSampleName().ToString();
  447. //执行开关
  448. IDC_MEAS_SWITCH.Checked = m_cgenparam.GetMeasurementSwitch();
  449. //是否使用系统库开关
  450. OTS_CLASSIFY_ENGINE_TYPE EngineType = m_cgenparam.GetEngineType();
  451. int sel = 0;
  452. if (m_cotsprogmgrparamfile.GetSysTypeName() == "SteelMineral")
  453. {
  454. if(EngineType== OTS_CLASSIFY_ENGINE_TYPE.SpectrumMatch)
  455. {
  456. sel = 1;
  457. }
  458. else
  459. {
  460. sel = 0;
  461. }
  462. }
  463. else if (m_cotsprogmgrparamfile.GetSysTypeName() == "IncA")
  464. {
  465. sel = (int)EngineType;
  466. }
  467. else
  468. {
  469. sel = 0;
  470. }
  471. comboEngineType.SelectedIndex = sel;
  472. //精炼工艺选项
  473. foreach (ComboBoxItem cbi in IDC_COMBO_TECHNOLOGY.Items)
  474. {
  475. if (cbi.Value.ToString() != "")
  476. if (Convert.ToInt32(cbi.Value) == m_cgenparam.GetSteelTechnology())
  477. {
  478. IDC_COMBO_TECHNOLOGY.SelectedItem = cbi;
  479. }
  480. }
  481. //测量区域形状
  482. foreach (ComboBoxItem cbi in cBMeasShape.Items)
  483. {
  484. if (cbi.Value.ToString() != "")
  485. if (Convert.ToInt32(cbi.Value) == (int)m_cgenparam.GetShape())
  486. {
  487. cBMeasShape.SelectedItem = cbi;
  488. }
  489. }
  490. //测量区域面积
  491. tBMeasArea.Text = m_cgenparam.GetArea().ToString();
  492. //标准库选择
  493. foreach (ComboBoxItem cbi in IDC_COMBO_STDSelect.Items)
  494. {
  495. if (cbi.Text.ToString() != "")
  496. if (cbi.Text.ToString() == m_cgenparam.GetSTDSelect())
  497. {
  498. IDC_COMBO_STDSelect.SelectedItem = cbi;
  499. }
  500. }
  501. }
  502. /// <summary>
  503. /// 加载默认参数
  504. /// </summary>
  505. public void LoadDefaultParam()
  506. {
  507. //模式
  508. foreach (OTSPeriodicTable.ComboBoxItem cbi in IDC_COMBO_Model.Items)
  509. {
  510. if (cbi.Value.ToString() != "")
  511. if (Convert.ToInt32(cbi.Value) == (int)m_cotsprogmgrparamfile.GetRunMode())
  512. {
  513. IDC_COMBO_Model.SelectedItem = cbi;
  514. }
  515. }
  516. }
  517. /// <summary>
  518. /// 加载图像处理参数
  519. /// </summary>
  520. public void LoadImageProc()
  521. {
  522. //颗粒面积范围 最小
  523. IDC_EDIT_PARTAREAMIN.Text = m_cotsimgprocprm.GetIncAreaRange().GetStart().ToString();
  524. //颗粒面积范围 最大
  525. IDC_EDIT_PARTAREAMAX.Text = m_cotsimgprocprm.GetIncAreaRange().GetEnd().ToString();
  526. //背景灰度范围 最小
  527. IDC_EDIT_BACKMIN.Text = m_cotsimgprocprm.GetBGGray().GetStart().ToString();
  528. //背景灰度范围 最大
  529. IDC_EDIT_BACKMAX.Text = m_cotsimgprocprm.GetBGGray().GetEnd().ToString();
  530. //颗粒灰度范围 最小
  531. IDC_EDIT_PARTMIN.Text = m_cotsimgprocprm.GetParticleGray().GetStart().ToString();
  532. //颗粒灰度范围 最大
  533. IDC_EDIT_PARTMAX.Text = m_cotsimgprocprm.GetParticleGray().GetEnd().ToString();
  534. //重叠尺寸
  535. IDC_EDIT_Overlap.Text = m_cotsimgprocprm.GetOverlapParam().ToString();
  536. //去背景方式
  537. foreach (ComboBoxItem cbi in IDC_COMBO_BGREMOVETYPE.Items)
  538. {
  539. if (cbi.Value.ToString() != "")
  540. {
  541. if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgprocprm.GetBGRemoveType())
  542. {
  543. IDC_COMBO_BGREMOVETYPE.SelectedItem = cbi;
  544. break;
  545. }
  546. }
  547. }
  548. foreach (ComboBoxItem cbi in IDC_COMBO_AUTOBGREMOVETYP.Items)
  549. {
  550. if (cbi.Value.ToString() != "")
  551. {
  552. if (Convert.ToInt32(cbi.Value) == (int)m_cotsimgprocprm.GetAutoBGRemoveType())
  553. {
  554. IDC_COMBO_AUTOBGREMOVETYP.SelectedItem = cbi;
  555. break;
  556. }
  557. }
  558. }
  559. //重叠尺寸
  560. IDC_EDIT_Overlap.Text = m_cotsimgprocprm.GetOverlapParam().ToString();
  561. if (m_cotsimgprocprm.GetParticleSelectCondition().ToString() == "")
  562. {
  563. IDC_EDIT_OTHERSELECTION.Text = "NoFilter";
  564. }
  565. else
  566. {
  567. IDC_EDIT_OTHERSELECTION.Text = m_cotsimgprocprm.GetParticleSelectCondition().ToString();
  568. }
  569. }
  570. /// <summary>
  571. /// 加载X-Ray参数
  572. /// </summary>
  573. public void LoadXRayParam()
  574. {
  575. foreach (ComboBoxItem cbi in IDC_COMBO_XRAYSCANMODE.Items)
  576. {
  577. if (cbi.Value.ToString() != "")
  578. if (Convert.ToInt32(cbi.Value) == (int)m_cotsxrayprm.GetScanMode())
  579. {
  580. IDC_COMBO_XRAYSCANMODE.SelectedItem = cbi;
  581. }
  582. }
  583. //是否使用电镜
  584. IDC_USINGXRAY_LIB.Checked = m_cotsxrayprm.GetUsingXray();
  585. //分析X-ray精度对应的时间
  586. IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Text = m_cotsxrayprm.GetMidAnalyAQTime().ToString();
  587. //分析X-ray计数期望值
  588. IDC_EDIT_ANALYXRAYAIMVALUE.Text = m_cotsxrayprm.GetAnalyExpCount().ToString();
  589. IDC_EDIT_QuantifyMinSize.Text = m_cotsxrayprm.GetFeatureModeMinSize().ToString();
  590. IDC_EDIT_SmallPartAQTime.Text = m_cotsxrayprm.GetSmallPartXrayTime().ToString();
  591. IDC_EDIT_XrayLimit.Text = m_cotsxrayprm.GetXrayLimit().ToString();
  592. if (m_cotsxrayprm.IfAutoId)
  593. {
  594. radioButton1.Checked =true;
  595. }
  596. else
  597. {
  598. radioButton2.Checked = true;
  599. }
  600. tb_xsys.Text = m_cotsxrayprm.AnalysisElements;
  601. }
  602. /// <summary>
  603. /// 保存SEM样品台参数
  604. /// </summary>
  605. public void SaveSEMStageData()
  606. {
  607. //100倍时屏幕尺寸/mm
  608. m_csemstagedata.SetScanFieldSize100(Convert.ToInt32(IDC_EDIT_SCREENWIDTH.Text));
  609. //x轴方向
  610. ComboBoxItem cbi_x = (ComboBoxItem)IDC_COMBO_XDIREC.SelectedItem;
  611. m_csemstagedata.SetXAxisDir((otsdataconst.OTS_X_AXIS_DIRECTION)Convert.ToInt32(cbi_x.Value));
  612. //x轴行程/mm 起,始
  613. CIntRange crc_x = new CIntRange(Convert.ToInt32(IDC_EDIT_XSTART.Text) * 1000, Convert.ToInt32(IDC_EDIT_XEND.Text) * 1000);
  614. m_csemstagedata.SetXAxis(crc_x);
  615. //y轴方向
  616. ComboBoxItem cbi_y = (ComboBoxItem)IDC_COMBO_YDIRECT.SelectedItem;
  617. m_csemstagedata.SetYAxisDir((otsdataconst.OTS_Y_AXIS_DIRECTION)Convert.ToInt32(cbi_y.Value));
  618. //y轴行程/mm 起,始
  619. CIntRange crc_y = new CIntRange(Convert.ToInt32(IDC_EDIT_YSTART.Text) * 1000, Convert.ToInt32(IDC_EDIT_YEND.Text) * 1000);
  620. m_csemstagedata.SetYAxis(crc_y);
  621. //最小放大倍数
  622. m_csemstagedata.SetMinMag(Convert.ToDouble(IDC_EDIT_MINMAG.Text));
  623. }
  624. /// <summary>
  625. /// 保存图像扫描参数
  626. /// </summary>
  627. public void SaveImageScanPrm()
  628. {
  629. // 保存图像扫描参数");
  630. //测量终止方式
  631. m_cotsimgscanprm.SetStopMode(tB_StopMode.Text);
  632. //终止时间
  633. m_cotsimgscanprm.SetStopParamMeasTime(StopModeDialog.TimeMode);
  634. ////终止帧图数
  635. m_cotsimgscanprm.SetStopParamFields(StopModeDialog.FieldMode);
  636. ////终止夹杂物数
  637. m_cotsimgscanprm.SetStopParamParticles(StopModeDialog.ParticleMode);
  638. ////终止面积
  639. m_cotsimgscanprm.SetStopParamArea(StopModeDialog.AreaMode);
  640. //取图方式
  641. ComboBoxItem enum_fetchimgmode = (ComboBoxItem)IDC_COMBO_FETCHIMGMODE.SelectedItem;
  642. m_cotsimgscanprm.SetStartImageMode((otsdataconst.OTS_GET_IMAGE_MODE)Convert.ToInt32(enum_fetchimgmode.Value));
  643. //扫描图精度
  644. ComboBoxItem enum_imgscanspeed = (ComboBoxItem)IDC_COMBO_IMGSCANSPEED.SelectedItem;
  645. m_cotsimgscanprm.SetScanImageSpeed((otsdataconst.OTS_IMAGE_SCANSPEED_OPTIONS)Convert.ToInt32(enum_imgscanspeed.Value));
  646. //扫描图尺寸
  647. ComboBoxItem enum_imgsize = (ComboBoxItem)IDC_COMBO_IMGSIZE.SelectedItem;
  648. m_cotsimgscanprm.SetImageResulotion((otsdataconst.OTS_IMAGE_RESULOTION_OPTIONS)Convert.ToInt32(enum_imgsize.Value));
  649. }
  650. /// <summary>
  651. /// 保存一般常规参数
  652. /// </summary>
  653. public void SaveCGenParam()
  654. {
  655. //样品名
  656. m_cgenparam.SetSampleName(IDC_EDIT_SAMPLENAME.Text);
  657. //执行开关
  658. m_cgenparam.SetMeasurementSwitch(IDC_MEAS_SWITCH.Checked);
  659. //是否使用系统库
  660. m_cgenparam.SetEngineType((OTS_CLASSIFY_ENGINE_TYPE)comboEngineType.SelectedIndex);
  661. //获取精炼工艺索引
  662. ComboBoxItem cbiTECH = new ComboBoxItem();
  663. cbiTECH = (ComboBoxItem)IDC_COMBO_TECHNOLOGY.SelectedItem;
  664. //设置参数文件类中精炼工艺索引值
  665. m_cgenparam.SetSteelTechnology((int)cbiTECH.Value);
  666. //测量区域形状
  667. ComboBoxItem enum_Shape = (ComboBoxItem)cBMeasShape.SelectedItem;
  668. m_cgenparam.SetShape((otsdataconst.DOMAIN_SHAPE)Convert.ToInt32(enum_Shape.Value));
  669. //测量区域大小
  670. m_cgenparam.SetArea(Convert.ToDouble(tBMeasArea.Text));
  671. int EngineType = comboEngineType.SelectedIndex;
  672. OTS_CLASSIFY_ENGINE_TYPE oTS_CLASSIFY_ENGINE_TYPE = OTS_CLASSIFY_ENGINE_TYPE.ExpressionParse;
  673. if (m_cotsprogmgrparamfile.GetSysTypeName() == "IncA")
  674. {
  675. oTS_CLASSIFY_ENGINE_TYPE=(OTS_CLASSIFY_ENGINE_TYPE)comboEngineType.SelectedIndex;
  676. }
  677. else if (m_cotsprogmgrparamfile.GetSysTypeName() == "SteelMineral")
  678. {
  679. if(comboEngineType.SelectedIndex==0)
  680. {
  681. oTS_CLASSIFY_ENGINE_TYPE = OTS_CLASSIFY_ENGINE_TYPE.ExpressionParse;
  682. }
  683. else
  684. {
  685. oTS_CLASSIFY_ENGINE_TYPE = OTS_CLASSIFY_ENGINE_TYPE.SpectrumMatch;
  686. }
  687. }
  688. else
  689. {
  690. oTS_CLASSIFY_ENGINE_TYPE = OTS_CLASSIFY_ENGINE_TYPE.ExpressionParse;
  691. }
  692. m_cgenparam.SetEngineType(oTS_CLASSIFY_ENGINE_TYPE);
  693. //标准库选择
  694. ComboBoxItem enum_STDLIBSELECT = (ComboBoxItem)IDC_COMBO_STDSelect.SelectedItem;
  695. m_cgenparam.SetSTDSelect(enum_STDLIBSELECT.Text.ToString());
  696. }
  697. /// <summary>
  698. /// 保存图像处理参数
  699. /// </summary>
  700. public void SaveImageProc()
  701. {
  702. //颗粒面积范围 最小 最大
  703. CDoubleRange crc_partareamin = new CDoubleRange(Math.Round(Convert.ToDouble(IDC_EDIT_PARTAREAMIN.Text), 2), Math.Round(Convert.ToDouble(IDC_EDIT_PARTAREAMAX.Text), 2));
  704. m_cotsimgprocprm.SetIncAreaRange(crc_partareamin);
  705. //背景灰度范围 最小 最大
  706. CIntRange crc_backmin = new CIntRange(Convert.ToInt32(IDC_EDIT_BACKMIN.Text), Convert.ToInt32(IDC_EDIT_BACKMAX.Text));
  707. m_cotsimgprocprm.SetBGGray(crc_backmin);
  708. //颗粒灰度范围 最小 最大
  709. CIntRange crc_partmin = new CIntRange(Convert.ToInt32(IDC_EDIT_PARTMIN.Text), Convert.ToInt32(IDC_EDIT_PARTMAX.Text));
  710. m_cotsimgprocprm.SetParticleGray(crc_partmin);
  711. //去背景方式
  712. ComboBoxItem enum_BGREMOVETYPE = (ComboBoxItem)IDC_COMBO_BGREMOVETYPE.SelectedItem;
  713. m_cotsimgprocprm.SetBGRemoveType((otsdataconst.OTS_BGREMOVE_TYPE)enum_BGREMOVETYPE.Value);
  714. //去背景方式
  715. ComboBoxItem enum_AUTOBGREMOVETYP = (ComboBoxItem)IDC_COMBO_AUTOBGREMOVETYP.SelectedItem;
  716. m_cotsimgprocprm.SetAutoBGRemoveType((otsdataconst.OTS_AUTOBGREMOVE_TYPE)enum_AUTOBGREMOVETYP.Value);
  717. //重叠像素
  718. m_cotsimgprocprm.SetOverlapParam(Convert.ToInt32(IDC_EDIT_Overlap.Text));
  719. if (IDC_EDIT_OTHERSELECTION.Text != "NoFilter")
  720. {
  721. m_cotsimgprocprm.SetParticleSelectCondition(IDC_EDIT_OTHERSELECTION.Text);
  722. }
  723. else
  724. {
  725. m_cotsimgprocprm.SetParticleSelectCondition("");
  726. }
  727. }
  728. /// <summary>
  729. /// 保存X-Ray参数
  730. /// </summary>
  731. public void SaveXRayParam()
  732. {
  733. //X-ray扫描方式
  734. ComboBoxItem enum_xrayscanmode = (ComboBoxItem)IDC_COMBO_XRAYSCANMODE.SelectedItem;
  735. m_cotsxrayprm.SetScanMode((otsdataconst.OTS_X_RAY_SCAN_MODE)Convert.ToInt32(enum_xrayscanmode.Value));
  736. //是否使用X-ray
  737. m_cotsxrayprm.SetUsingXray(IDC_USINGXRAY_LIB.Checked);
  738. //分析X-ray精度对应的时间
  739. m_cotsxrayprm.SetMidAnalyAQTime(Convert.ToInt32(IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Text.Trim()));
  740. //分析X-ray计数期望值
  741. m_cotsxrayprm.SetAnalyExpCount(Convert.ToInt32(IDC_EDIT_ANALYXRAYAIMVALUE.Text));
  742. m_cotsxrayprm.SetFeatureModeMinSize(Convert.ToDouble(IDC_EDIT_QuantifyMinSize.Text));
  743. m_cotsxrayprm.SetSmallPartXrayTime(Convert.ToInt32(IDC_EDIT_SmallPartAQTime.Text));
  744. m_cotsxrayprm.SetXrayLimit(Convert.ToInt32(IDC_EDIT_XrayLimit.Text));
  745. m_cotsxrayprm.IfAutoId=radioButton1.Checked ;
  746. m_cotsxrayprm.AnalysisElements=tb_xsys.Text ;
  747. }
  748. /// <summary>
  749. /// 将参数保存到文件
  750. /// </summary>
  751. /// <param name="a_nPackId"></param>
  752. /// <param name="a_pStageData"></param>
  753. /// <param name="a_pGenParam"></param>
  754. /// <param name="a_pImageScanParam"></param>
  755. /// <param name="a_pImageProcParam"></param>
  756. /// <param name="a_pXRayParam"></param>
  757. /// <returns></returns>
  758. public bool SaveInfoToProgMgrFile()
  759. {
  760. //SaveInfoToProgMgrFile()
  761. if (false == m_cotsprogmgrparamfile.SaveInfoToProgMgrFile())
  762. {
  763. log.Error("(OTSProgMgrInfoFun.SaveInfoToProgMgrFile) Failed to save parameters to file");
  764. return false;
  765. }
  766. return true;
  767. }
  768. /// <summary>
  769. /// 加载参数各个类
  770. /// </summary>
  771. public bool LoadParamFun()
  772. {
  773. bool result = m_cotsprogmgrparamfile.LoadInfoFromProgMgrFile();
  774. if (!result)
  775. {
  776. log.Error("(OTSProgMgrInfoFun.LoadParamFun) LoadInfoFromProgMgrFile Failed");
  777. return false;
  778. }
  779. m_csemstagedata = m_cotsprogmgrparamfile.GetStageDataParam();
  780. if (null == m_csemstagedata)
  781. {
  782. log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetStageData Failed");
  783. return false;
  784. }
  785. m_cotsimgscanprm = m_cotsprogmgrparamfile.GetImageScanParam();
  786. if (null == m_cotsimgscanprm)
  787. {
  788. log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetImageScanParam Failed");
  789. return false;
  790. }
  791. m_cgenparam = m_cotsprogmgrparamfile.GetCommonParam();
  792. if (null == m_cgenparam)
  793. {
  794. log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetGenParam Failed");
  795. return false;
  796. }
  797. m_cotsimgprocprm = m_cotsprogmgrparamfile.GetImageProcParam();
  798. if (null == m_cotsimgprocprm)
  799. {
  800. log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetImageProcParam Failed");
  801. return false;
  802. }
  803. m_cotsxrayprm = m_cotsprogmgrparamfile.GetXRayParam();
  804. if (null == m_cotsxrayprm)
  805. {
  806. log.Error("(OTSProgMgrInfoFun.LoadParamFun) GetXRayParam Failed");
  807. return false;
  808. }
  809. return true;
  810. }
  811. #endregion
  812. #region 窗体加载
  813. private void ProgMgrInfoForm_Load(object sender, EventArgs e)
  814. {
  815. //加载各参数类
  816. LoadParamFun();
  817. //初始化combobox下拉框列表
  818. BindComboBox();
  819. //加载相关参数信息
  820. LoadDefaultParam();
  821. LoadSEMStageData();
  822. LoadImageScanPrm();
  823. LoadCGenParam();
  824. LoadImageProc();
  825. LoadXRayParam();
  826. if (m_b_checkstagefile == false)
  827. btnok.Enabled = true;
  828. else
  829. btnok.Enabled = false;
  830. if(m_cotsprogmgrparamfile.GetSysTypeName() == "IncA")
  831. {
  832. label42.Visible = true;
  833. IDC_COMBO_TECHNOLOGY.Visible = true;
  834. }
  835. else
  836. {
  837. label42.Visible = false;
  838. IDC_COMBO_TECHNOLOGY.Visible = false;
  839. }
  840. }
  841. #endregion
  842. #region 各按钮控件点击事件
  843. private void IDC_BUTTON_KLFX_Click(object sender, EventArgs e)
  844. {
  845. try
  846. {
  847. if (IDC_COMBO_STDSelect.Text != "NoSTDDB")
  848. {
  849. Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", Application.StartupPath + "\\Config\\SysData\\" + IDC_COMBO_STDSelect.Text+".db");
  850. p.WaitForExit();
  851. }
  852. else
  853. {
  854. string message = table["message55"].ToString();
  855. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  856. }
  857. }
  858. catch (Exception ex)
  859. {
  860. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  861. }
  862. }
  863. /// <summary>
  864. /// 弹出样品台管理窗体
  865. /// </summary>
  866. /// <param name="a_nPackId"></param>
  867. /// <param name="a_pStageFile"></param>
  868. /// <returns></returns>
  869. public void ShowStageDialogExport()
  870. {
  871. DlgStageMgr dlgStageMgr = new DlgStageMgr(m_cstagefile);
  872. dlgStageMgr.ShowDialog();
  873. return;
  874. }
  875. /// <summary>
  876. /// 保存样品台信息
  877. /// </summary>
  878. /// <returns></returns>
  879. public bool CStageFileClrSave()
  880. {
  881. if (m_cstagefile == null)
  882. {
  883. //报错
  884. log.Error("(OTSProgMgrInfoFun.CStageFileClrSave) Error saving sample station information!");
  885. }
  886. else
  887. {
  888. bool b_ret = m_cstagefile.Save();
  889. if (false == b_ret)
  890. {
  891. log.Error("(OTSProgMgrInfoFun.CStageFileClrSave) Error saving sample table information!");
  892. }
  893. }
  894. return false;
  895. }
  896. private void IDC_BUTTON_STAGE_Click(object sender, EventArgs e)
  897. {
  898. //弹出管理样品台管理窗体
  899. ShowStageDialogExport();
  900. //弹出后再保存样品台信息
  901. CStageFileClrSave();
  902. //刷新绑定样品台列表
  903. BindStageCombobox();
  904. //检测是否已经有修改
  905. ThisSetIsModify();
  906. }
  907. /// <summary>
  908. /// 判断各控件值是否正确
  909. /// </summary>
  910. /// <returns></returns>
  911. private bool CheckSetupValues(int bz)
  912. {
  913. if ("" == IDC_COMBO_STAGE.Text)
  914. {
  915. string message = table["message1"].ToString();
  916. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  917. IDC_COMBO_STAGE.Focus();
  918. IDC_COMBO_STAGE.SelectAll();
  919. return false;
  920. }
  921. if ("" == IDC_EDIT_SCREENWIDTH.Text)
  922. {
  923. string message = table["message2"].ToString();
  924. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  925. IDC_EDIT_SCREENWIDTH.Focus();
  926. IDC_EDIT_SCREENWIDTH.SelectAll();
  927. return false;
  928. }
  929. if ("" == IDC_COMBO_XDIREC.Text)
  930. {
  931. string message = table["message3"].ToString();
  932. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  933. IDC_COMBO_XDIREC.Focus();
  934. IDC_COMBO_XDIREC.SelectAll();
  935. return false;
  936. }
  937. if ("" == IDC_EDIT_XSTART.Text)
  938. {
  939. string message = table["message4"].ToString();
  940. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  941. IDC_EDIT_XSTART.Focus();
  942. IDC_EDIT_XSTART.SelectAll();
  943. return false;
  944. }
  945. if ("" == IDC_EDIT_XEND.Text)
  946. {
  947. string message = table["message4"].ToString();
  948. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  949. IDC_EDIT_XEND.Focus();
  950. IDC_EDIT_XEND.SelectAll();
  951. return false;
  952. }
  953. if ("" == IDC_COMBO_YDIRECT.Text)
  954. {
  955. string message = table["message5"].ToString();
  956. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  957. IDC_COMBO_YDIRECT.Focus();
  958. IDC_COMBO_YDIRECT.SelectAll();
  959. return false;
  960. }
  961. if ("" == IDC_EDIT_YSTART.Text)
  962. {
  963. string message = table["message6"].ToString();
  964. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  965. IDC_EDIT_YSTART.Focus();
  966. IDC_EDIT_YSTART.SelectAll();
  967. return false;
  968. }
  969. if ("" == IDC_EDIT_YEND.Text)
  970. {
  971. string message = table["message6"].ToString();
  972. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  973. IDC_EDIT_YEND.Focus();
  974. IDC_EDIT_YEND.SelectAll();
  975. return false;
  976. }
  977. if ("" == tB_StopMode.Text)
  978. {
  979. string message = table["message7"].ToString();
  980. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  981. //IDC_EDIT_STOP_TIME.Focus();
  982. //IDC_EDIT_STOP_TIME.SelectAll();
  983. return false;
  984. }
  985. if ("" == IDC_COMBO_FETCHIMGMODE.Text)
  986. {
  987. string message = table["message10"].ToString();
  988. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  989. IDC_COMBO_FETCHIMGMODE.Focus();
  990. IDC_COMBO_FETCHIMGMODE.SelectAll();
  991. return false;
  992. }
  993. if ("" == IDC_COMBO_IMGSCANSPEED.Text)
  994. {
  995. string message = table["message11"].ToString();
  996. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  997. IDC_COMBO_IMGSCANSPEED.Focus();
  998. IDC_COMBO_IMGSCANSPEED.SelectAll();
  999. return false;
  1000. }
  1001. if ("" == IDC_COMBO_IMGSIZE.Text)
  1002. {
  1003. string message = table["message12"].ToString();
  1004. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1005. IDC_COMBO_IMGSIZE.Focus();
  1006. IDC_COMBO_IMGSIZE.SelectAll();
  1007. return false;
  1008. }
  1009. if ("" == IDC_EDIT_MINMAG.Text)
  1010. {
  1011. string message = table["message13"].ToString();
  1012. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1013. IDC_EDIT_MINMAG.Focus();
  1014. IDC_EDIT_MINMAG.SelectAll();
  1015. return false;
  1016. }
  1017. if ("" == IDC_EDIT_PARTAREAMIN.Text)
  1018. {
  1019. string message = table["message14"].ToString();
  1020. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1021. IDC_EDIT_PARTAREAMIN.Focus();
  1022. IDC_EDIT_PARTAREAMIN.SelectAll();
  1023. return false;
  1024. }
  1025. if ("" == IDC_EDIT_PARTAREAMAX.Text)
  1026. {
  1027. string message = table["message15"].ToString();
  1028. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1029. IDC_EDIT_PARTAREAMAX.Focus();
  1030. IDC_EDIT_PARTAREAMAX.SelectAll();
  1031. return false;
  1032. }
  1033. if ("" == IDC_EDIT_BACKMIN.Text)
  1034. {
  1035. string message = table["message16"].ToString();
  1036. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1037. IDC_EDIT_BACKMIN.Focus();
  1038. IDC_EDIT_BACKMIN.SelectAll();
  1039. return false;
  1040. }
  1041. if ("" == IDC_EDIT_BACKMAX.Text)
  1042. {
  1043. string message = table["message17"].ToString();
  1044. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1045. IDC_EDIT_BACKMAX.Focus();
  1046. IDC_EDIT_BACKMAX.SelectAll();
  1047. return false;
  1048. }
  1049. if ("" == IDC_EDIT_PARTMIN.Text)
  1050. {
  1051. string message = table["message18"].ToString();
  1052. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1053. IDC_EDIT_PARTMIN.Focus();
  1054. IDC_EDIT_PARTMIN.SelectAll();
  1055. return false;
  1056. }
  1057. if ("" == IDC_EDIT_PARTMAX.Text)
  1058. {
  1059. string message = table["message19"].ToString();
  1060. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1061. IDC_EDIT_PARTMAX.Focus();
  1062. IDC_EDIT_PARTMAX.SelectAll();
  1063. return false;
  1064. }
  1065. if ("" == IDC_COMBO_XRAYSCANMODE.Text)
  1066. {
  1067. string message = table["message20"].ToString();
  1068. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1069. IDC_COMBO_XRAYSCANMODE.Focus();
  1070. IDC_COMBO_XRAYSCANMODE.SelectAll();
  1071. return false;
  1072. }
  1073. if ("" == IDC_EDIT_ANALYXRAYAIMVALUE.Text)
  1074. {
  1075. string message = table["message22"].ToString();
  1076. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1077. IDC_EDIT_ANALYXRAYAIMVALUE.Focus();
  1078. IDC_EDIT_ANALYXRAYAIMVALUE.SelectAll();
  1079. return false;
  1080. }
  1081. if ("" == tBMeasArea.Text)
  1082. {
  1083. string message = table["message62"].ToString();
  1084. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1085. tBMeasArea.Focus();
  1086. tBMeasArea.SelectAll();
  1087. return false;
  1088. }
  1089. //string pat = @"^(-|\+)?\d{1,8}$";//只能输入1到3位的正负整数
  1090. string pat = @"^-?[0-9]\d*$";//只能限定正负整数,包含0
  1091. string scope = @"^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$";
  1092. string PositiveDecimals = @"^(([1-9]\d*)(\.\d+)?)$|^0\.\d*[1-9]$"; //正浮点数
  1093. string positiveInteger = @"^?[0-9]\d*$";//只能限定正整数,包含0
  1094. string positiveOddNumber = @"[^1,3,5,7,9]";//只能限定正奇数
  1095. Regex rg = new Regex(pat);
  1096. Regex rgScope = new Regex(scope);
  1097. Regex rgPositiveDecimals = new Regex(PositiveDecimals);
  1098. Regex rgpositiveInteger = new Regex(positiveInteger);
  1099. Regex rgpositiveOddNumber = new Regex(positiveOddNumber);
  1100. //100倍时屏幕尺寸
  1101. if (false == rg.Match(IDC_EDIT_SCREENWIDTH.Text.Trim()).Success)
  1102. {
  1103. IDC_EDIT_SCREENWIDTH.Focus();
  1104. IDC_EDIT_SCREENWIDTH.SelectAll();
  1105. string message = table["message23"].ToString();
  1106. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1107. return false;
  1108. }
  1109. //x轴行程/mm 起
  1110. if (false == rg.Match(IDC_EDIT_XSTART.Text.Trim()).Success)
  1111. {
  1112. IDC_EDIT_XSTART.Focus();
  1113. IDC_EDIT_XSTART.SelectAll();
  1114. string message = table["message24"].ToString();
  1115. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1116. return false;
  1117. }
  1118. //x轴行程/mm 止
  1119. if (false == rg.Match(IDC_EDIT_XEND.Text.Trim()).Success)
  1120. {
  1121. IDC_EDIT_XEND.Focus();
  1122. IDC_EDIT_XEND.SelectAll();
  1123. string message = table["message25"].ToString();
  1124. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1125. return false;
  1126. }
  1127. //y轴行程/mm 起
  1128. if (false == rg.Match(IDC_EDIT_YSTART.Text.Trim()).Success)
  1129. {
  1130. IDC_EDIT_YSTART.Focus();
  1131. IDC_EDIT_YSTART.SelectAll();
  1132. string message = table["message26"].ToString();
  1133. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1134. return false;
  1135. }
  1136. //y轴行程/mm 止
  1137. if (false == rg.Match(IDC_EDIT_YEND.Text.Trim()).Success)
  1138. {
  1139. IDC_EDIT_YEND.Focus();
  1140. IDC_EDIT_YEND.SelectAll();
  1141. string message = table["message27"].ToString();
  1142. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1143. return false;
  1144. }
  1145. //颗粒面积范围 最小
  1146. if (false == rgPositiveDecimals.Match(IDC_EDIT_PARTAREAMIN.Text.Trim()).Success)
  1147. {
  1148. IDC_EDIT_PARTAREAMIN.Focus();
  1149. IDC_EDIT_PARTAREAMIN.SelectAll();
  1150. string message = table["message31"].ToString();
  1151. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1152. return false;
  1153. }
  1154. //颗粒面积范围 最大
  1155. if (false == rgPositiveDecimals.Match(IDC_EDIT_PARTAREAMAX.Text.Trim()).Success)
  1156. {
  1157. IDC_EDIT_PARTAREAMAX.Focus();
  1158. IDC_EDIT_PARTAREAMAX.SelectAll();
  1159. string message = table["message32"].ToString();
  1160. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1161. return false;
  1162. }
  1163. //背景灰度范围 最小
  1164. if (false == rg.Match(IDC_EDIT_BACKMIN.Text.Trim()).Success)
  1165. {
  1166. IDC_EDIT_BACKMIN.Focus();
  1167. IDC_EDIT_BACKMIN.SelectAll();
  1168. string message = table["message33"].ToString();
  1169. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1170. return false;
  1171. }
  1172. else
  1173. {
  1174. if (false == rgScope.Match(IDC_EDIT_BACKMIN.Text.Trim()).Success)
  1175. {
  1176. IDC_EDIT_BACKMIN.Focus();
  1177. IDC_EDIT_BACKMIN.SelectAll();
  1178. string message = table["message34"].ToString();
  1179. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1180. return false;
  1181. }
  1182. }
  1183. //背景灰度范围 最大
  1184. if (false == rg.Match(IDC_EDIT_BACKMAX.Text.Trim()).Success)
  1185. {
  1186. IDC_EDIT_BACKMAX.Focus();
  1187. IDC_EDIT_BACKMAX.SelectAll();
  1188. string message = table["message35"].ToString();
  1189. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1190. return false;
  1191. }
  1192. else
  1193. {
  1194. if (false == rgScope.Match(IDC_EDIT_BACKMAX.Text.Trim()).Success)
  1195. {
  1196. IDC_EDIT_BACKMAX.Focus();
  1197. IDC_EDIT_BACKMAX.SelectAll();
  1198. string message = table["message36"].ToString();
  1199. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1200. return false;
  1201. }
  1202. }
  1203. //颗粒灰度范围 最小
  1204. if (false == rg.Match(IDC_EDIT_PARTMIN.Text.Trim()).Success)
  1205. {
  1206. IDC_EDIT_PARTMIN.Focus();
  1207. IDC_EDIT_PARTMIN.SelectAll();
  1208. string message = table["message37"].ToString();
  1209. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1210. return false;
  1211. }
  1212. else
  1213. {
  1214. if (false == rgScope.Match(IDC_EDIT_PARTMIN.Text.Trim()).Success)
  1215. {
  1216. IDC_EDIT_PARTMIN.Focus();
  1217. IDC_EDIT_PARTMIN.SelectAll();
  1218. string message = table["message38"].ToString();
  1219. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1220. return false;
  1221. }
  1222. }
  1223. //颗粒灰度范围 最大
  1224. if (false == rg.Match(IDC_EDIT_PARTMAX.Text.Trim()).Success)
  1225. {
  1226. IDC_EDIT_PARTMAX.Focus();
  1227. IDC_EDIT_PARTMAX.SelectAll();
  1228. string message = table["message39"].ToString();
  1229. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1230. return false;
  1231. }
  1232. else
  1233. {
  1234. if (false == rgScope.Match(IDC_EDIT_PARTMAX.Text.Trim()).Success)
  1235. {
  1236. IDC_EDIT_PARTMAX.Focus();
  1237. IDC_EDIT_PARTMAX.SelectAll();
  1238. string message = table["message40"].ToString();
  1239. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1240. return false;
  1241. }
  1242. }
  1243. //分析X-ray计数期望值 最大
  1244. if (false == rg.Match(IDC_EDIT_ANALYXRAYAIMVALUE.Text.Trim()).Success)
  1245. {
  1246. IDC_EDIT_ANALYXRAYAIMVALUE.Focus();
  1247. IDC_EDIT_ANALYXRAYAIMVALUE.SelectAll();
  1248. string message = table["message41"].ToString();
  1249. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1250. return false;
  1251. }
  1252. //分析X-ray精度对应的时间
  1253. if (false == rg.Match(IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Text.Trim()).Success)
  1254. {
  1255. IDC_TEXTBOX_ANALYXRAYSPEED_TIME.Focus();
  1256. IDC_TEXTBOX_ANALYXRAYSPEED_TIME.SelectAll();
  1257. string message = table["message42"].ToString();
  1258. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1259. return false;
  1260. }
  1261. pat = @"^[0-9]+(\.[0-9]{1,3})?$"; //只能输入,1到3位小数的正数
  1262. rg = new Regex(pat);
  1263. //最小放大倍数
  1264. if (false == rg.Match(IDC_EDIT_MINMAG.Text.Trim()).Success)
  1265. {
  1266. IDC_EDIT_MINMAG.Focus();
  1267. IDC_EDIT_MINMAG.SelectAll();
  1268. string message = table["message43"].ToString();
  1269. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1270. return false;
  1271. }
  1272. //再限制,x轴,y轴,的起止的,输入长度,因为现在已经有在mm和um之间的转换,所以这里要限制一下
  1273. //x轴行程/mm 起
  1274. if (IDC_EDIT_XSTART.Text.Length > 4)
  1275. {
  1276. IDC_EDIT_XSTART.Focus();
  1277. IDC_EDIT_XSTART.SelectAll();
  1278. string message = table["message44"].ToString();
  1279. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1280. return false;
  1281. }
  1282. //x轴行程/mm 止
  1283. if (IDC_EDIT_XEND.Text.Length > 4)
  1284. {
  1285. IDC_EDIT_XEND.Focus();
  1286. IDC_EDIT_XEND.SelectAll();
  1287. string message = table["message45"].ToString();
  1288. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1289. return false;
  1290. }
  1291. //y轴行程/mm 起
  1292. if (IDC_EDIT_YSTART.Text.Length > 4)
  1293. {
  1294. IDC_EDIT_YSTART.Focus();
  1295. IDC_EDIT_YSTART.SelectAll();
  1296. string message = table["message46"].ToString();
  1297. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1298. return false;
  1299. }
  1300. //y轴行程/mm 止
  1301. if (IDC_EDIT_YEND.Text.Length > 4)
  1302. {
  1303. IDC_EDIT_YEND.Focus();
  1304. IDC_EDIT_YEND.SelectAll();
  1305. string message = table["message47"].ToString();
  1306. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1307. return false;
  1308. }
  1309. if (Convert.ToInt32(IDC_EDIT_XSTART.Text.Trim()) > Convert.ToInt32(IDC_EDIT_XEND.Text.Trim()))
  1310. {
  1311. IDC_EDIT_XEND.Focus();
  1312. IDC_EDIT_XEND.SelectAll();
  1313. string message = table["message50"].ToString();
  1314. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1315. return false;
  1316. }
  1317. if (Convert.ToInt32(IDC_EDIT_YSTART.Text.Trim()) > Convert.ToInt32(IDC_EDIT_YEND.Text.Trim()))
  1318. {
  1319. IDC_EDIT_YEND.Focus();
  1320. IDC_EDIT_YEND.SelectAll();
  1321. string message = table["message53"].ToString();
  1322. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1323. return false;
  1324. }
  1325. //颗粒尺寸范围
  1326. if (Convert.ToDouble(IDC_EDIT_PARTAREAMIN.Text.Trim()) > Convert.ToDouble(IDC_EDIT_PARTAREAMAX.Text.Trim()))
  1327. {
  1328. IDC_EDIT_PARTAREAMIN.Focus();
  1329. IDC_EDIT_PARTAREAMIN.SelectAll();
  1330. string message = table["message56"].ToString();
  1331. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1332. return false;
  1333. }
  1334. //背景灰度范围
  1335. if (Convert.ToInt32(IDC_EDIT_BACKMIN.Text.Trim()) > Convert.ToInt32(IDC_EDIT_BACKMAX.Text.Trim()))
  1336. {
  1337. IDC_EDIT_BACKMIN.Focus();
  1338. IDC_EDIT_BACKMIN.SelectAll();
  1339. string message = table["message57"].ToString();
  1340. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1341. return false;
  1342. }
  1343. //颗粒灰度范围
  1344. if (Convert.ToInt32(IDC_EDIT_PARTMIN.Text.Trim()) > Convert.ToInt32(IDC_EDIT_PARTMAX.Text.Trim()))
  1345. {
  1346. IDC_EDIT_PARTMIN.Focus();
  1347. IDC_EDIT_PARTMIN.SelectAll();
  1348. string message = table["message58"].ToString();
  1349. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1350. return false;
  1351. }
  1352. //最小放大倍数
  1353. if (false == rgpositiveInteger.Match(IDC_EDIT_XrayLimit.Text.Trim()).Success)
  1354. {
  1355. IDC_EDIT_XrayLimit.Focus();
  1356. IDC_EDIT_XrayLimit.SelectAll();
  1357. string message = table["message64"].ToString();
  1358. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1359. return false;
  1360. }
  1361. return true;
  1362. }
  1363. /// <summary>
  1364. /// 判断当前样品台是否在被修改
  1365. /// </summary>
  1366. /// <returns></returns>
  1367. public bool IsModified()
  1368. {
  1369. return m_cstagefile.IsModified();
  1370. }
  1371. /// <summary>
  1372. /// 样品台保存
  1373. /// </summary>
  1374. /// <returns></returns>
  1375. public bool StageSave()
  1376. {
  1377. if (!m_cstagefile.Save())
  1378. {
  1379. log.Error("(OTSProgMgrInfoFun.StageLoad) Failed to save sample station information!");
  1380. return false;
  1381. }
  1382. return true;
  1383. }
  1384. private void btnok_Click(object sender, EventArgs e)
  1385. {
  1386. //先判断
  1387. if (false == CheckSetupValues(1))
  1388. {
  1389. return;
  1390. }
  1391. //先把各个值都保存到各类
  1392. m_cotsprogmgrparamfile.m_runmode = (RunMode)IDC_COMBO_Model.SelectedIndex;
  1393. SaveSEMStageData();
  1394. SaveImageScanPrm();
  1395. SaveCGenParam();
  1396. SaveImageProc();
  1397. SaveXRayParam();
  1398. //然后再把各类传入到SaveInfoToProgMgrFile函数中
  1399. if (false == SaveInfoToProgMgrFile())
  1400. {
  1401. return;
  1402. }
  1403. //保存样品台到文件,在被修改时进行保存
  1404. if (true == IsModified())
  1405. {
  1406. if (true == StageSave())
  1407. {
  1408. this.DialogResult = DialogResult.OK;
  1409. this.Close();
  1410. return;
  1411. }
  1412. else
  1413. {
  1414. string message = table["message54"].ToString();
  1415. log.Error("(ProgMgrInfoForm.btnok_Click) " + message);
  1416. this.Close();
  1417. return;
  1418. }
  1419. }
  1420. }
  1421. //关闭窗体
  1422. private void btncancel_Click(object sender, EventArgs e)
  1423. {
  1424. this.Close();
  1425. }
  1426. #endregion
  1427. #region 选择样品台事件
  1428. private void IDC_COMBO_STAGE_SelectedIndexChanged(object sender, EventArgs e)
  1429. {
  1430. //样品台
  1431. if (!StageLoad())
  1432. {
  1433. this.Close();
  1434. return;//加载失败返回
  1435. }
  1436. ThisSetIsModify();
  1437. }
  1438. /// <summary>
  1439. /// 通过id设置当前正在工作的样品台
  1440. /// </summary>
  1441. /// <param name="id"></param>
  1442. public void SetWorkingStageId(int id)
  1443. {
  1444. m_cstagefile.SetWorkingStageId(id);
  1445. }
  1446. /// <summary>
  1447. /// 设置当前样品台正在被修改中
  1448. /// </summary>
  1449. /// <param name="yn"></param>
  1450. public void SetModify(bool yn)
  1451. {
  1452. m_cstagefile.SetModify(true);
  1453. }
  1454. /// <summary>
  1455. /// 设置当前窗体可以保存了
  1456. /// </summary>
  1457. private void ThisSetIsModify()
  1458. {
  1459. ComboBoxItem cbi = new ComboBoxItem();
  1460. if (IDC_COMBO_STAGE.Items.Count > 0)
  1461. if (null != IDC_COMBO_STAGE.SelectedItem)
  1462. {
  1463. cbi = (ComboBoxItem)IDC_COMBO_STAGE.SelectedItem;
  1464. SetWorkingStageId(Convert.ToInt32(cbi.Value));
  1465. SetModify(true);
  1466. btnok.Enabled = true;
  1467. }
  1468. }
  1469. #endregion
  1470. #region 监视控件改变状态事件
  1471. private void IDC_EDIT_SCREENWIDTH_TextChanged(object sender, EventArgs e)
  1472. {
  1473. ThisSetIsModify();
  1474. }
  1475. private void IDC_COMBO_XDIREC_SelectedIndexChanged(object sender, EventArgs e)
  1476. {
  1477. ThisSetIsModify();
  1478. }
  1479. private void IDC_EDIT_XSTART_TextChanged(object sender, EventArgs e)
  1480. {
  1481. ThisSetIsModify();
  1482. }
  1483. private void IDC_EDIT_XEND_TextChanged(object sender, EventArgs e)
  1484. {
  1485. ThisSetIsModify();
  1486. }
  1487. private void IDC_COMBO_YDIRECT_SelectedIndexChanged(object sender, EventArgs e)
  1488. {
  1489. ThisSetIsModify();
  1490. }
  1491. private void IDC_EDIT_YSTART_TextChanged(object sender, EventArgs e)
  1492. {
  1493. ThisSetIsModify();
  1494. }
  1495. private void IDC_EDIT_YEND_TextChanged(object sender, EventArgs e)
  1496. {
  1497. ThisSetIsModify();
  1498. }
  1499. private void IDC_EDIT_MINMAG_TextChanged(object sender, EventArgs e)
  1500. {
  1501. ThisSetIsModify();
  1502. }
  1503. private void IDC_COMBO_STOPMODE_SelectedIndexChanged(object sender, EventArgs e)
  1504. {
  1505. ThisSetIsModify();
  1506. }
  1507. private void IDC_EDIT_STOP_TIME_TextChanged(object sender, EventArgs e)
  1508. {
  1509. ThisSetIsModify();
  1510. }
  1511. private void IDC_EDIT_STOP_FIELD_NUM_TextChanged(object sender, EventArgs e)
  1512. {
  1513. ThisSetIsModify();
  1514. }
  1515. private void IDC_EDIT_STOP_INCA_NUM_TextChanged(object sender, EventArgs e)
  1516. {
  1517. ThisSetIsModify();
  1518. }
  1519. private void IDC_COMBO_FETCHIMGMODE_SelectedIndexChanged(object sender, EventArgs e)
  1520. {
  1521. ThisSetIsModify();
  1522. }
  1523. private void IDC_COMBO_IMGSCANSPEED_SelectedIndexChanged(object sender, EventArgs e)
  1524. {
  1525. ThisSetIsModify();
  1526. }
  1527. private void IDC_COMBO_IMGSIZE_SelectedIndexChanged(object sender, EventArgs e)
  1528. {
  1529. ThisSetIsModify();
  1530. }
  1531. private void IDC_EDIT_SAMPLENAME_TextChanged(object sender, EventArgs e)
  1532. {
  1533. ThisSetIsModify();
  1534. }
  1535. private void IDC_MEAS_SWITCH_CheckedChanged(object sender, EventArgs e)
  1536. {
  1537. ThisSetIsModify();
  1538. }
  1539. private void IDC_EDIT_MEASUREPARAMPATH_TextChanged(object sender, EventArgs e)
  1540. {
  1541. ThisSetIsModify();
  1542. }
  1543. private void IDC_EDIT_ANALYSESTDLIBPATH_TextChanged(object sender, EventArgs e)
  1544. {
  1545. ThisSetIsModify();
  1546. }
  1547. private void IDC_EDIT_STDLIBNAME_TextChanged(object sender, EventArgs e)
  1548. {
  1549. ThisSetIsModify();
  1550. }
  1551. private void IDC_EDIT_PARTAREAMIN_TextChanged(object sender, EventArgs e)
  1552. {
  1553. ThisSetIsModify();
  1554. }
  1555. private void IDC_EDIT_PARTAREAMAX_TextChanged(object sender, EventArgs e)
  1556. {
  1557. ThisSetIsModify();
  1558. }
  1559. private void IDC_EDIT_BACKMIN_TextChanged(object sender, EventArgs e)
  1560. {
  1561. ThisSetIsModify();
  1562. }
  1563. private void IDC_EDIT_BACKMAX_TextChanged(object sender, EventArgs e)
  1564. {
  1565. ThisSetIsModify();
  1566. }
  1567. private void IDC_EDIT_PARTMIN_TextChanged(object sender, EventArgs e)
  1568. {
  1569. ThisSetIsModify();
  1570. }
  1571. private void IDC_EDIT_PARTMAX_TextChanged(object sender, EventArgs e)
  1572. {
  1573. ThisSetIsModify();
  1574. }
  1575. private void IDC_COMBO_AUTOBGREMOVETYPE_SelectedIndexChanged(object sender, EventArgs e)
  1576. {
  1577. ThisSetIsModify();
  1578. }
  1579. private void IDC_COMBO_BGREMOVETYPE_SelectedIndexChanged(object sender, EventArgs e)
  1580. {
  1581. ComboBox cbBGREMOVETYPE = (ComboBox)sender;
  1582. int selectValue=Convert.ToInt32(((OTSMeasureApp.ComboBoxItem)cbBGREMOVETYPE.Items[cbBGREMOVETYPE.SelectedIndex]).Value);
  1583. if (selectValue == (int)otsdataconst.OTS_AUTOBGREMOVETYPE.MANUAL)
  1584. {
  1585. IDC_COMBO_AUTOBGREMOVETYP.Enabled = false;
  1586. }
  1587. else
  1588. {
  1589. IDC_COMBO_AUTOBGREMOVETYP.Enabled = true;
  1590. }
  1591. ThisSetIsModify();
  1592. }
  1593. private void IDC_COMBO_SEARCHXRAYSPEED_SelectedIndexChanged(object sender, EventArgs e)
  1594. {
  1595. ThisSetIsModify();
  1596. }
  1597. private void IDC_EDIT_SEARCHXRAYCOUNTLIMIT_TextChanged(object sender, EventArgs e)
  1598. {
  1599. ThisSetIsModify();
  1600. }
  1601. private void IDC_COMBO_XRAYSCANMODE_SelectedIndexChanged(object sender, EventArgs e)
  1602. {
  1603. ThisSetIsModify();
  1604. }
  1605. private void IDC_COMBO_ANALYXRAYSPEED_SelectedIndexChanged(object sender, EventArgs e)
  1606. {
  1607. ThisSetIsModify();
  1608. }
  1609. private void IDC_EDIT_ANALYXRAYAIMVALUE_TextChanged(object sender, EventArgs e)
  1610. {
  1611. ThisSetIsModify();
  1612. }
  1613. private void IDC_COMBO_TECHNOLOGY_SelectedIndexChanged(object sender, EventArgs e)
  1614. {
  1615. ThisSetIsModify();
  1616. }
  1617. private void IDC_STOP_MODE_SWITCH_CheckedChanged(object sender, EventArgs e)
  1618. {
  1619. ThisSetIsModify();
  1620. }
  1621. private void IDC_STOP_TIME_SWITCH_CheckedChanged(object sender, EventArgs e)
  1622. {
  1623. ThisSetIsModify();
  1624. }
  1625. private void IDC_STOP_FIELD_SWITCH_CheckedChanged(object sender, EventArgs e)
  1626. {
  1627. ThisSetIsModify();
  1628. }
  1629. private void IDC_STOP_PARTICAL_SWITCH_CheckedChanged(object sender, EventArgs e)
  1630. {
  1631. ThisSetIsModify();
  1632. }
  1633. private void IDC_FETCH_IMAGE_SWITCH_CheckedChanged(object sender, EventArgs e)
  1634. {
  1635. ThisSetIsModify();
  1636. }
  1637. private void IDC_SCAN_SPEED_SWITCH_CheckedChanged(object sender, EventArgs e)
  1638. {
  1639. ThisSetIsModify();
  1640. }
  1641. private void IDC_IMAGE_SIZE_SWITCH_CheckedChanged(object sender, EventArgs e)
  1642. {
  1643. ThisSetIsModify();
  1644. }
  1645. private void IDC_PART_MIN_SWITCH_CheckedChanged(object sender, EventArgs e)
  1646. {
  1647. ThisSetIsModify();
  1648. }
  1649. private void IDC_PART_MAX_SWITCH_CheckedChanged(object sender, EventArgs e)
  1650. {
  1651. ThisSetIsModify();
  1652. }
  1653. private void IDC_BACK_MIN_SWITCH_CheckedChanged(object sender, EventArgs e)
  1654. {
  1655. ThisSetIsModify();
  1656. }
  1657. private void IDC_BACK_MAX_SWITCH_CheckedChanged(object sender, EventArgs e)
  1658. {
  1659. ThisSetIsModify();
  1660. }
  1661. private void IDC_PART_GRAY_SWITCH_CheckedChanged(object sender, EventArgs e)
  1662. {
  1663. ThisSetIsModify();
  1664. }
  1665. private void IDC_PART_GRAY_MAX_CheckedChanged(object sender, EventArgs e)
  1666. {
  1667. ThisSetIsModify();
  1668. }
  1669. private void IDC_XRAY_MODE_SWITCH_CheckedChanged(object sender, EventArgs e)
  1670. {
  1671. ThisSetIsModify();
  1672. }
  1673. private void IDC_XRAY_TIME_SWITCH_CheckedChanged(object sender, EventArgs e)
  1674. {
  1675. ThisSetIsModify();
  1676. }
  1677. private void IDC_XRAY_COUNT_SWITCH_CheckedChanged(object sender, EventArgs e)
  1678. {
  1679. ThisSetIsModify();
  1680. }
  1681. private void cBMeasShape_SelectedIndexChanged(object sender, EventArgs e)
  1682. {
  1683. ThisSetIsModify();
  1684. }
  1685. private void tBMeasArea_TextChanged(object sender, EventArgs e)
  1686. {
  1687. ThisSetIsModify();
  1688. }
  1689. private void IDC_SYS_LIB_CheckedChanged(object sender, EventArgs e)
  1690. {
  1691. ThisSetIsModify();
  1692. }
  1693. #endregion
  1694. private void IDC_COMBO_STDSelect_SelectedIndexChanged(object sender, EventArgs e)
  1695. {
  1696. ThisSetIsModify();
  1697. }
  1698. private void IDC_COMBO_USINGXRAYS_SelectedIndexChanged(object sender, EventArgs e)
  1699. {
  1700. ThisSetIsModify();
  1701. }
  1702. private void IDC_COMBO_Model_SelectedIndexChanged(object sender, EventArgs e)
  1703. {
  1704. ThisSetIsModify();
  1705. }
  1706. private void btn_StopMode_Click(object sender, EventArgs e)
  1707. {
  1708. if (StopModeDialog == null)
  1709. {
  1710. StopModeDialog = new frmMeasureStopMode();
  1711. StopModeDialog.FieldMode = m_cotsimgscanprm.GetStopParamFields();
  1712. StopModeDialog.TimeMode = m_cotsimgscanprm.GetStopParamMeasTime();
  1713. StopModeDialog.ParticleMode = m_cotsimgscanprm.GetStopParamParticles();
  1714. StopModeDialog.AreaMode = m_cotsimgscanprm.GetStopParamArea();
  1715. StopModeDialog.StopMode = tB_StopMode.Text;
  1716. }
  1717. DialogResult result = StopModeDialog.ShowDialog();
  1718. if (result == DialogResult.OK)
  1719. {
  1720. string[] rst = StopModeDialog.StopMode.Split(',');
  1721. string str = "";
  1722. for (int k = 0; k < rst.Length; k++)
  1723. {
  1724. str += rst[k].Split(':')[0] + " + ";
  1725. }
  1726. tB_StopMode.Text = str.Substring(0, str.Length - 3);
  1727. }
  1728. }
  1729. private void IDC_COMBO_CorrosionExpansionCoefficient_TextChanged(object sender, EventArgs e)
  1730. {
  1731. ThisSetIsModify();
  1732. }
  1733. private void button_SpPart_Click(object sender, EventArgs e)
  1734. {
  1735. }
  1736. private void checkBox_Run_CheckedChanged(object sender, EventArgs e)
  1737. {
  1738. }
  1739. private void btn_otherselection_Click(object sender, EventArgs e)
  1740. {
  1741. if (otherSelectionForm == null)
  1742. {
  1743. otherSelectionForm = new _7_OTSProgMgrInfo.OtherSelectionForm();
  1744. otherSelectionForm.OtherSelection = m_cotsimgprocprm.GetParticleSelectCondition();
  1745. }
  1746. DialogResult result = otherSelectionForm.ShowDialog();
  1747. if (result == DialogResult.OK)
  1748. {
  1749. m_cotsimgprocprm.SetParticleSelectCondition(otherSelectionForm.OtherSelection);
  1750. if (otherSelectionForm.OtherSelection == "")
  1751. {
  1752. IDC_EDIT_OTHERSELECTION.Text = "NoFilter";
  1753. }
  1754. else
  1755. {
  1756. IDC_EDIT_OTHERSELECTION.Text = otherSelectionForm.OtherSelection;
  1757. }
  1758. }
  1759. }
  1760. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  1761. {
  1762. if (radioButton1.Checked)
  1763. {
  1764. elementchoose.Enabled = false;
  1765. }
  1766. }
  1767. int ReturnsAtomicNumberByElementName(string ElementName)
  1768. {
  1769. switch (ElementName)
  1770. {
  1771. case "H": return 1;
  1772. case "He": return 2;
  1773. case "Li": return 3;
  1774. case "Be": return 4;
  1775. case "B": return 5;
  1776. case "C": return 6;
  1777. case "N": return 7;
  1778. case "O": return 8;
  1779. case "F": return 9;
  1780. case "Ne": return 10;
  1781. case "Na": return 11;
  1782. case "Mg": return 12;
  1783. case "Al": return 13;
  1784. case "Si": return 14;
  1785. case "P": return 15;
  1786. case "S": return 16;
  1787. case "Cl": return 17;
  1788. case "Ar": return 18;
  1789. case "K": return 19;
  1790. case "Ca": return 20;
  1791. case "Sc": return 21;
  1792. case "Ti": return 22;
  1793. case "V": return 23;
  1794. case "Cr": return 24;
  1795. case "Mn": return 25;
  1796. case "Fe": return 26;
  1797. case "Co": return 27;
  1798. case "Ni": return 28;
  1799. case "Cu": return 29;
  1800. case "Zn": return 30;
  1801. case "Ga": return 31;
  1802. case "Ge": return 32;
  1803. case "As": return 33;
  1804. case "Se": return 34;
  1805. case "Br": return 35;
  1806. case "Kr": return 36;
  1807. case "Rb": return 37;
  1808. case "Sr": return 38;
  1809. case "Y": return 39;
  1810. case "Zr": return 40;
  1811. case "Nb": return 41;
  1812. case "Mo": return 42;
  1813. case "Tc": return 43;
  1814. case "Ru": return 44;
  1815. case "Rh": return 45;
  1816. case "Pd": return 46;
  1817. case "Ag": return 47;
  1818. case "Cd": return 48;
  1819. case "In": return 49;
  1820. case "Sn": return 50;
  1821. case "Sb": return 51;
  1822. case "Te": return 52;
  1823. case "I": return 53;
  1824. case "Xe": return 54;
  1825. case "Cs": return 55;
  1826. case "Ba": return 56;
  1827. case "La": return 57;
  1828. case "Ce": return 58;
  1829. case "Pr": return 59;
  1830. case "Nd": return 60;
  1831. case "Pm": return 61;
  1832. case "Sm": return 62;
  1833. case "Eu": return 63;
  1834. case "Gd": return 64;
  1835. case "Tb": return 65;
  1836. case "Dy": return 66;
  1837. case "Ho": return 67;
  1838. case "Er": return 68;
  1839. case "Tm": return 69;
  1840. case "Yb": return 70;
  1841. case "Lu": return 71;
  1842. case "Hf": return 72;
  1843. case "Ta": return 73;
  1844. case "W": return 74;
  1845. case "Re": return 75;
  1846. case "Os": return 76;
  1847. case "Ir": return 77;
  1848. case "Pt": return 78;
  1849. case "Au": return 79;
  1850. case "Hq": return 80;
  1851. case "TI": return 81;
  1852. case "Pb": return 82;
  1853. case "Bi": return 83;
  1854. case "Po": return 84;
  1855. case "At": return 85;
  1856. case "Rn": return 86;
  1857. case "Fr": return 87;
  1858. case "Ra": return 88;
  1859. case "Ac": return 89;
  1860. case "Th": return 90;
  1861. case "Pa": return 91;
  1862. case "U": return 92;
  1863. case "Np": return 93;
  1864. case "Pu": return 94;
  1865. case "Am": return 95;
  1866. case "Cm": return 96;
  1867. case "Bk": return 97;
  1868. case "Cf": return 98;
  1869. case "Es": return 99;
  1870. case "Fm": return 100;
  1871. case "Mc": return 101;
  1872. case "No": return 102;
  1873. case "Lr": return 103;
  1874. case "Rf": return 104;
  1875. case "Db": return 105;
  1876. case "Sg": return 106;
  1877. case "Bh": return 107;
  1878. case "Hs": return 108;
  1879. case "Mt": return 109;
  1880. case "Ds": return 110;
  1881. case "Rg": return 111;
  1882. case "Unb": return 112;
  1883. default: return 1000;
  1884. }
  1885. }
  1886. private void button1_Click(object sender, EventArgs e)
  1887. {
  1888. OTSPeriodicTable.OTSPeriodicTableForm_Small opts = new OTSPeriodicTable.OTSPeriodicTableForm_Small();
  1889. //获取需要显示的元素列表,并转换成元素周期表窗体可接受的格式,传入----------------------
  1890. string str_xsys = tb_xsys.Text.Trim();
  1891. List<string> list_str = new List<string>();
  1892. string[] strs = str_xsys.Split(',');
  1893. for (int i = 0; i < strs.Length; i++)
  1894. {
  1895. list_str.Add(strs[i]);
  1896. }
  1897. //清除元素周期表中所有的记录
  1898. opts.m_List_Periodic.Clear();
  1899. //将该分类下的元素添加到元素周期表窗体的List_periodic中
  1900. for (int i = 0; i < strs.Length; i++)
  1901. {
  1902. string str_ysm = strs[i];
  1903. Periodic ls_periodic = new Periodic();
  1904. ls_periodic = CListPeriodic.GetPeriodicByEleName(str_ysm);
  1905. opts.m_List_Periodic.Add(ls_periodic);
  1906. }
  1907. //----------------------------------------------------------------------------------------
  1908. opts.StartPosition = FormStartPosition.CenterScreen;
  1909. opts.ShowDialog();
  1910. List<string> PeriodicFH = new List<string>();
  1911. for (int j = 0; j < opts.m_List_Periodic.Count; j++)
  1912. {
  1913. PeriodicFH.Add(opts.m_List_Periodic[j].Symbol);
  1914. }
  1915. PeriodicFH.Sort(delegate (string a, string b) { return ReturnsAtomicNumberByElementName(a).CompareTo(ReturnsAtomicNumberByElementName(b)); });//排序 从小到大原子序数
  1916. list_str = list_str.FindAll(delegate (string a) { return PeriodicFH.Contains(a); });
  1917. PeriodicFH = PeriodicFH.FindAll(delegate (string a) { return !list_str.Contains(a); });
  1918. //先清空元素
  1919. str_xsys = "";
  1920. //然后再将选择的元素,组合起来,返回显示到该窗体上
  1921. for (int i = 0; i < list_str.Count; i++)
  1922. {
  1923. if (str_xsys == "")
  1924. {
  1925. str_xsys = list_str[i];
  1926. }
  1927. else
  1928. {
  1929. str_xsys = str_xsys + "," + list_str[i];
  1930. }
  1931. }
  1932. for (int i = 0; i < PeriodicFH.Count; i++)
  1933. {
  1934. if (str_xsys == "")
  1935. {
  1936. str_xsys = PeriodicFH[i];
  1937. }
  1938. else
  1939. {
  1940. str_xsys = str_xsys + "," + PeriodicFH[i];
  1941. }
  1942. }
  1943. //再对选择的元素进行显示
  1944. tb_xsys.Text = str_xsys;
  1945. }
  1946. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  1947. {
  1948. if (radioButton2.Checked)
  1949. {
  1950. elementchoose.Enabled = true;
  1951. }
  1952. }
  1953. }
  1954. public class ComboBoxItem
  1955. {
  1956. private string _text = null;
  1957. private object _value = null;
  1958. public string Text { get { return this._text; } set { this._text = value; } }
  1959. public object Value { get { return this._value; } set { this._value = value; } }
  1960. public override string ToString()
  1961. {
  1962. return this._text;
  1963. }
  1964. }
  1965. }