OTSIncAMeasureAppForm.cs 45 KB

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