OTSIncAMeasureAppForm.cs 46 KB

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