OTSIncAMeasureAppForm.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using OTS.WinFormsUI.Docking;
  6. using System.Runtime.InteropServices;
  7. using System.Collections;
  8. using CefSharp;
  9. using OTSDataType;
  10. using OTSModelSharp;
  11. using OTSModelSharp.ResourceManage;
  12. using static OTSDataType.otsdataconst;
  13. using System.Diagnostics;
  14. using OTSModelSharp.ServiceCenter;
  15. using OTSMeasureApp._0_OTSModel.Measure.ParamData;
  16. using OTSCLRINTERFACE;
  17. using System.IO;
  18. using System.Management;
  19. using System.Xml;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Runtime.Remoting.Channels.Ipc;
  23. using System.Runtime.Remoting.Channels;
  24. using System.Runtime.Remoting;
  25. using OTSMeasureApp.ServiceCenter;
  26. namespace OTSMeasureApp
  27. {
  28. public enum ShapeType
  29. {
  30. CIRCUL = 0, //圆形
  31. RECTANGLE = 1 //矩形
  32. };
  33. enum MessageBoxRev
  34. {
  35. DIALOG_YES = 0,
  36. DIALOG_NO = 1,
  37. DIALOG_CANCEL = 2
  38. }
  39. public partial class OTSIncAMeasureAppForm : Form
  40. {
  41. public static string m_SamplespaceWindowName = "样品台";
  42. public static string m_MeasureStauWindowName = "测量状态";
  43. public static string m_MeasureRetWindowName = "测量结果";
  44. public static string m_NoWindowName = "未知工作窗口";
  45. //国际化
  46. OTSCommon.Language lan;
  47. Hashtable table;
  48. public OTSRibbonFun m_RibbonFun = null;
  49. // 初始化日志类
  50. NLog.Logger log ;
  51. private PostLogMsg m_LogMsg;
  52. public const int MsgID = 0x0464;
  53. public const int LogMsgID = 0x0465;
  54. // Control m_ControlWindow = null;
  55. public OTSMeasureResultWindow m_MeasureRetWindow = null;
  56. public OTSMeasureStatusWindow m_MessureStatuWindow = null;
  57. public OTSSamplespaceWindow m_SamplepaceWindow = null;
  58. public OTSMeasureOutputNlog m_OTSMeasureOutputNlog = null;
  59. public COTSMeasureParam m_ProjParam = null;
  60. public COTSMsrPrjResultData m_ProjData;
  61. public OTSSolutionWindow m_SolutionWindows = null;
  62. public OTSPropertyWindow m_SPropertyWindows = null;
  63. //测量线程对象
  64. public CMeasureThreadWrapper m_MsrThreadWrapper = null;
  65. // 测量线程当前状态 True: 正在测量; False: 测量结束
  66. public bool MeasureThreadRunFlag { get => m_MsrThreadWrapper.BGWorkThreadIsRunning(); }
  67. public MSR_RUN_TYPE GetRunType()
  68. {
  69. return m_MsrThreadWrapper.GetDoRunType();
  70. }
  71. public void SetRunType(MSR_RUN_TYPE value)
  72. {
  73. m_MsrThreadWrapper.SetDoRunType(value);
  74. }
  75. public FileSystemWatcher fileWatcher = new FileSystemWatcher(Application.StartupPath+ @"\Config\SysData");
  76. public OTSIncAMeasureAppForm()
  77. {
  78. InitializeComponent();
  79. //国际化
  80. lan = new OTSCommon.Language(this);
  81. table = lan.GetNameTable(this.Name);
  82. m_SamplespaceWindowName = table["m_samplespacewindowname"].ToString();
  83. m_MeasureStauWindowName = table["m_measurestauwindowname"].ToString();
  84. m_MeasureRetWindowName = table["m_measureretwindowname"].ToString();
  85. m_NoWindowName = table["m_nowindowname"].ToString();
  86. m_OTSMeasureOutputNlog = new OTSMeasureOutputNlog();
  87. m_OTSMeasureOutputNlog.Show();
  88. // 初始化Docpanle
  89. m_SolutionWindows = new OTSSolutionWindow(this);
  90. m_SPropertyWindows = new OTSPropertyWindow(this);
  91. m_MeasureRetWindow = new OTSMeasureResultWindow(this);
  92. m_MeasureRetWindow.Text = m_MeasureRetWindowName;
  93. m_MessureStatuWindow = new OTSMeasureStatusWindow(this);
  94. m_MessureStatuWindow.Text = m_MeasureStauWindowName;
  95. m_SamplepaceWindow = new OTSSamplespaceWindow(this);
  96. m_SamplepaceWindow.Text = m_SamplespaceWindowName;
  97. //和DataMgr进行数据交互类
  98. m_ProjParam = new COTSMeasureParam(this);
  99. m_ProjData = m_ProjParam.GetResultData();
  100. //初始化Ribbon类,操作Ribbon按钮的可用或者不可用
  101. m_RibbonFun = new OTSRibbonFun(this);
  102. //初始化测量线程
  103. m_MsrThreadWrapper = new CMeasureThreadWrapper(this);//must be the last sentence of this procedure.
  104. fileWatcher.Changed += FileWatcher_Changed;
  105. fileWatcher.EnableRaisingEvents=true;
  106. }
  107. private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
  108. {
  109. if (e.Name == "SpecialGrayConfig.xml")
  110. {
  111. m_ProjParam.SpecialRanges.IsInited = false;
  112. foreach (var s in this.m_ProjData.GetSampleList())
  113. {
  114. s.GetMsrParams().GetSpecialGrayRangeParam().IsInited = false;
  115. }
  116. }
  117. }
  118. private void OTSIncAMeasureAppForm_Load(object sender, EventArgs e)
  119. {
  120. try
  121. {
  122. ArrangWorkspaceWindow();
  123. log = NLog.LogManager.GetCurrentClassLogger();
  124. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  125. {
  126. m_ProjParam.LoadSpecialGrayRangeParamFile();
  127. if (m_ProjParam.InitResultData())
  128. {
  129. m_RibbonFun.SetAllRibbonButnStatus(true);
  130. m_SamplepaceWindow.InitStageDisplay(m_ProjData.GetStage(),m_ProjData.GetSEMStageData());
  131. //添加启动系统界面显示
  132. if (m_ProjParam.GetDefaultParam().m_systemTypeId == OTS_SysType_ID.IncA)
  133. {
  134. this.Text += "(Inclusion)";
  135. }
  136. else if (m_ProjParam.GetDefaultParam().m_systemTypeId == OTS_SysType_ID.CleannessA)
  137. {
  138. this.Text += "(Cleanness)";
  139. }
  140. else if (m_ProjParam.GetDefaultParam().m_systemTypeId == OTS_SysType_ID.MiningA)
  141. {
  142. this.Text += "(Mining)";
  143. }
  144. }
  145. else
  146. {
  147. log.Error(" InitResultData() failed");
  148. }
  149. }
  150. else
  151. {
  152. log.Error("(OTSIncAMeasureAppForm.OTSIncAMeasureAppForm_Load) (LoadParamFile() && LoadStageParamFile()) failed");
  153. }
  154. if (!m_MsrThreadWrapper.ConnectSEM())
  155. {
  156. MessageBox.Show("Connect SEM failed!Please goto the SysMgrApp.exe to setup the proper parameter or check other parameter of the EDS software");
  157. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  158. process.FileName = "OTSSysMgrApp.exe";//打开app的路径
  159. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  160. System.Diagnostics.Process.Start(process);
  161. this.rbConnectHardware.Enabled = true;
  162. this.rbDisconnectHardware.Enabled = false;
  163. }
  164. this.rbConnectHardware.Enabled = false;
  165. this.rbDisconnectHardware.Enabled = true;
  166. log.Warn("SEM connect success!");
  167. PrepareIpcServer();
  168. log.Info("Ipc server start success!");
  169. //----------------------Test Code, Don't delete
  170. //var f = new BaseFunctionTest();
  171. //f.ShowDialog();
  172. //----------------------
  173. }
  174. catch (Exception ex)
  175. {
  176. log.Error(" OTSIncAMeasureAppForm_Load:" + ex.ToString());
  177. }
  178. }
  179. public void ArrangWorkspaceWindow()
  180. {
  181. //Show 样品台窗口
  182. m_SamplepaceWindow.Show(dockPanel);
  183. //Show 测量状态窗口
  184. m_MessureStatuWindow.Show(dockPanel);
  185. //Show 测量结果窗口
  186. m_MeasureRetWindow.Show(dockPanel);
  187. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  188. //Show 测量过程中Log显示窗口
  189. m_OTSMeasureOutputNlog.Show(dockPanel, DockState.DockRight);
  190. dockPanel.DockRightPortion = 365;
  191. m_SPropertyWindows.Show(dockPanel);
  192. m_SamplepaceWindow.Activate();
  193. }
  194. private void rbReport_Click(object sender, EventArgs e)
  195. {
  196. //测量结果文件路径列表
  197. List<string> mrFilePathList = new List<string>();
  198. //获取测量结果文件路径列表
  199. bool result = m_ProjParam.GetCompletedMeasureFileName(ref mrFilePathList);
  200. if (result)
  201. {
  202. for (int i = 0; i < mrFilePathList.Count; i++)
  203. {
  204. mrFilePathList[i] = mrFilePathList[i].Replace(" ", "^");
  205. }
  206. //转换为数组
  207. string[] resultFilePath = mrFilePathList.ToArray();
  208. System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo();
  209. process.FileName = "OTSIncAReportApp.exe";//打开app的路径
  210. string FilePath = string.Join(" ", resultFilePath);
  211. process.Arguments = FilePath;//多个参数用空格隔开
  212. process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  213. System.Diagnostics.Process.Start(process);
  214. }
  215. }
  216. // sNewWorkSampleName: 新工作样品名
  217. public void SwitchWSample(string sNewWorkSampleName)
  218. {
  219. m_ProjParam.SetWorkSample(sNewWorkSampleName);
  220. m_SolutionWindows.SwitchSample(sNewWorkSampleName);
  221. //获取新工作样品属性值
  222. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  223. m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo);
  224. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  225. //发送想你的样品名给Sample
  226. m_SamplepaceWindow.SwitchWorkSample(sNewWorkSampleName);
  227. }
  228. public void Rev_SoluWindowReqCheckBosStatuChange_Event(string sSampleName, bool bCheckBoxStatu)
  229. {
  230. string sWSampleName = m_ProjParam.GetWorkSampleName();
  231. if ("" == sWSampleName)
  232. {
  233. //不修改Tteeview 的工作样品属性值
  234. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  235. return;
  236. }
  237. //Treeview更改的工作样品数的CHECKBOX 状态
  238. if (!m_ProjParam.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH, OTS_ITEM_TYPES.BOOL, bCheckBoxStatu))
  239. {
  240. //不修改Tteeview 的工作样品属性值
  241. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(sSampleName, !bCheckBoxStatu);
  242. return;
  243. }
  244. // 设置 开始 ,停止 和检查参数 按钮状态
  245. m_RibbonFun.SetMeasureRibbonButnStatu();
  246. //修改Grid工作样品的SWITCH值
  247. OTSSamplePropertyInfo SMeasurenfo = new OTSSamplePropertyInfo();
  248. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMeasurenfo))
  249. {
  250. return;
  251. }
  252. m_SPropertyWindows.DisplaySampleMeasureInfo(SMeasurenfo);
  253. }
  254. public bool EditWorkSampleName(string sSampleOldName, string sSampleNewName)
  255. {
  256. if (!m_ProjParam.ChangeWorkSampleName(sSampleNewName))
  257. {
  258. return false;
  259. }
  260. // 获取修改名称后的工作样品属性值
  261. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  262. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  263. {
  264. return false;
  265. }
  266. //获取修改名称后的工作样品属性值发送给Grid显示
  267. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  268. //给样品台发送新的工作样品名称
  269. m_SamplepaceWindow.ChangeWorkSampleName(sSampleNewName);
  270. return true;
  271. }
  272. public void SoluwindowReqAddSample()
  273. {
  274. //Treeview右键点击添加新样品
  275. this.AddNewSampleMeasure();
  276. }
  277. private void OTSIncAMeasureAppForm_FormClosing(object sender, FormClosingEventArgs e)
  278. {
  279. try
  280. {
  281. if (m_MsrThreadWrapper.BGWorkThreadIsRunning ()) //当前正在测量
  282. {
  283. e.Cancel = true;
  284. return;
  285. }
  286. if (m_MsrThreadWrapper.IsHavingNotCompleteSamples()) //当前正在测量
  287. {
  288. e.Cancel = true;
  289. MessageBox.Show("There is one sample is still in pausing state,please stop it!");
  290. return;
  291. }
  292. //判断测量结果文件修改后是否保存
  293. if (m_ProjData.IsModified())
  294. {
  295. string message = table["message2"].ToString();
  296. DialogResult lsdr = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
  297. if (lsdr == DialogResult.Yes)
  298. {
  299. //保存,退出
  300. m_ProjData.Save();
  301. //保存,直接退出
  302. Application.ExitThread();
  303. }
  304. else if (lsdr == DialogResult.No)
  305. {
  306. //不保存,直接退出
  307. Application.ExitThread();
  308. }
  309. else if (lsdr == DialogResult.Cancel)
  310. {
  311. //取消
  312. e.Cancel = true;
  313. return;
  314. }
  315. }
  316. log.Info("Disconnect SEM!");
  317. m_MsrThreadWrapper.DisconnectSEM();
  318. m_MsrThreadWrapper.SetWorkThreadPending();
  319. }
  320. catch (Exception ex)
  321. {
  322. string message = table["message3"].ToString();
  323. log.Error("OTSIncAMeasureAppForm_FormClosing-"+ message + ":" + ex.ToString());
  324. }
  325. Process.GetCurrentProcess().Kill();
  326. }
  327. //打开指定路径的文件
  328. private void ribbonOrbMenuItem1_OpenWorkspace_Click(object sender, EventArgs e)
  329. {
  330. OpenMeasureProjectFile();
  331. //UpdatePropertyVal();
  332. }
  333. //新建样品工作文件
  334. private void ribbonOrbMenuItem3_CreateWorkspace_Click(object sender, EventArgs e)
  335. {
  336. int iCreateNewFileResult = m_ProjParam.CreateNewFile();
  337. if (iCreateNewFileResult == 0)
  338. {
  339. log.Error("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Failed !");
  340. return;
  341. }
  342. else if(iCreateNewFileResult == 2)
  343. {
  344. log.Info("(OTSIncAMeasureAppForm.rbNew_CreateWorkspace_Click) m_DataMgrFun.CreateNewFile() Cancel !");
  345. return;
  346. }
  347. m_RibbonFun.SetAllRibbonButnStatus(true);
  348. //清除TREEVIEW和GRID上的显示的已经保存的样品信息
  349. m_SolutionWindows.m_TreeViewBase.DeleteAllTreeNode();
  350. m_SPropertyWindows.m_SampleGrid.HideGrid();
  351. //设置报告按钮
  352. rbPReport.Enabled = false;
  353. rbReport.Enabled = false;
  354. rbReClassify.Enabled = true;
  355. //新建项目时,设置属性窗体中的两个按钮也为不可用状态
  356. m_SPropertyWindows.TSLoad.Enabled = false;
  357. m_SPropertyWindows.TSSaveAs.Enabled = false;
  358. //绘制样品台
  359. m_SamplepaceWindow.InitStageDisplay(m_ProjData.GetStage(), m_ProjData.GetSEMStageData());
  360. //隐藏XrayTable控件
  361. m_MessureStatuWindow.HideXRayTable();
  362. //新建时重新初始化结果窗体结果
  363. m_MeasureRetWindow.SetInit();
  364. }
  365. // 新建样品时提示保存样品信息Messagebox
  366. public int ShowSaveInfoMsgBox()
  367. {
  368. string message = table["message4"].ToString();
  369. DialogResult dResult = MessageBox.Show(message, "Tip", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
  370. if (dResult == DialogResult.Yes)
  371. {
  372. return (int)MessageBoxRev.DIALOG_YES;
  373. }
  374. else if (dResult == DialogResult.No)
  375. {
  376. return (int)MessageBoxRev.DIALOG_NO;
  377. }
  378. else
  379. {
  380. return (int)MessageBoxRev.DIALOG_CANCEL;
  381. }
  382. }
  383. //打开已经保存的工作文件
  384. private bool DisplayExistSampleFile()
  385. {
  386. List<CTreeSampleParam> TSampleParamList = new List<CTreeSampleParam>();
  387. List<SampleMeasurePara> SampleMeasureAreaList = new List<SampleMeasurePara>();
  388. int iSampleCount = m_ProjData.GetSampleList().Count;
  389. if (0 == iSampleCount)
  390. {
  391. return false;
  392. }
  393. for (int i = 0; i < iSampleCount; i++)
  394. {
  395. CTreeSampleParam CTSampleParam = new CTreeSampleParam();
  396. COTSSample SampleClr = (m_ProjData.GetSampleList())[i];
  397. CTSampleParam.sSampleTitleName = m_ProjData.GetFileName();
  398. CTSampleParam.sWorkSampleName = SampleClr.GetName();
  399. CTSampleParam.bSwitch = SampleClr.GetSwitch();
  400. CTSampleParam.bParamLock = SampleClr.GetParamLock();
  401. TSampleParamList.Add(CTSampleParam);
  402. }
  403. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  404. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetResultData().GetWorkingSample(), ref SMInfo))
  405. {
  406. log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(), ref SMInfo) = false Failed !");
  407. return false;
  408. }
  409. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  410. m_SolutionWindows.OpenExistSampleFile(TSampleParamList, SMInfo.TSampleParam);
  411. if (!OpenExistSampleMeasureArea(ref SampleMeasureAreaList))
  412. {
  413. log.Error(" OpenExistSampleMeasureArea(ref SampleMeasureAreaList) Failed !");
  414. return false;
  415. }
  416. string sWSampleName = m_ProjParam.GetWorkSampleName();
  417. if ("" == sWSampleName)
  418. {
  419. log.Error("(OTSIncAMeasureAppForm.OpenExistSampleFile) m_DataMgrFun.GetWorkSampleName() = null !");
  420. return false;
  421. }
  422. m_SamplepaceWindow.OpenExistSampleFile(m_ProjData.GetStage(), m_ProjData.GetSEMStageData(), SampleMeasureAreaList);
  423. return true;
  424. }
  425. public bool OpenExistSampleMeasureArea(ref List<SampleMeasurePara> SampleMeasureParaList)
  426. {
  427. int iSListCount = m_ProjData.GetSampleList().Count;
  428. if (0 == iSListCount)
  429. {
  430. return false;
  431. }
  432. for (int i = 0; i < iSListCount; i++)
  433. {
  434. SampleMeasurePara SampleMeasureArea = new SampleMeasurePara();
  435. //获取样品的测量区域信息
  436. //获取样品名称
  437. SampleMeasureArea.sSampleName = (m_ProjData.GetSampleList())[i].GetName();
  438. // 获取测量区域形状
  439. SampleMeasureArea.iShape = (ShapeType)m_ProjData.GetSampleList()[i].GetMsrDomain().GetShape();
  440. //获取样品孔名称
  441. SampleMeasureArea.sampleHoleName = (m_ProjData.GetSampleList())[i].GetSampleHoleName();
  442. //样品测量区域
  443. SampleMeasureArea.MeasureRect =(m_ProjData.GetSampleList())[i].GetMsrDomain().GetRectDomain();
  444. //多边形点集合
  445. List<PointF> PointRegionF = new List<PointF>();
  446. List<Point> PolygonPoint = m_ProjData.GetSampleList()[i].GetMsrDomain().GetPolygonPoint();
  447. if (PolygonPoint != null)
  448. {
  449. foreach (var item in m_ProjData.GetSampleList()[i].GetMsrDomain().GetPolygonPoint())
  450. {
  451. PointRegionF.Add(new PointF(item.X, item.Y));
  452. }
  453. }
  454. SampleMeasureArea.DrawPolygonPointList = PointRegionF;
  455. SampleMeasureParaList.Add(SampleMeasureArea);
  456. }
  457. return true;
  458. }
  459. //打开指定路径的文件
  460. private void rbOpen_Click(object sender, EventArgs e)
  461. {
  462. OpenMeasureProjectFile();
  463. }
  464. private void rbDeleteSample_Click(object sender, EventArgs e)
  465. {
  466. //删除样品(样品必须先选中)
  467. string sWSampleName = m_ProjParam.GetWorkSampleName();
  468. if ("" == sWSampleName)
  469. {
  470. log.Error("(OTSIncAMeasureAppForm.rbDeleteSample_Click) m_DataMgrFun.GetWorkSampleName() = null Failed");
  471. return;
  472. }
  473. string message = table["message5"].ToString();
  474. string message6 = table["message6"].ToString();
  475. string sDeleteSampleName = message;
  476. sDeleteSampleName += sWSampleName;
  477. sDeleteSampleName += message6;
  478. if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Tip", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
  479. {
  480. //删除样品成功
  481. DeleteSample(sWSampleName);
  482. sWSampleName = m_ProjParam.GetWorkSampleName();
  483. if ("" != sWSampleName)
  484. {
  485. m_SolutionWindows.m_TreeViewBase.GetTreeWorkSampleNode(sWSampleName);
  486. m_SolutionWindows.treeView1.Focus();
  487. }
  488. }
  489. }
  490. //返回删除的工作样品名
  491. public void DeleteSample(string sDeleteWSampleName = "")
  492. {
  493. if (m_MsrThreadWrapper.m_measure.mapSmplMsr.ContainsKey(sDeleteWSampleName))
  494. {
  495. m_MsrThreadWrapper.m_measure.mapSmplMsr.Remove(sDeleteWSampleName);
  496. }
  497. if (!m_ProjParam.DeleteWorkSample(sDeleteWSampleName))
  498. {
  499. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.DeleteWorkSample(sDeleteWSampleName) Failed, sDeleteWSampleName = " + sDeleteWSampleName);
  500. }
  501. // 设置 开始 ,停止 和检查参数 按钮状态
  502. m_RibbonFun.SetMeasureRibbonButnStatu();
  503. //设置 删除,复位,圆形,矩形 按钮状态
  504. m_RibbonFun.SetSampleRibbonButnStatus();
  505. // 更新报告ribbon按钮状态
  506. m_RibbonFun.SetAllRibbonButnStatus(true);
  507. int iSampleCount = m_ProjParam.GetSampleCount();
  508. if (0 == iSampleCount)
  509. {
  510. //给工作样品台发送删除样品和新的工作样品名称
  511. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  512. m_SPropertyWindows.PropGrid.Hide();
  513. m_SolutionWindows.treeView1.Nodes.Clear();
  514. m_MessureStatuWindow.HideXRayTable();
  515. m_MeasureRetWindow.SetInit();
  516. return ;
  517. }
  518. else
  519. {
  520. string sNewWSName = m_ProjParam.GetWorkSampleName();
  521. if ("" == sNewWSName)
  522. {
  523. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetWorkSampleName() = null Failed");
  524. return ;
  525. }
  526. m_SolutionWindows.DeletCurrentSampleNode();
  527. m_SolutionWindows.DisplaySample(sNewWSName);
  528. //将测量状态初始化
  529. m_MessureStatuWindow.SetMeasureStatusInit();
  530. //给工作样品台发送删除样品和新的工作样品名称
  531. m_SamplepaceWindow.DeleteWorkSample(sDeleteWSampleName);
  532. //设置工作样品
  533. SwitchWSample(sNewWSName);
  534. }
  535. return ;
  536. }
  537. private void rbAddSample_Click(object sender, EventArgs e)
  538. {
  539. this.AddNewSampleMeasure();//the system will choose the empty hole one by one according to the holeNo sequence.
  540. }
  541. public void AddNewSampleMeasure(string sSampleHoleName = "")
  542. {
  543. //样品的属性值
  544. OTSSamplePropertyInfo SMInfo = m_ProjParam.AddNewSampleMeasure(sSampleHoleName);
  545. if (null == SMInfo)
  546. {
  547. // 设置 开始 ,停止 和检查参数 按钮状态
  548. m_RibbonFun.SetMeasureRibbonButnStatu();
  549. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  550. return;
  551. }
  552. m_SPropertyWindows.TSSaveAs.Enabled = true;
  553. m_SPropertyWindows.TSLoad.Enabled = true;
  554. //给SampleWindow 发送样品信息
  555. m_SamplepaceWindow.AddSampleArea(SMInfo.SMeasurePara);
  556. m_SamplepaceWindow.ReadSEMDataAndSetToCurrentSample();
  557. //给PropWindow 发送工作样品属性信息
  558. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  559. //给SoluWindow 发送样品显示信息
  560. m_SolutionWindows.AddSampleMeasure(SMInfo.TSampleParam);
  561. // 设置 开始 ,停止 和检查参数 按钮状态
  562. m_RibbonFun.SetMeasureRibbonButnStatu();
  563. //设置 删除,复位,圆形,矩形 按钮状态
  564. m_RibbonFun.SetSampleRibbonButnStatus();
  565. //清空帧图信息
  566. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  567. }
  568. private void rbSelectDlg_Click(object sender, EventArgs e)
  569. {
  570. //判断样品台是否有样品,如果有样品则不能设置默认参数
  571. if (m_ProjParam.GetSampleCount() > 0)
  572. {
  573. MessageBox.Show("Cann't setup preference parameter,for you have added some samples!");
  574. return;
  575. }
  576. ProgMgrInfoForm ProgMgrForm = new ProgMgrInfoForm();
  577. if (DialogResult.OK == ProgMgrForm.ShowDialog())
  578. {
  579. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  580. {
  581. if (m_ProjParam.InitResultData())
  582. {
  583. m_RibbonFun.SetAllRibbonButnStatus(true);
  584. //当样品台上有样品,则不更新样品台数据
  585. if (0 == m_ProjParam.GetSampleCount())
  586. {
  587. m_SamplepaceWindow.InitStageDisplay(m_ProjData.GetStage(), m_ProjData.GetSEMStageData());
  588. }
  589. }
  590. else
  591. {
  592. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) this.CheckMeasureSysFileExist() = false");
  593. }
  594. }
  595. else
  596. {
  597. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
  598. }
  599. }
  600. }
  601. // 主Windows框右下角显示鼠标点的SEM坐标(样品台)
  602. public void ShowSemCoordvAL(string sSemCoord)
  603. {
  604. STSemCoordinate.Text = sSemCoord;
  605. statusStrip1.Refresh();
  606. }
  607. //// 主Windows框右下角显示鼠标点的灰度值(测量图)
  608. public void ShowGrayVal(string sGrayVal)
  609. {
  610. TSGrayVal.Text = sGrayVal;
  611. statusStrip1.Refresh();
  612. }
  613. //获取工作样品测量锁
  614. public bool GetWorkSampleParamLock(ref CTreeSampleParam TSParamLock)
  615. {
  616. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  617. if (!m_ProjParam.GetWSampleParaLock(ref SMInfo))
  618. {
  619. return false;
  620. }
  621. TSParamLock = SMInfo.TSampleParam;
  622. return true;
  623. }
  624. /// <summary>
  625. /// 更新属性窗口
  626. /// </summary>
  627. public void UpdatePropertyVal()
  628. {
  629. //获取新的工作样品属性值
  630. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  631. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  632. {
  633. log.Error("(OTSIncAMeasureAppForm.SetSEMData) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(),ref SMInfo) = false Failed");
  634. }
  635. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  636. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  637. }
  638. private void ribbonOrbMenuItemSaveAs_Click(object sender, EventArgs e)
  639. {
  640. bool iRev = m_ProjData.SaveAs();
  641. if (!iRev)
  642. {
  643. return;
  644. }
  645. }
  646. private void rbSaveFile_Click(object sender, EventArgs e)
  647. {
  648. bool iRev = m_ProjData.Save();
  649. if (!iRev)
  650. {
  651. return;
  652. }
  653. }
  654. private void rbCheckParam_Click(object sender, EventArgs e)
  655. {
  656. //检查样品测量参数
  657. if (m_ProjParam.CheckSampleParam(true))
  658. {
  659. string message = table["message7"].ToString();
  660. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  661. }
  662. }
  663. private void ribReset_Click(object sender, EventArgs e)
  664. {
  665. //调用样品台窗口中的复位方法
  666. m_SamplepaceWindow.ResetWorkSampleMeasure();
  667. }
  668. //绘制圆形测量区域
  669. private void ribCircle_Click(object sender, EventArgs e)
  670. {
  671. //修改工作样品的测量区域为圆形
  672. m_SamplepaceWindow.DrawCircleMeasure();
  673. }
  674. private void rbThreePoints_Click(object sender, EventArgs e)
  675. {
  676. //修改工作样品的测量区域为圆形
  677. m_SamplepaceWindow.DrawCircleMeasureByThreePoints();
  678. }
  679. private void rbRingShape_Click(object sender, EventArgs e)
  680. {
  681. //修改工作样品的测量区域为圆形
  682. m_SamplepaceWindow.DrawRingShapeArea();
  683. }
  684. //绘制矩形测量区域
  685. private void ribRectangle_Click(object sender, EventArgs e)
  686. {
  687. //修改工作样品的测量区域为矩形
  688. m_SamplepaceWindow.DrawRectangleMeasure();
  689. }
  690. private void rbExitApp_Click(object sender, EventArgs e)
  691. {
  692. this.Close();
  693. }
  694. private void rbStart_Click(object sender, EventArgs e)
  695. {
  696. if (!m_ProjParam.CheckSampleParam(false))
  697. {
  698. return;
  699. }
  700. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning() && !m_MsrThreadWrapper.BgWorkIsPaused())
  701. {
  702. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  703. //m_MsrThreadWrapper.SetDoRunType(MSR_RUN_TYPE.RUNMEASURE);
  704. m_MsrThreadWrapper.StartBGWorkThread();
  705. m_RibbonFun.SetMeasureRibbonButnStatu();
  706. }
  707. else //thread is in pausing state
  708. {
  709. SetRunType(MSR_RUN_TYPE.RUNMEASURE);
  710. //m_MsrThreadWrapper.SetDoRunType(MSR_RUN_TYPE.RUNMEASURE);
  711. m_MsrThreadWrapper.SetMeasureThreadStatus(OTS_MSR_THREAD_STATUS.INPROCESS);
  712. m_RibbonFun.SetMeasureRibbonButnStatu();
  713. }
  714. }
  715. public void SetStartMeasureRibbonStatus()
  716. {
  717. ribView.Enabled = false;
  718. m_RibbonFun.SetToolButnStatu(false);
  719. //false: 将其他ribbon按钮设置为灰色
  720. rbPanelFile.Enabled = false;
  721. rbPanelSample.Enabled = false;
  722. m_SolutionWindows.Enabled = false;
  723. m_SPropertyWindows.Enabled = false;
  724. rbStart.Enabled = false;
  725. //rbPause.Enabled = true;
  726. rbStop.Enabled = true;
  727. rbCheckParam.Enabled = false;
  728. }
  729. private void rbStop_Click(object sender, EventArgs e)
  730. {
  731. //如果当前正在测量,则停止测量线程
  732. if (MeasureThreadRunFlag)
  733. {
  734. //停止测量线程
  735. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  736. }
  737. else if (m_MsrThreadWrapper.m_measure.GetMsrThreadStatus() .GetStatus()== OTS_MSR_THREAD_STATUS.PAUSED)
  738. {
  739. foreach (KeyValuePair<string, CSmplMeasure> smpl in m_MsrThreadWrapper.m_measure.mapSmplMsr)
  740. {
  741. if (smpl.Value.GetSample().GetMsrStatus().GetStatus() == OTS_MSR_SAMPLE_STATUS.PAUSED)
  742. {
  743. smpl.Value.TheLastWorkOfSampleMeasure();
  744. return;
  745. }
  746. }
  747. }
  748. }
  749. private void rbPause_Click(object sender, EventArgs e)
  750. {
  751. //如果当前正在测量,则停止测量线程
  752. if (MeasureThreadRunFlag)
  753. {
  754. //停止测量线程
  755. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.PAUSED);
  756. }
  757. }
  758. private void rbRuler_Click(object sender, EventArgs e)
  759. {
  760. m_SamplepaceWindow.ShowRulerLocation();
  761. }
  762. private void rbSmapleName_Click(object sender, EventArgs e)
  763. {
  764. //m_SamplepaceWindow.ChangeSampleHoleFont();
  765. }
  766. private void rbSmaplePhoto_Click(object sender, EventArgs e)
  767. {
  768. m_SamplepaceWindow.ChangeSampleHoleImage();
  769. }
  770. //当点击Ribbon停止按钮时,设置Ribbon状态
  771. public void SetStopMeasureRibbonStatus()
  772. {
  773. ribView.Enabled = true;
  774. m_RibbonFun.SetToolButnStatu(true);
  775. rbPanelFile.Enabled = true;
  776. rbPanelSample.Enabled = true;
  777. m_RibbonFun.SetMeasureRibbonButnStatu();
  778. m_SolutionWindows.Enabled = true;
  779. m_SPropertyWindows.Enabled = true;
  780. rbStart.Enabled = true;
  781. rbPause.Enabled = false;
  782. rbStop.Enabled = false;
  783. rbCheckParam.Enabled = true;
  784. }
  785. public void SetPauseMeasureRibbonStatus()
  786. {
  787. ribView.Enabled = true;
  788. m_RibbonFun.SetToolButnStatu(true);
  789. rbPanelFile.Enabled = true;
  790. rbPanelSample.Enabled = true;
  791. m_RibbonFun.SetMeasureRibbonButnStatu();
  792. m_SolutionWindows.Enabled = true;
  793. m_SPropertyWindows.Enabled = true;
  794. rbStart.Enabled = true;
  795. rbPause.Enabled = false;
  796. rbStop.Enabled = true;
  797. rbCheckParam.Enabled = false;
  798. }
  799. public bool SwitchMeasureSample(string sMsrSampleName)
  800. {
  801. if (!m_ProjParam.SetWorkSample(sMsrSampleName))
  802. {
  803. log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample) SetWorkSample(sMsrSampleName =" + sMsrSampleName + ") Failed !");
  804. return false;
  805. }
  806. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  807. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  808. {
  809. log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(), ref SMInfo) = false Failed !");
  810. return false;
  811. }
  812. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  813. m_SolutionWindows.SwitchSample(sMsrSampleName);
  814. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  815. return true;
  816. }
  817. #region 开始获取样品孔中的照片
  818. /// <summary>
  819. /// 开始获取样品孔中的照片
  820. /// </summary>
  821. /// <param name="doRunType"></param>
  822. /// <param name="HoleID"></param>
  823. /// <param name="c_DomainMessure"></param>
  824. public void StartSampleHoleBSEImage(int HoleID)
  825. {
  826. //设置获取样品孔中照片所需的参数
  827. m_MsrThreadWrapper.SetHoleImagePreview(HoleID);
  828. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  829. {
  830. m_MsrThreadWrapper.StartBGWorkThread();
  831. m_RibbonFun.SetMeasureRibbonButnStatu();
  832. }
  833. }
  834. #endregion
  835. private void rbRecover_Click(object sender, EventArgs e)
  836. {
  837. //关闭所有内容
  838. CloseAllContents();
  839. //显示样品属性窗口与树结构窗口
  840. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  841. m_SPropertyWindows.Show(dockPanel);
  842. //显示样品台窗口 测量状态与测量结果窗口
  843. m_SamplepaceWindow.Show(dockPanel);
  844. m_MessureStatuWindow.Show(dockPanel);
  845. m_MeasureRetWindow.Show(dockPanel);
  846. //此处将在父窗体选项卡上显示
  847. foreach (Form child in this.MdiChildren)
  848. {
  849. if (child.Name == "OTSSamplespaceWindow")
  850. {
  851. child.Activate();
  852. break;
  853. }
  854. }
  855. }
  856. private void CloseAllContents()
  857. {
  858. m_SolutionWindows.DockPanel = null;
  859. m_SPropertyWindows.DockPanel = null;
  860. m_SamplepaceWindow.DockPanel = null;
  861. m_MessureStatuWindow.DockPanel = null;
  862. m_MeasureRetWindow.DockPanel = null;
  863. CloseAllDocuments();
  864. }
  865. private void CloseAllDocuments()
  866. {
  867. if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
  868. {
  869. foreach (Form form in MdiChildren)
  870. form.Close();
  871. }
  872. else
  873. {
  874. IDockContent[] documents = dockPanel.DocumentsToArray();
  875. foreach (IDockContent content in documents)
  876. content.DockHandler.Close();
  877. }
  878. }
  879. private void rbMeasureCircle_Click(object sender, EventArgs e)
  880. {
  881. m_ProjParam.SetMeasureAreaShape(ShapeType.CIRCUL);
  882. //修改工作样品的测量区域为圆形
  883. m_SamplepaceWindow.changeShape(ShapeType.CIRCUL);
  884. }
  885. private void rbMeasureRectangle_Click(object sender, EventArgs e)
  886. {
  887. m_ProjParam.SetMeasureAreaShape(ShapeType.RECTANGLE);
  888. //修改工作样品的测量区域为矩形
  889. m_SamplepaceWindow.changeShape(ShapeType.RECTANGLE);
  890. }
  891. //ctrl+s组合键进行保存
  892. private void OTSIncAMeasureAppForm_KeyDown(object sender, KeyEventArgs e)
  893. {
  894. if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
  895. {
  896. bool iRev = m_ProjData.Save();
  897. if (!iRev)
  898. {
  899. log.Error("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  900. return;
  901. }
  902. log.Error("(OTSIncAMeasureAppForm.rbSaveAs_Click) m_DataMgrFun.SaveFile() Success !");
  903. }
  904. }
  905. private void rbSTDEdit_Click_1(object sender, EventArgs e)
  906. {
  907. OpenFileDialog openFileDialog = new OpenFileDialog();
  908. openFileDialog.Filter = "(*.db)|*.db";
  909. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  910. openFileDialog.RestoreDirectory = true;
  911. openFileDialog.FilterIndex = 1;
  912. if (openFileDialog.ShowDialog() == DialogResult.OK)
  913. {
  914. try
  915. {
  916. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSPartA_STDEditor.exe", openFileDialog.FileName);
  917. p.WaitForExit();
  918. }
  919. catch (Exception ex)
  920. {
  921. log.Error("OTSPartA_STDEditor:" + ex.ToString());
  922. }
  923. }
  924. //reload the setup data just now
  925. foreach (var s in this.m_ProjData.GetSampleList())
  926. {
  927. var stdname= s.GetMsrParams().GetSTDName();
  928. if (stdname != "NoSTDDB")
  929. {
  930. if (!stdname.Contains(".db"))
  931. {
  932. stdname += ".db";
  933. }
  934. var m_classifyEngine = new COTSClassifyEngineClr(EngineType.ParticleClassifyEng, stdname);
  935. m_classifyEngine.ReloadEngineDB();
  936. }
  937. }
  938. }
  939. private void rbSysMgrApp_Click(object sender, EventArgs e)
  940. {
  941. try
  942. {
  943. System.Diagnostics.Process p = System.Diagnostics.Process.Start(".\\OTSSysMgrApp.exe");
  944. p.WaitForExit();
  945. }
  946. catch (Exception ex)
  947. {
  948. log.Error("OTSSysMgrApp:" + ex.ToString());
  949. }
  950. }
  951. private void ribPolygon_Click(object sender, EventArgs e)
  952. {
  953. //修改工作样品的测量区域为矩形
  954. m_SamplepaceWindow.DrawPolygonMeasure();
  955. }
  956. private void rbReClassify_Click(object sender, EventArgs e)
  957. {
  958. this.Cursor = Cursors.WaitCursor;
  959. if (m_ProjData.Reclassify())
  960. {
  961. m_ProjData.Save();
  962. MessageBox.Show("reclassification success");
  963. }
  964. else
  965. {
  966. MessageBox.Show("reclassification failed");
  967. }
  968. this.Cursor = Cursors.Default;
  969. }
  970. /// <summary>
  971. /// 打开测量项目文件
  972. /// </summary>
  973. private void OpenMeasureProjectFile()
  974. {
  975. bool bOpenFlag=false;
  976. COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
  977. string strPathName;
  978. // file open dialog
  979. OpenFileDialog openFileDialog = new OpenFileDialog();
  980. openFileDialog.Filter = "Probject Files (*.prj)|*.prj";
  981. if (openFileDialog.ShowDialog() != DialogResult.OK)
  982. {
  983. return ;
  984. }
  985. strPathName = openFileDialog.FileName;
  986. this.Cursor = Cursors.WaitCursor;
  987. if (ProjDataMgr.Load(strPathName))
  988. {
  989. m_ProjData = ProjDataMgr;
  990. m_ProjParam.SetResultData(m_ProjData);
  991. m_ProjParam.InitResultData();
  992. bOpenFlag = true;
  993. }
  994. this.Cursor = Cursors.Default;
  995. if (bOpenFlag)
  996. {
  997. if (!DisplayExistSampleFile())
  998. {
  999. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) OpenExistSampleFile() = false Failed !");
  1000. return;
  1001. }
  1002. m_RibbonFun.SetAllRibbonButnStatus(true);
  1003. }
  1004. else
  1005. {
  1006. log.Error("(OTSIncAMeasureAppForm.rbOpen_Click) m_DataMgrFun.OpenExistSampleFile() Failed !");
  1007. }
  1008. }
  1009. private void OTSIncAMeasureAppForm_FormClosed(object sender, FormClosedEventArgs e)
  1010. {
  1011. }
  1012. private void rbAbout_Click(object sender, EventArgs e)
  1013. {
  1014. About m_about = new About();
  1015. m_about.ShowDialog();
  1016. }
  1017. protected override void DefWndProc(ref Message m)
  1018. {
  1019. switch (m.Msg)
  1020. {
  1021. case MsgID:
  1022. break;
  1023. case LogMsgID:
  1024. m_LogMsg = new PostLogMsg();
  1025. m_LogMsg = (PostLogMsg)Marshal.PtrToStructure(m.LParam, typeof(PostLogMsg));
  1026. var log = NLog.LogManager.GetCurrentClassLogger();
  1027. string s = GetString(m_LogMsg.logMessage);
  1028. switch (m_LogMsg.logLevel)
  1029. {
  1030. case 1:
  1031. log.Trace(s);
  1032. break;
  1033. case 2:
  1034. log.Debug(s);
  1035. break;
  1036. case 3:
  1037. log.Info(s);
  1038. break;
  1039. case 4:
  1040. log.Warn(s);
  1041. break;
  1042. case 5:
  1043. log.Error(s);
  1044. break;
  1045. case 6:
  1046. log.Fatal(s);
  1047. break;
  1048. }
  1049. break;
  1050. default:
  1051. base.DefWndProc(ref m);
  1052. break;
  1053. }
  1054. }
  1055. private string GetString(char[] csStr)
  1056. {
  1057. int ilen = csStr.Length;
  1058. string csName = new string(csStr); //MSTMsg.STMSampleStu.cSName
  1059. csName.IndexOf('\0');
  1060. csName = csName.Substring(0, csName.IndexOf('\0'));
  1061. return csName;
  1062. }
  1063. private void PrepareIpcServer()
  1064. {
  1065. //Instantiate our server channel.
  1066. IpcServerChannel channel = new IpcServerChannel("ServerChannel");
  1067. //Register the server channel.
  1068. ChannelServices.RegisterChannel(channel, false);
  1069. //Register this service type.
  1070. RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcSEMController), "RemoteObject", WellKnownObjectMode.Singleton);
  1071. }
  1072. private void rbConnectHardware_Click_1(object sender, EventArgs e)
  1073. {
  1074. if (!m_MsrThreadWrapper.IsSEMConnected())
  1075. {
  1076. if (!m_MsrThreadWrapper.ConnectSEM())
  1077. {
  1078. MessageBox.Show("Connect failed!");
  1079. return;
  1080. }
  1081. }
  1082. this.rbConnectHardware.Enabled = false;
  1083. this.rbDisconnectHardware.Enabled = true;
  1084. log.Warn("SEM connect success!");
  1085. }
  1086. private void rbDisconnectHardware_Click_1(object sender, EventArgs e)
  1087. {
  1088. if (m_MsrThreadWrapper.IsSEMConnected())
  1089. {
  1090. m_MsrThreadWrapper.DisconnectSEM();
  1091. }
  1092. this.rbDisconnectHardware.Enabled = false;
  1093. this.rbConnectHardware.Enabled = true;
  1094. log.Warn("SEM Disconnect!");
  1095. }
  1096. private void rbinterrupt_Click(object sender, EventArgs e)
  1097. {
  1098. if (m_MsrThreadWrapper.IsSEMConnected())
  1099. {
  1100. m_MsrThreadWrapper.StopXrayAcquisition();
  1101. }
  1102. log.Warn("StopXrayAcquisition!");
  1103. }
  1104. private void rbAutoBeamOff_Click(object sender, EventArgs e)
  1105. {
  1106. if (m_ProjData.GetGenParam().AutoBeamOff)
  1107. {
  1108. m_ProjData.GetGenParam().AutoBeamOff = false;
  1109. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1110. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_off;
  1111. }
  1112. else
  1113. {
  1114. m_ProjData.GetGenParam().AutoBeamOff = true;
  1115. rbAutoBeamOff.Image = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1116. rbAutoBeamOff.SmallImage = global::OTSMeasureApp.Properties.Resources.AutoBeamOff_on;
  1117. }
  1118. }
  1119. }
  1120. }