OTSPropertyWindow.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. using System.Collections.Generic;
  10. using OTSMeasureApp._7_OTSProgMgrInfo;
  11. namespace OTSMeasureApp
  12. {
  13. public partial class OTSPropertyWindow : DockContent
  14. {
  15. public OTSIncAMeasureAppForm m_MeasureAppForm = null;
  16. public OTSDisplaySampleGrid m_SampleGrid = null;
  17. frmMeasureStopMode frmStopModeDialog;
  18. OtherSelectionForm otherSelectionForm;
  19. public OTSPropertyWindow(OTSIncAMeasureAppForm MeasureAppForm)
  20. {
  21. InitializeComponent();
  22. m_MeasureAppForm = MeasureAppForm;
  23. m_SampleGrid = new OTSDisplaySampleGrid(this);
  24. //国际化
  25. OTSCommon.Language lan = new OTSCommon.Language(this);
  26. }
  27. //接收 MeasureApp 发送的样品属性数据,通过Grid显示在properyWindow上
  28. public void DisplaySampleMeasureInfo(OTSSampleVisualPropertyInfo SampleInfo)
  29. {
  30. SampleInfo.InitPropItemGrps();
  31. SampleInfo.UpdatePropertyData();
  32. PropGrid.Show();
  33. m_SampleGrid.m_ClickRow = 0;
  34. m_SampleGrid.m_ClickColumn = 0;
  35. if (PropGrid.Rows.Count() > 0)
  36. {
  37. PropGrid.Rows.Clear();
  38. PropGrid.Redim(OTSDisplaySampleGrid.Const_Grid_Row, OTSDisplaySampleGrid.Const_Grid_Column);
  39. }
  40. m_SampleGrid.InitGrid();
  41. m_SampleGrid.ShowSampleInfoGrid(SampleInfo);
  42. int iPropertyDisplayMode = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetGenParam().PropertyDisplayMode();
  43. if (iPropertyDisplayMode == 1)
  44. {
  45. for (int i = 6; i < PropGrid.Rows.Count(); i++)
  46. {
  47. PropGrid.Rows.HideRow(i);
  48. }
  49. }
  50. else if (iPropertyDisplayMode == 0)
  51. {
  52. for (int i = 6; i < PropGrid.Rows.Count(); i++)
  53. {
  54. PropGrid.Rows.ShowRow(i);
  55. }
  56. }
  57. PropGrid.Refresh();
  58. PropGrid.Invalidate();
  59. }
  60. private void OTSPropertyWindow_Load(object sender, EventArgs e)
  61. {
  62. }
  63. private void OTSPropertyWindow_Resize(object sender, EventArgs e)
  64. {
  65. if (null != m_SampleGrid)
  66. {
  67. m_SampleGrid.m_PropWindow_X = this.Width;
  68. m_SampleGrid.InitGridTitlet();
  69. }
  70. }
  71. public void SampleGridInfoChange(OTS_SAMPLE_PROP_GRID_ITEMS SampleId, OTS_ITEM_TYPES ValType, object ObjVal)
  72. {
  73. var PropertyMeasureThreadRunFlag = m_MeasureAppForm.m_MsrThreadWrapper.BGWorkThreadIsRunning();
  74. var measureTreadIsPaused = m_MeasureAppForm.m_MsrThreadWrapper.BgWorkIsPaused();
  75. if (measureTreadIsPaused == false && PropertyMeasureThreadRunFlag == true)
  76. {
  77. return;
  78. }
  79. var m_measurePara = m_MeasureAppForm.m_ProjParam;
  80. var sample = m_measurePara.GetWorkSample();
  81. var stype = m_measurePara.GetDefaultParam().GetSysType();
  82. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(sample, stype);
  83. switch (SampleId)
  84. {
  85. case OTS_SAMPLE_PROP_GRID_ITEMS.STD_FILE_NAME:
  86. if (SMInfo.SetSTDFileName((int)ObjVal))
  87. {
  88. DisplaySampleMeasureInfo(SMInfo);
  89. return;
  90. }
  91. break;
  92. case OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME:
  93. string strNewName = (string)ObjVal;
  94. strNewName = strNewName.Trim();
  95. string oldName = m_measurePara.GetWorkSampleName();
  96. if (!m_measurePara.CheckSampleNameIsValid(strNewName))
  97. {
  98. //update source grid,recover to the original value
  99. DisplaySampleMeasureInfo(SMInfo);
  100. return;
  101. }
  102. m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME, OTS_ITEM_TYPES.STRING, strNewName);
  103. //update visual stage
  104. m_MeasureAppForm.m_SamplepaceWindow.ChangeWorkSampleName(strNewName);
  105. var m_SolutionWindows = m_MeasureAppForm.m_SolutionWindows;
  106. //update the project sample list on the left of the main gui interface.
  107. m_SolutionWindows.m_TreeViewBase.EditTreeWorkSampleName(oldName, strNewName);
  108. //update source grid
  109. DisplaySampleMeasureInfo(SMInfo);
  110. break;
  111. case OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE:
  112. if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_FIELD, OTS_ITEM_TYPES.INT, frmStopModeDialog.FieldMode)) // Prop值变化,修改样品值成功
  113. {
  114. DisplaySampleMeasureInfo(SMInfo);
  115. return;
  116. }
  117. if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_TIME, OTS_ITEM_TYPES.INT, frmStopModeDialog.TimeMode)) // Prop值变化,修改样品值成功
  118. {
  119. DisplaySampleMeasureInfo(SMInfo);
  120. return;
  121. }
  122. if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_PARTICLE, OTS_ITEM_TYPES.INT, frmStopModeDialog.ParticleMode)) // Prop值变化,修改样品值成功
  123. {
  124. DisplaySampleMeasureInfo(SMInfo);
  125. return;
  126. }
  127. if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_AREA, OTS_ITEM_TYPES.INT, frmStopModeDialog.AreaMode)) // Prop值变化,修改样品值成功
  128. {
  129. DisplaySampleMeasureInfo(SMInfo);
  130. return;
  131. }
  132. if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE, OTS_ITEM_TYPES.STRING, frmStopModeDialog.StopMode)) // Prop值变化,修改样品值成功
  133. {
  134. DisplaySampleMeasureInfo(SMInfo);
  135. return;
  136. }
  137. break;
  138. case OTS_SAMPLE_PROP_GRID_ITEMS.OtherSelection:
  139. if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.OtherSelection, OTS_ITEM_TYPES.STRING, otherSelectionForm.OtherSelection)) // Prop值变化,修改样品值成功
  140. {
  141. DisplaySampleMeasureInfo(SMInfo);
  142. return;
  143. }
  144. break;
  145. default:
  146. if (!m_measurePara.SetSampleParamVal(SampleId, ValType, ObjVal)) // Prop值变化,修改样品值成功
  147. {
  148. DisplaySampleMeasureInfo(SMInfo);
  149. return;
  150. }
  151. break;
  152. }
  153. //---after modify the value of current sample properties,update the corresponding value of GUI.---
  154. if (
  155. OTS_SAMPLE_PROP_GRID_ITEMS.MAGNIFICATION == SampleId
  156. || OTS_SAMPLE_PROP_GRID_ITEMS.IMAGERESOLUTION_SIZE == SampleId
  157. || OTS_SAMPLE_PROP_GRID_ITEMS.START_PHOTO_MODE == SampleId
  158. || OTS_SAMPLE_PROP_GRID_ITEMS.XRAYSCAN_MODE == SampleId
  159. )
  160. {
  161. var sam = m_MeasureAppForm.m_SamplepaceWindow.GetWorkingVisualSample();
  162. m_MeasureAppForm.m_SamplepaceWindow.PrepareMeasureField(sam, MSR_RUN_TYPE.RUNMEASURE);
  163. DisplaySampleMeasureInfo(SMInfo);
  164. return;
  165. }
  166. if (OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH == SampleId)
  167. {
  168. m_MeasureAppForm.m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(m_measurePara.GetWorkSampleName(), SMInfo.TSampleParam.bSwitch);
  169. // 设置 开始 ,停止 和检查参数 按钮状态
  170. m_MeasureAppForm.m_RibbonFun.SetMeasureRibbonButnStatu();
  171. }
  172. //update the source grid value
  173. DisplaySampleMeasureInfo(SMInfo);
  174. }
  175. private void toolStrip1_Paint(object sender, PaintEventArgs e)
  176. {
  177. if ((sender as ToolStrip).RenderMode == ToolStripRenderMode.System)
  178. {
  179. Rectangle rect = new Rectangle(0, 0, this.TSGridTitle.Width - 5, this.TSGridTitle.Height - 5);
  180. e.Graphics.SetClip(rect);
  181. }
  182. }
  183. private void PropGrid_Click_1(object sender, EventArgs e)
  184. {
  185. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  186. ls_gd.Focus();
  187. m_SampleGrid.m_ClickRow = ls_gd.Selection.ActivePosition.Row;
  188. m_SampleGrid.m_ClickColumn = ls_gd.Selection.ActivePosition.Column;
  189. /// 保证鼠标点击的GRID行和列是有效的
  190. if (m_SampleGrid.m_ClickRow >= 0 && m_SampleGrid.m_ClickColumn >= 0)
  191. {
  192. m_SampleGrid.SetGridTitleStatus();
  193. if (PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag == null)
  194. {
  195. return;
  196. }
  197. if ((OTS_SAMPLE_PROP_GRID_ITEMS)PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag == OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE && m_SampleGrid.m_ClickColumn == 2)
  198. {
  199. frmStopModeDialog = new frmMeasureStopMode();
  200. frmStopModeDialog.FieldMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value.ToString());
  201. frmStopModeDialog.TimeMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value.ToString());
  202. frmStopModeDialog.ParticleMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value.ToString());
  203. frmStopModeDialog.StopMode = PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString();
  204. frmStopModeDialog.AreaMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value.ToString());
  205. DialogResult result = frmStopModeDialog.ShowDialog();
  206. if (result == DialogResult.OK)
  207. {
  208. string str = PropGrid[0, 0].Value.ToString();
  209. PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.StopMode;
  210. PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.FieldMode;
  211. PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.TimeMode;
  212. PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.ParticleMode;
  213. PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.AreaMode;
  214. PropGrid[0, 0].Value = str;
  215. PropGrid.Refresh();
  216. PropGrid.Invalidate();
  217. }
  218. }
  219. else if ((OTS_SAMPLE_PROP_GRID_ITEMS)PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag == OTS_SAMPLE_PROP_GRID_ITEMS.OtherSelection && m_SampleGrid.m_ClickColumn == 2)
  220. {
  221. otherSelectionForm = new OtherSelectionForm();
  222. if (PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString() != "NoFilter")
  223. {
  224. otherSelectionForm.OtherSelection = PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString();
  225. }
  226. else
  227. {
  228. otherSelectionForm.OtherSelection = "";
  229. }
  230. DialogResult result = otherSelectionForm.ShowDialog();
  231. if (result == DialogResult.OK)
  232. {
  233. string str = PropGrid[0, 0].Value.ToString();
  234. if (otherSelectionForm.OtherSelection == "")
  235. {
  236. PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = "NoFilter";
  237. }
  238. else
  239. {
  240. PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = otherSelectionForm.OtherSelection;
  241. }
  242. PropGrid[0, 0].Value = str;
  243. PropGrid.Refresh();
  244. PropGrid.Invalidate();
  245. }
  246. }
  247. }
  248. }
  249. private void TSSaveAs_Click(object sender, EventArgs e)
  250. {
  251. OTSModelSharp.COTSDefaultParam m_cotsprogmgrparamfile = m_MeasureAppForm.m_ProjParam.GetDefaultParam();
  252. COTSSample WSample = m_MeasureAppForm.m_ProjParam.GetResultData().GetWorkingSample();
  253. m_cotsprogmgrparamfile.SetImageProcParam(WSample.GetMsrParams().GetImageProcessParam());
  254. m_cotsprogmgrparamfile.SetImageScanParam(WSample.GetMsrParams().GetImageScanParam());
  255. m_cotsprogmgrparamfile.SetXRayParam(WSample.GetMsrParams().GetXRayParam());
  256. OTSModelSharp.COTSGeneralParam m_cgenparam = m_cotsprogmgrparamfile.GetGenParam();
  257. m_cgenparam.SetSysSTD(WSample.GetMsrParams().GetSysSTDSwitch());
  258. m_cgenparam.SetSteelTechnology((int)WSample.GetMsrParams().GetSteelTechnology());
  259. m_cgenparam.SetSTDSelect(WSample.GetMsrParams().GetSTDName().ToString());
  260. m_cotsprogmgrparamfile.SetGenParam(m_cgenparam);
  261. if (m_cotsprogmgrparamfile.SaveInfoToProgMgrFile())
  262. {
  263. //MessageBox.Show("Already saved!", "Tip");
  264. }
  265. }
  266. private void TSEdit_Click(object sender, EventArgs e)
  267. {
  268. }
  269. private void TSLoad_Click(object sender, EventArgs e)
  270. {
  271. if (m_SampleGrid.m_ClickRow <= 0)
  272. {
  273. m_MeasureAppForm.m_ProjParam.LoadWorkMeasureFile();
  274. return;
  275. }
  276. if (OTS_SAMPLE_PROP_GRID_ITEMS.STD_FILE_NAME == (OTS_SAMPLE_PROP_GRID_ITEMS)PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag)
  277. {
  278. return;
  279. }
  280. else
  281. {
  282. m_MeasureAppForm.m_ProjParam.LoadWorkMeasureFile();
  283. return;
  284. }
  285. }
  286. private void toolStripButton_refresh_Click(object sender, EventArgs e)
  287. {
  288. var sample = m_MeasureAppForm.m_ProjParam.GetWorkSample();
  289. var stype = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetSysType();
  290. OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample, stype);
  291. DisplaySampleMeasureInfo(MeasureInfo);
  292. }
  293. }
  294. }