OTSIncAMeasureAppForm.cs 45 KB

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