ProgMgrInfoForm.cs 84 KB

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