OTSIncAMeasureAppForm.cs 46 KB

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