OTSPropertyWindow.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. using System;
  2. using System.Drawing;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using OTS.WinFormsUI.Docking;
  6. using OTSDataType;
  7. using OTSMeasureApp._3_OTSDisplaySourceGridData;
  8. using OTSModelSharp.ResourceManage;
  9. namespace OTSMeasureApp
  10. {
  11. public partial class OTSPropertyWindow : DockContent
  12. {
  13. public OTSIncAMeasureAppForm m_MeasureAppForm = null;
  14. public OTSDisplaySampleGrid m_SampleGrid = null;
  15. MeasureStopMode StopModeDialog;
  16. public OTSPropertyWindow(OTSIncAMeasureAppForm MeasureAppForm)
  17. {
  18. InitializeComponent();
  19. m_MeasureAppForm = MeasureAppForm;
  20. m_SampleGrid = new OTSDisplaySampleGrid(this);
  21. //国际化
  22. OTSCommon.Language lan = new OTSCommon.Language(this);
  23. }
  24. //接收 MeasureApp 发送的样品属性数据,通过Grid显示在properyWindow上
  25. public void DisplaySampleMeasureInfo(OTSSamplePropertyInfo SampleInfo)
  26. {
  27. //当点击事件响应结束后,将之前点击的行数和列数清0,避免选择工作样品重新赋值响应CELL值改变事件
  28. PropGrid.Show();
  29. m_SampleGrid.m_ClickRow = 0;
  30. m_SampleGrid.m_ClickColumn = 0;
  31. if(PropGrid.Rows.Count()>0)
  32. {
  33. PropGrid.Rows.Clear();
  34. PropGrid.Redim(OTSDisplaySampleGrid.Const_Grid_Row, OTSDisplaySampleGrid.Const_Grid_Column);
  35. }
  36. m_SampleGrid.InitGrid();
  37. m_SampleGrid.ShowSampleInfoGrid(SampleInfo);
  38. int iPropertyDisplayMode = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetGenParam().PropertyDisplayMode();
  39. if (iPropertyDisplayMode == 1)
  40. {
  41. for (int i = 6; i < PropGrid.Rows.Count(); i++)
  42. {
  43. PropGrid.Rows.HideRow(i);
  44. }
  45. }
  46. else if (iPropertyDisplayMode == 0)
  47. {
  48. for (int i = 6; i < PropGrid.Rows.Count(); i++)
  49. {
  50. PropGrid.Rows.ShowRow(i);
  51. }
  52. }
  53. PropGrid.Refresh();
  54. PropGrid.Invalidate();
  55. }
  56. private void OTSPropertyWindow_Load(object sender, EventArgs e)
  57. {
  58. }
  59. private void OTSPropertyWindow_Resize(object sender, EventArgs e)
  60. {
  61. {
  62. if (null != m_SampleGrid )
  63. {
  64. m_SampleGrid.m_PropWindow_X = this.Width;
  65. m_SampleGrid.InitGridTitlet();
  66. }
  67. }
  68. }
  69. public void SampleGridInfoChange(OTS_SAMPLE_PROP_GRID_ITEMS SampleId, OTS_ITEM_TYPES ValType, object ObjVal)
  70. {
  71. var PropertyMeasureThreadRunFlag = m_MeasureAppForm.m_MsrThreadWrapper.BGWorkThreadIsRunning();
  72. var measureTreadIsPaused= m_MeasureAppForm.m_MsrThreadWrapper.BgWorkIsPaused();
  73. var m_SolutionWindows = m_MeasureAppForm.m_SolutionWindows;
  74. //设置样品属性参数成功
  75. OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
  76. var m_DataMgr = m_MeasureAppForm.m_ProjParam;
  77. //当前正在测量
  78. if (PropertyMeasureThreadRunFlag)//measureThread is running
  79. {
  80. if (measureTreadIsPaused == false)//and is not paused
  81. {
  82. goto HERE;
  83. }
  84. }
  85. string sWSampleName = m_DataMgr.GetWorkSampleName();
  86. if ("" == sWSampleName)
  87. {
  88. return;
  89. }
  90. //更新 STD_FILE_NAME FILE_LIST
  91. if (OTS_SAMPLE_PROP_GRID_ITEMS.STD_FILE_NAME == SampleId)
  92. {
  93. if (m_DataMgr.SetSTDFileName((int)ObjVal))
  94. {
  95. //重新获取原来工作样品值重新设置
  96. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  97. {
  98. //系统工作文件出错,设置样品属性失败
  99. return;
  100. }
  101. //Prop重新获显示工作样品的原来值
  102. DisplaySampleMeasureInfo(SMInfo);
  103. return;
  104. }
  105. }
  106. else
  107. {
  108. if (OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME == SampleId)
  109. {
  110. //去除修改GRID的样品名的前后空格
  111. string str = (string)ObjVal;
  112. str = str.Trim();
  113. ObjVal = str;
  114. if (!m_DataMgr.CheckSampleNameIsValid((string)ObjVal))
  115. {
  116. //重新获取原来工作样品值重新设置
  117. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  118. {
  119. return;
  120. }
  121. //Prop重新获显示工作样品的原来值
  122. DisplaySampleMeasureInfo(SMInfo);
  123. return;
  124. }
  125. }
  126. //更新COMBBOX值
  127. if (!m_DataMgr.SetSampleParamVal(SampleId, ValType, ObjVal)) // Prop值变化,修改样品值成功
  128. {
  129. string sLog = "SampleId = " + SampleId.ToString() + "," + "ValType = " + ValType.ToString() + "," + "ObjVal = " + ObjVal.ToString();
  130. //重新获取原来工作样品值重新设置
  131. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  132. {
  133. return;
  134. }
  135. //Prop重新获显示工作样品的原来值
  136. DisplaySampleMeasureInfo(SMInfo);
  137. return;
  138. }
  139. if(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE==SampleId)
  140. {
  141. if (!m_DataMgr.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_FIELD, OTS_ITEM_TYPES.INT, StopModeDialog.FieldMode)) // Prop值变化,修改样品值成功
  142. {
  143. string sLog = "SampleId = " + SampleId.ToString() + "," + "ValType = " + ValType.ToString() + "," + "ObjVal = " + ObjVal.ToString();
  144. //重新获取原来工作样品值重新设置
  145. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  146. {
  147. return;
  148. }
  149. //Prop重新获显示工作样品的原来值
  150. DisplaySampleMeasureInfo(SMInfo);
  151. return;
  152. }
  153. if (!m_DataMgr.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_TIME, OTS_ITEM_TYPES.INT, StopModeDialog.TimeMode)) // Prop值变化,修改样品值成功
  154. {
  155. string sLog = "SampleId = " + SampleId.ToString() + "," + "ValType = " + ValType.ToString() + "," + "ObjVal = " + ObjVal.ToString();
  156. //重新获取原来工作样品值重新设置
  157. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  158. {
  159. return;
  160. }
  161. //Prop重新获显示工作样品的原来值
  162. DisplaySampleMeasureInfo(SMInfo);
  163. return;
  164. }
  165. if (!m_DataMgr.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_PARTICLE, OTS_ITEM_TYPES.INT, StopModeDialog.ParticleMode)) // Prop值变化,修改样品值成功
  166. {
  167. string sLog = "SampleId = " + SampleId.ToString() + "," + "ValType = " + ValType.ToString() + "," + "ObjVal = " + ObjVal.ToString();
  168. //重新获取原来工作样品值重新设置
  169. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  170. {
  171. return;
  172. }
  173. //Prop重新获显示工作样品的原来值
  174. DisplaySampleMeasureInfo(SMInfo);
  175. return;
  176. }
  177. if (!m_DataMgr.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_AREA, OTS_ITEM_TYPES.INT, StopModeDialog.AreaMode)) // Prop值变化,修改样品值成功
  178. {
  179. string sLog = "SampleId = " + SampleId.ToString() + "," + "ValType = " + ValType.ToString() + "," + "ObjVal = " + ObjVal.ToString();
  180. //重新获取原来工作样品值重新设置
  181. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  182. {
  183. return;
  184. }
  185. //Prop重新获显示工作样品的原来值
  186. DisplaySampleMeasureInfo(SMInfo);
  187. return;
  188. }
  189. }
  190. }
  191. //更新GROUPID和ITEMID的变化
  192. OTS_SAMPLE_PROP_GRID_ITEMS ItemID = (OTS_SAMPLE_PROP_GRID_ITEMS)SampleId;
  193. m_DataMgr.UpdateGroupValAndItemVal(ItemID);
  194. //修改Treeview 工作样品名字
  195. if (OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME == SampleId)
  196. {
  197. m_SolutionWindows.m_TreeViewBase.EditTreeWorkSampleName(sWSampleName, (string)ObjVal);
  198. }
  199. HERE:
  200. if (!m_DataMgr.GetWorkSamplePerameter(m_DataMgr.GetWorkSample(), ref SMInfo))
  201. {
  202. //系统工作文件出错,设置样品属性失败
  203. return;
  204. }
  205. // 修改TREEVIEW 工作样品的CHECKBOX值
  206. if (OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH == SampleId)
  207. {
  208. //修改TREEVIEW对应的样品的CHECKBOX值
  209. m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(m_DataMgr.GetWorkSampleName(), SMInfo.TSampleParam.bSwitch);
  210. // 设置 开始 ,停止 和检查参数 按钮状态
  211. m_MeasureAppForm. m_RibbonFun.SetMeasureRibbonButnStatu();
  212. }
  213. //设置SampleWindow新的工作样品
  214. sWSampleName = m_DataMgr.GetWorkSampleName();
  215. if (!("" == sWSampleName))
  216. {
  217. m_MeasureAppForm. m_SamplepaceWindow.ChangeWorkSampleName(sWSampleName);
  218. }
  219. //GRID重新获取工作样品属性值
  220. DisplaySampleMeasureInfo(SMInfo);
  221. //当修改了 样品图尺寸、放大倍数和样品图的Pix大小等,SAMPLEWINDOW需要重新绘制样品台
  222. if (OTS_SAMPLE_PROP_GRID_ITEMS.IMAGE_GRP_MAX == SampleId
  223. || OTS_SAMPLE_PROP_GRID_ITEMS.MAGNIFICATION == SampleId
  224. || OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE == SampleId
  225. || OTS_SAMPLE_PROP_GRID_ITEMS.START_MODE == SampleId
  226. || OTS_SAMPLE_PROP_GRID_ITEMS.SCAN_MODE == SampleId
  227. )
  228. {
  229. if (!measureTreadIsPaused && !PropertyMeasureThreadRunFlag)
  230. {
  231. var sam = m_MeasureAppForm.m_SamplepaceWindow.GetWorkingVisualSample();
  232. m_MeasureAppForm.m_SamplepaceWindow.PrepareMeasureField(sam);
  233. }
  234. }
  235. }
  236. private void toolStrip1_Paint(object sender, PaintEventArgs e)
  237. {
  238. if ((sender as ToolStrip).RenderMode == ToolStripRenderMode.System)
  239. {
  240. Rectangle rect = new Rectangle(0, 0, this.TSGridTitle.Width - 5, this.TSGridTitle.Height - 5);
  241. e.Graphics.SetClip(rect);
  242. }
  243. }
  244. private void PropGrid_Click_1(object sender, EventArgs e)
  245. {
  246. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  247. ls_gd.Focus();
  248. m_SampleGrid.m_ClickRow = ls_gd.Selection.ActivePosition.Row;
  249. m_SampleGrid.m_ClickColumn = ls_gd.Selection.ActivePosition.Column;
  250. /// 保证鼠标点击的GRID行和列是有效的
  251. if(m_SampleGrid.m_ClickRow>=0 && m_SampleGrid.m_ClickColumn>=0)
  252. {
  253. m_SampleGrid.SetGridTitleStatus();
  254. if(m_MeasureAppForm.m_ProjData.m_nPackId == otsdataconst.OTS_SysType_ID.CleannessA)
  255. {
  256. if (m_SampleGrid.m_ClickRow == 7 && m_SampleGrid.m_ClickColumn == 2)
  257. {
  258. StopModeDialog = new MeasureStopMode();
  259. StopModeDialog.FieldMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value.ToString());
  260. StopModeDialog.TimeMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value.ToString());
  261. StopModeDialog.ParticleMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value.ToString());
  262. StopModeDialog.StopMode = PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString();
  263. StopModeDialog.AreaMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value.ToString());
  264. DialogResult result = StopModeDialog.ShowDialog();
  265. if (result == DialogResult.OK)
  266. {
  267. string str = PropGrid[0, 0].Value.ToString();
  268. PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.StopMode;
  269. PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.FieldMode;
  270. PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.TimeMode;
  271. PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.ParticleMode;
  272. PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.AreaMode;
  273. PropGrid[0, 0].Value = str;
  274. PropGrid.Refresh();
  275. PropGrid.Invalidate();
  276. }
  277. }
  278. }
  279. else
  280. {
  281. if (m_SampleGrid.m_ClickRow == 9 && m_SampleGrid.m_ClickColumn == 2)
  282. {
  283. StopModeDialog = new MeasureStopMode();
  284. StopModeDialog.FieldMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value.ToString());
  285. StopModeDialog.TimeMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value.ToString());
  286. StopModeDialog.ParticleMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value.ToString());
  287. StopModeDialog.StopMode = PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString();
  288. StopModeDialog.AreaMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value.ToString());
  289. DialogResult result = StopModeDialog.ShowDialog();
  290. if (result == DialogResult.OK)
  291. {
  292. string str = PropGrid[0, 0].Value.ToString();
  293. PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.StopMode;
  294. PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.FieldMode;
  295. PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.TimeMode;
  296. PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.ParticleMode;
  297. PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value = StopModeDialog.AreaMode;
  298. PropGrid[0, 0].Value = str;
  299. PropGrid.Refresh();
  300. PropGrid.Invalidate();
  301. }
  302. }
  303. }
  304. }
  305. }
  306. private void TSSaveAs_Click(object sender, EventArgs e)
  307. {
  308. m_MeasureAppForm.m_ProjParam.SaveWorkMeasureFile();
  309. }
  310. private void TSEdit_Click(object sender, EventArgs e)
  311. {
  312. }
  313. private void TSLoad_Click(object sender, EventArgs e)
  314. {
  315. if (m_SampleGrid.m_ClickRow <= 0)
  316. {
  317. m_MeasureAppForm.m_ProjParam.LoadWorkMeasureFile();
  318. return;
  319. }
  320. if (OTS_SAMPLE_PROP_GRID_ITEMS.STD_FILE_NAME == (OTS_SAMPLE_PROP_GRID_ITEMS)PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag)
  321. {
  322. return;
  323. }
  324. else
  325. {
  326. m_MeasureAppForm.m_ProjParam.LoadWorkMeasureFile();
  327. return;
  328. }
  329. }
  330. }
  331. }