OTSIncAMeasureAppForm.cs 47 KB

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