OTSIncAMeasureAppForm.cs 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  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. if ("" != sWSampleName)
  521. {
  522. m_SolutionWindows.m_TreeViewBase.GetTreeWorkSampleNode(sWSampleName);
  523. m_SolutionWindows.treeView1.Focus();
  524. }
  525. }
  526. }
  527. //返回删除的工作样品名
  528. public bool DeleteSample(string sDeleteWSampleName = "")
  529. {
  530. if (!m_ProjParam.DeleteWorkSample(sDeleteWSampleName))
  531. {
  532. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.DeleteWorkSample(sDeleteWSampleName) Failed, sDeleteWSampleName = " + sDeleteWSampleName);
  533. //return false;
  534. }
  535. // 设置 开始 ,停止 和检查参数 按钮状态
  536. m_RibbonFun.SetMeasureRibbonButnStatu();
  537. //设置 删除,复位,圆形,矩形 按钮状态
  538. m_RibbonFun.SetSampleRibbonButnStatus();
  539. // 更新报告ribbon按钮状态
  540. m_RibbonFun.SetAllRibbonButnStatus(true);
  541. int iSampleCount = m_ProjParam.GetSampleCount();
  542. if (0 == iSampleCount)
  543. {
  544. //给工作样品台发送删除样品和新的工作样品名称
  545. m_SamplepaceWindow.Rev_MeasureApp_DeleteWorkSample_Event(sDeleteWSampleName, "");
  546. //清空样品对象列表
  547. if (OTSSamplespaceWindow.m_SampleGDIObjects != null)
  548. {
  549. //清空样品台窗口中样品、测量区域、帧图、照片位置对象列表
  550. OTSSamplespaceWindow.m_SampleGDIObjects.Clear();
  551. OTSSamplespaceWindow.m_MeasureGDIObjects.Clear();
  552. OTSSamplespaceWindow.m_MeasurePathGDIObjects.Clear();
  553. m_SamplepaceWindow.ClearImageAndSingleGDIObjects();
  554. }
  555. //样品全部删除完,将Treeview 和Grid 显示内容清空
  556. m_SPropertyWindows.PropGrid.Hide();
  557. m_SolutionWindows.treeView1.Nodes.Clear();
  558. m_MessureStatuWindow.HideXRayTable();
  559. m_MeasureRetWindow.SetInit();
  560. return true;
  561. }
  562. //获取新工作样品名称
  563. string sNewWSName = m_ProjParam.GetWorkSampleName();
  564. if ("" == sNewWSName)
  565. {
  566. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetWorkSampleName() = null Failed");
  567. return true;
  568. }
  569. //获取新的工作样品属性值
  570. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  571. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  572. {
  573. log.Error("(OTSIncAMeasureAppForm.DeleteSample) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(),ref SMInfo) = false Failed");
  574. return false;
  575. }
  576. //给SolutionWindow 发送新的工作样品名称
  577. m_SolutionWindows.Rev_MeasureApp_DeletSample_Event(m_ProjParam.GetWorkSampleName());
  578. //给工作样品台发送删除样品和新的工作样品名称
  579. m_SamplepaceWindow.Rev_MeasureApp_DeleteWorkSample_Event(sDeleteWSampleName, sNewWSName);
  580. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  581. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  582. return true;
  583. }
  584. private void rbAddSample_Click(object sender, EventArgs e)
  585. {
  586. this.AddNewSampleMeasure();//the system will choose the empty hole one by one according to the holeNo sequence.
  587. }
  588. public void AddNewSampleMeasure(string sSampleHoleName = "")
  589. {
  590. //样品的属性值
  591. OTSSamplePropertyInfo SamplePropParam ;
  592. SamplePropParam = m_ProjParam.AddNewSampleMeasure(sSampleHoleName);
  593. if (null == SamplePropParam)
  594. {
  595. // 设置 开始 ,停止 和检查参数 按钮状态
  596. m_RibbonFun.SetMeasureRibbonButnStatu();
  597. log.Error("(OTSIncAMeasureAppForm.AddNewSample) m_DataMgrFun.AddNewSample(sSampleHoleName) = null ");
  598. return;
  599. }
  600. m_SPropertyWindows.TSSaveAs.Enabled = true;
  601. m_SPropertyWindows.TSLoad.Enabled = true;
  602. //给SampleWindow 发送样品信息
  603. OTSSamplePropertyInfo SMInfo = SamplePropParam;
  604. m_SamplepaceWindow.AddOneSampleArea(SMInfo.SMeasurePara);
  605. //给PropWindow 发送工作样品属性信息
  606. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  607. //给SoluWindow 发送样品显示信息
  608. m_SolutionWindows.AddSampleMeasure(SMInfo.TSampleParam);
  609. // 设置 开始 ,停止 和检查参数 按钮状态
  610. m_RibbonFun.SetMeasureRibbonButnStatu();
  611. //设置 删除,复位,圆形,矩形 按钮状态
  612. m_RibbonFun.SetSampleRibbonButnStatus();
  613. //清空帧图信息
  614. m_MessageStates = (int)MessageState.StartMeasure;
  615. m_SamplepaceWindow.ClearImageAndSingleGDIObjects();
  616. m_SamplepaceWindow.Invalidate();
  617. }
  618. private void rbSelectDlg_Click(object sender, EventArgs e)
  619. {
  620. //判断样品台是否有样品,如果有样品则不能设置默认参数
  621. if (m_ProjParam.GetSampleCount() > 0)
  622. {
  623. MessageBox.Show("Cann't setup preference parameter,for you have added some samples!");
  624. return;
  625. }
  626. ProgMgrInfoForm ProgMgrForm = new ProgMgrInfoForm();
  627. if (DialogResult.OK == ProgMgrForm.ShowDialog())
  628. {
  629. //m_DataMgrFun.SetSysPartSTDData(ProgMgrForm.GetCPartSTDDataClr());
  630. //检查\\Config\\SysData 是否有OTSProgMgrParam.pmf文件
  631. if (m_ProjParam.LoadParamFile() && m_ProjParam.LoadStageParamFile())
  632. {
  633. //检查\\Config\\SysData 是否有OTSProgMgrParam.pmf文件
  634. if (m_ProjParam.InitResultData())
  635. {
  636. m_RibbonFun.SetAllRibbonButnStatus(true);
  637. //当样品台上有样品,则不更新样品台数据
  638. if (0 == m_ProjParam.GetSampleCount())
  639. {
  640. //通过委托事件将样品台数据发送给SamplespaceWindwo
  641. m_SamplepaceWindow.InitStageDisplay(m_ProjData.GetStage(), m_ProjData.GetSEMStageData());
  642. }
  643. }
  644. else
  645. {
  646. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) this.CheckMeasureSysFileExist() = false");
  647. }
  648. }
  649. else
  650. {
  651. log.Error("(OTSIncAMeasureAppForm.rbSelectDlg_Click) (m_DataMgrFun.CheckParamFile() && m_DataMgrFun.CheckStageFile()) = false");
  652. }
  653. }
  654. }
  655. // 主Windows框右下角显示鼠标点的SEM坐标(样品台)
  656. public void ShowSemCoordvAL(string sSemCoord)
  657. {
  658. STSemCoordinate.Text = sSemCoord;
  659. // TSGrayVal.Text = sGrayVal;
  660. statusStrip1.Refresh();
  661. }
  662. //// 主Windows框右下角显示鼠标点的灰度值(测量图)
  663. public void ShowGrayVal(string sGrayVal)
  664. {
  665. TSGrayVal.Text = sGrayVal;
  666. statusStrip1.Refresh();
  667. }
  668. //获取工作样品测量锁
  669. public bool GetWorkSampleParamLock(ref CTreeSampleParam TSParamLock)
  670. {
  671. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  672. if (!m_ProjParam.GetWSampleParaLock(ref SMInfo))
  673. {
  674. return false;
  675. }
  676. TSParamLock = SMInfo.TSampleParam;
  677. return true;
  678. }
  679. /// <summary>
  680. /// 更新属性窗口
  681. /// </summary>
  682. public void UpdatePropertyVal()
  683. {
  684. //获取新的工作样品属性值
  685. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  686. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  687. {
  688. log.Error("(OTSIncAMeasureAppForm.SetSEMData) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(),ref SMInfo) = false Failed");
  689. }
  690. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  691. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  692. }
  693. //获取BSE图
  694. //int iWidth: 宽
  695. //int iHeigh: 高
  696. //byte bImageData: 图像数据
  697. //返回 图像数据长度 = iWidth*iHeigh
  698. //bool bSimulatFlag : True 仿真状态
  699. public int GetImageData(int iWidth, int iHeight, ref byte[] ImageData, bool bSimulatFlag = false)
  700. {
  701. //获取BSE图片数据
  702. OTSBSEImageFun m_GetBseImage = new OTSBSEImageFun();
  703. return m_GetBseImage.GetScanImage(iWidth, iHeight, ref ImageData);
  704. }
  705. private void ribbonOrbMenuItemSaveAs_Click(object sender, EventArgs e)
  706. {
  707. bool iRev = m_ProjData.SaveAs();
  708. if (!iRev)
  709. {
  710. //log.Trace("(OTSIncAMeasureAppForm.ribbonOrbMenuItemSaveAs_Click) m_DataMgrFun.SaveAsFile() Failed !");
  711. return;
  712. }
  713. }
  714. private void rbSaveFile_Click(object sender, EventArgs e)
  715. {
  716. bool iRev = m_ProjData.Save();
  717. if (!iRev)
  718. {
  719. //log.Trace("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  720. return;
  721. }
  722. }
  723. private void rbCheckParam_Click(object sender, EventArgs e)
  724. {
  725. //检查样品测量参数
  726. if (m_ProjParam.CheckSampleParam(true))
  727. {
  728. string message = table["message7"].ToString();
  729. MessageBox.Show(message, "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
  730. }
  731. }
  732. private void ribReset_Click(object sender, EventArgs e)
  733. {
  734. //调用样品台窗口中的复位方法
  735. m_SamplepaceWindow.ResetWorkSampleMeasure();
  736. }
  737. //绘制圆形测量区域
  738. private void ribCircle_Click(object sender, EventArgs e)
  739. {
  740. //修改工作样品的测量区域为圆形
  741. m_SamplepaceWindow.Rev_DDrawCircleMeasure_MeasureAppToSampleWindow_Event();
  742. }
  743. private void rbThreePoints_Click(object sender, EventArgs e)
  744. {
  745. //修改工作样品的测量区域为圆形
  746. m_SamplepaceWindow.Rev_DDrawCircleMeasureByThreePoints_MeasureAppToSampleWindow_Event();
  747. }
  748. //绘制矩形测量区域
  749. private void ribRectangle_Click(object sender, EventArgs e)
  750. {
  751. //修改工作样品的测量区域为矩形
  752. m_SamplepaceWindow.Rev_DDrawRectangleMeasure_MeasureAppToSampleWindow_Event();
  753. }
  754. private void rbExitApp_Click(object sender, EventArgs e)
  755. {
  756. this.Close();
  757. }
  758. /// <summary>
  759. /// 执行样品孔中照片后台线程
  760. /// </summary>
  761. private void StartSampleHoleImageBGWorkThread()
  762. {
  763. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  764. {
  765. m_MessageStates = MessageState.ShotBSEPicture;
  766. m_MsrThreadWrapper.SetDoRunType((int)MSR_THREAD_RunSTATUS.RUNSampleHoleImage);
  767. m_MsrThreadWrapper.StartBGWorkThread();
  768. m_RibbonFun.SetMeasureRibbonButnStatu();
  769. }
  770. }
  771. private void rbStart_Click(object sender, EventArgs e)
  772. {
  773. if (!m_ProjParam.CheckSampleParam(false))
  774. {
  775. return;
  776. }
  777. if (!m_MsrThreadWrapper.BGWorkThreadIsRunning())
  778. {
  779. //设置消息类型 拍摄样品孔
  780. m_MessageStates = (int)MessageState.StartMeasure;
  781. m_MsrThreadWrapper.SetDoRunType((int)MSR_THREAD_RunSTATUS.RUNMEASURE);
  782. m_MsrThreadWrapper.StartBGWorkThread();
  783. m_RibbonFun.SetMeasureRibbonButnStatu();
  784. }
  785. }
  786. public void SetStartMeasureRibbonStatus()
  787. {
  788. //this.PropertyMeasureThreadRunFlag = true;
  789. ribView.Enabled = false;
  790. m_RibbonFun.SetToolButnStatu(false);
  791. //false: 将其他ribbon按钮设置为灰色
  792. rbPanelFile.Enabled = false;
  793. rbPanelSample.Enabled = false;
  794. m_SolutionWindows.Enabled = false;
  795. m_SPropertyWindows.Enabled = false;
  796. rbStart.Enabled = false;
  797. rbStop.Enabled = true;
  798. rbCheckParam.Enabled = false;
  799. }
  800. private void rbStop_Click(object sender, EventArgs e)
  801. {
  802. //如果当前正在测量,则停止测量线程
  803. if (MeasureThreadRunFlag)
  804. {
  805. //停止测量线程
  806. m_MsrThreadWrapper.SetMeasureThreadStatus(otsdataconst.OTS_MSR_THREAD_STATUS.STOPPED);
  807. }
  808. }
  809. private void rbRuler_Click(object sender, EventArgs e)
  810. {
  811. m_SamplepaceWindow.ShowRulerLocation();
  812. }
  813. private void rbSmapleName_Click(object sender, EventArgs e)
  814. {
  815. m_SamplepaceWindow.ChangeSampleHoleFont();
  816. }
  817. private void rbSmaplePhoto_Click(object sender, EventArgs e)
  818. {
  819. m_SamplepaceWindow.ChangeSampleHoleImage();
  820. }
  821. //当点击Ribbon停止按钮时,设置Ribbon状态
  822. public void SetStopMeasureRibbonStatus()
  823. {
  824. //this.PropertyMeasureThreadRunFlag = false;
  825. ribView.Enabled = true;
  826. m_RibbonFun.SetToolButnStatu(true);
  827. rbPanelFile.Enabled = true;
  828. rbPanelSample.Enabled = true;
  829. m_RibbonFun.SetMeasureRibbonButnStatu();
  830. m_SolutionWindows.Enabled = true;
  831. m_SPropertyWindows.Enabled = true;
  832. rbStart.Enabled = true;
  833. rbStop.Enabled = false;
  834. rbCheckParam.Enabled = true;
  835. }
  836. public bool SwitchMeasureSample(string sMsrSampleName)
  837. {
  838. if (!m_ProjParam.SetWorkSample(sMsrSampleName))
  839. {
  840. log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample) SetWorkSample(sMsrSampleName =" + sMsrSampleName + ") Failed !");
  841. return false;
  842. }
  843. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  844. if (!m_ProjParam.GetWorkSamplePerameter(m_ProjParam.GetWorkSample(), ref SMInfo))
  845. {
  846. log.Error("(OTSIncAMeasureAppForm.SwitchMeasureSample) m_DataMgrFun.GetSamplePropertyVal(m_DataMgrFun.GetWorkSample(), ref SMInfo) = false Failed !");
  847. return false;
  848. }
  849. // MeasureApp 窗口给 OTSPropertyWindow窗口 Grid显示的样品属性信息
  850. m_SolutionWindows.Rev_MeasureApp_SwitchSample_Event(sMsrSampleName);
  851. m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  852. return true;
  853. }
  854. #region 开始获取样品孔中的照片
  855. /// <summary>
  856. /// 开始获取样品孔中的照片
  857. /// </summary>
  858. /// <param name="doRunType"></param>
  859. /// <param name="HoleID"></param>
  860. /// <param name="c_DomainMessure"></param>
  861. public void StartSampleHoleBSEImage(int doRunType, int HoleID, CDomain c_DomainMessure)
  862. {
  863. //线程执行类型 1:测量类型 2:获取样品孔图片类型
  864. m_MsrThreadWrapper.SetDoRunType(doRunType);
  865. //设置获取样品孔中照片所需的参数
  866. m_MsrThreadWrapper.SetHoleImagePreview(HoleID, c_DomainMessure);
  867. StartSampleHoleImageBGWorkThread();
  868. }
  869. #endregion
  870. private void rbRecover_Click(object sender, EventArgs e)
  871. {
  872. //关闭所有内容
  873. CloseAllContents();
  874. //显示样品属性窗口与树结构窗口
  875. m_SolutionWindows.Show(dockPanel, DockState.DockLeft);
  876. m_SPropertyWindows.Show(dockPanel);
  877. //显示样品台窗口 测量状态与测量结果窗口
  878. m_SamplepaceWindow.Show(dockPanel);
  879. m_MessureStatuWindow.Show(dockPanel);
  880. m_MeasureRetWindow.Show(dockPanel);
  881. //此处将在父窗体选项卡上显示
  882. foreach (Form child in this.MdiChildren)
  883. {
  884. if (child.Name == "OTSSamplespaceWindow")
  885. {
  886. child.Activate();
  887. break;
  888. }
  889. }
  890. }
  891. private void CloseAllContents()
  892. {
  893. m_SolutionWindows.DockPanel = null;
  894. m_SPropertyWindows.DockPanel = null;
  895. m_SamplepaceWindow.DockPanel = null;
  896. m_MessureStatuWindow.DockPanel = null;
  897. m_MeasureRetWindow.DockPanel = null;
  898. CloseAllDocuments();
  899. }
  900. private void CloseAllDocuments()
  901. {
  902. if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi)
  903. {
  904. foreach (Form form in MdiChildren)
  905. form.Close();
  906. }
  907. else
  908. {
  909. IDockContent[] documents = dockPanel.DocumentsToArray();
  910. foreach (IDockContent content in documents)
  911. content.DockHandler.Close();
  912. }
  913. }
  914. private void rbMeasureCircle_Click(object sender, EventArgs e)
  915. {
  916. m_ProjParam.SetMeasureAreaShape((int)ShapeType.CIRCUL);
  917. //修改工作样品的测量区域为圆形
  918. m_SamplepaceWindow.changeShape((int)ShapeType.CIRCUL);
  919. }
  920. private void rbMeasureRectangle_Click(object sender, EventArgs e)
  921. {
  922. m_ProjParam.SetMeasureAreaShape((int)ShapeType.RECTANGLE);
  923. //修改工作样品的测量区域为矩形
  924. m_SamplepaceWindow.changeShape((int)ShapeType.RECTANGLE);
  925. }
  926. //ctrl+s组合键进行保存
  927. private void OTSIncAMeasureAppForm_KeyDown(object sender, KeyEventArgs e)
  928. {
  929. if (e.KeyCode == Keys.S && e.Modifiers == Keys.Control)
  930. {
  931. bool iRev = m_ProjData.Save();
  932. if (!iRev)
  933. {
  934. log.Error("(OTSIncAMeasureAppForm.rbSaveFile_Click) m_DataMgrFun.SaveFile() Failed !");
  935. return;
  936. }
  937. log.Error("(OTSIncAMeasureAppForm.rbSaveAs_Click) m_DataMgrFun.SaveFile() Success !");
  938. }
  939. }
  940. private void rbSTDEdit_Click_1(object sender, EventArgs e)
  941. {
  942. OpenFileDialog openFileDialog = new OpenFileDialog();
  943. openFileDialog.Filter = "(*.db)|*.db";
  944. openFileDialog.InitialDirectory = Application.StartupPath + "\\Config\\SysData\\";
  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. private void rbAbout_Click(object sender, EventArgs e)
  1009. {
  1010. About m_about = new About();
  1011. m_about.ShowDialog();
  1012. }
  1013. }
  1014. }