using System; using System.Drawing; using System.Linq; using System.Windows.Forms; using OTS.WinFormsUI.Docking; using OTSDataType; using OTSMeasureApp._3_OTSDisplaySourceGridData; using OTSModelSharp.ResourceManage; using System.Collections.Generic; using OTSMeasureApp._7_OTSProgMgrInfo; namespace OTSMeasureApp { public partial class OTSPropertyWindow : DockContent { public OTSIncAMeasureAppForm m_MeasureAppForm = null; public OTSDisplaySampleGrid m_SampleGrid = null; frmMeasureStopMode frmStopModeDialog; OtherSelectionForm otherSelectionForm; public OTSPropertyWindow(OTSIncAMeasureAppForm MeasureAppForm) { InitializeComponent(); m_MeasureAppForm = MeasureAppForm; m_SampleGrid = new OTSDisplaySampleGrid(this); //国际化 OTSCommon.Language lan = new OTSCommon.Language(this); } //接收 MeasureApp 发送的样品属性数据,通过Grid显示在properyWindow上 public void DisplaySampleMeasureInfo(OTSSampleVisualPropertyInfo SampleInfo) { SampleInfo.InitPropItemGrps(); SampleInfo.UpdatePropertyData(); PropGrid.Show(); m_SampleGrid.m_ClickRow = 0; m_SampleGrid.m_ClickColumn = 0; if (PropGrid.Rows.Count() > 0) { PropGrid.Rows.Clear(); PropGrid.Redim(OTSDisplaySampleGrid.Const_Grid_Row, OTSDisplaySampleGrid.Const_Grid_Column); } m_SampleGrid.InitGrid(); m_SampleGrid.ShowSampleInfoGrid(SampleInfo); int iPropertyDisplayMode = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetCommonParam().PropertyDisplayMode(); if (iPropertyDisplayMode == 1) { for (int i = 6; i < PropGrid.Rows.Count(); i++) { PropGrid.Rows.HideRow(i); } } else if (iPropertyDisplayMode == 0) { for (int i = 6; i < PropGrid.Rows.Count(); i++) { PropGrid.Rows.ShowRow(i); } } toolStripButton_refresh.Enabled = true; PropGrid.Refresh(); PropGrid.Invalidate(); } private void OTSPropertyWindow_Load(object sender, EventArgs e) { } private void OTSPropertyWindow_Resize(object sender, EventArgs e) { if (null != m_SampleGrid) { m_SampleGrid.m_PropWindow_X = this.Width; m_SampleGrid.InitGridTitlet(); } } public void SampleGridInfoChange(OTS_SAMPLE_PROP_GRID_ITEMS SampleId, OTS_ITEM_TYPES ValType, object ObjVal) { var PropertyMeasureThreadRunFlag = m_MeasureAppForm.m_MsrThreadWrapper.BGWorkThreadIsRunning(); var measureTreadIsPaused = m_MeasureAppForm.m_MsrThreadWrapper.BgWorkIsPaused(); if (measureTreadIsPaused == false && PropertyMeasureThreadRunFlag == true) { return; } var m_measurePara = m_MeasureAppForm.m_ProjParam; var sample = m_measurePara.GetWorkSample(); var stype = m_measurePara.GetDefaultParam().GetSysType(); OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(sample, stype); switch (SampleId) { case OTS_SAMPLE_PROP_GRID_ITEMS.STD_FILE_NAME: if (SMInfo.SetSTDFileName((int)ObjVal)) { DisplaySampleMeasureInfo(SMInfo); return; } break; case OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME: string strNewName = (string)ObjVal; strNewName = strNewName.Trim(); string oldName = m_measurePara.GetWorkSampleName(); if (!m_measurePara.CheckSampleNameIsValid(strNewName)) { //update source grid,recover to the original value DisplaySampleMeasureInfo(SMInfo); return; } m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME, OTS_ITEM_TYPES.STRING, strNewName); //update visual stage m_MeasureAppForm.m_SamplepaceWindow.ChangeWorkSampleName(strNewName); var m_SolutionWindows = m_MeasureAppForm.m_SolutionWindows; //update the project sample list on the left of the main gui interface. m_SolutionWindows.m_TreeViewBase.EditTreeWorkSampleName(oldName, strNewName); //update source grid DisplaySampleMeasureInfo(SMInfo); break; case OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE: if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_FIELD, OTS_ITEM_TYPES.INT, frmStopModeDialog.FieldMode)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_TIME, OTS_ITEM_TYPES.INT, frmStopModeDialog.TimeMode)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_PARTICLE, OTS_ITEM_TYPES.INT, frmStopModeDialog.ParticleMode)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_PARAM_AREA, OTS_ITEM_TYPES.INT, frmStopModeDialog.AreaMode)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE, OTS_ITEM_TYPES.STRING, frmStopModeDialog.StopMode)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } break; case OTS_SAMPLE_PROP_GRID_ITEMS.OtherSelection: if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.OtherSelection, OTS_ITEM_TYPES.STRING, otherSelectionForm.OtherSelection)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } break; default: if (!m_measurePara.SetSampleParamVal(SampleId, ValType, ObjVal)) // Prop值变化,修改样品值成功 { DisplaySampleMeasureInfo(SMInfo); return; } break; } //---after modify the value of current sample properties,update the corresponding value of GUI.--- if ( OTS_SAMPLE_PROP_GRID_ITEMS.MAGNIFICATION == SampleId || OTS_SAMPLE_PROP_GRID_ITEMS.PIXEL_SIZE == SampleId || OTS_SAMPLE_PROP_GRID_ITEMS.START_PHOTO_MODE == SampleId || OTS_SAMPLE_PROP_GRID_ITEMS.XRAYSCAN_MODE == SampleId ) { var sam = m_MeasureAppForm.m_SamplepaceWindow.GetWorkingVisualSample(); m_MeasureAppForm.m_SamplepaceWindow.PrepareVisualMeasureField(sam); DisplaySampleMeasureInfo(SMInfo); return; } if (OTS_SAMPLE_PROP_GRID_ITEMS.SWITCH == SampleId) { m_MeasureAppForm.m_SolutionWindows.Rev_MeasureApp_CheckboxStatuChange_Event(m_measurePara.GetWorkSampleName(), SMInfo.TSampleParam.bSwitch); // 设置 开始 ,停止 和检查参数 按钮状态 m_MeasureAppForm.SetMeasureRibbonButnStatu(); } //update the source grid value DisplaySampleMeasureInfo(SMInfo); } private void toolStrip1_Paint(object sender, PaintEventArgs e) { if ((sender as ToolStrip).RenderMode == ToolStripRenderMode.System) { Rectangle rect = new Rectangle(0, 0, this.TSGridTitle.Width - 5, this.TSGridTitle.Height - 5); e.Graphics.SetClip(rect); } } private void PropGrid_Click_1(object sender, EventArgs e) { SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender; ls_gd.Focus(); m_SampleGrid.m_ClickRow = ls_gd.Selection.ActivePosition.Row; m_SampleGrid.m_ClickColumn = ls_gd.Selection.ActivePosition.Column; /// 保证鼠标点击的GRID行和列是有效的 if (m_SampleGrid.m_ClickRow >= 0 && m_SampleGrid.m_ClickColumn >= 0) { m_SampleGrid.SetGridTitleStatus(); if (PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag == null) { return; } 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) { frmStopModeDialog = new frmMeasureStopMode(); frmStopModeDialog.FieldMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value.ToString()); frmStopModeDialog.TimeMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value.ToString()); frmStopModeDialog.ParticleMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value.ToString()); frmStopModeDialog.StopMode = PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString(); frmStopModeDialog.AreaMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value.ToString()); DialogResult result = frmStopModeDialog.ShowDialog(); if (result == DialogResult.OK) { string str = PropGrid[0, 0].Value.ToString(); PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.StopMode; PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.FieldMode; PropGrid[m_SampleGrid.m_ClickRow + 3, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.TimeMode; PropGrid[m_SampleGrid.m_ClickRow + 1, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.ParticleMode; PropGrid[m_SampleGrid.m_ClickRow + 4, m_SampleGrid.m_ClickColumn].Value = frmStopModeDialog.AreaMode; PropGrid[0, 0].Value = str; PropGrid.Refresh(); PropGrid.Invalidate(); } } 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) { otherSelectionForm = new OtherSelectionForm(); if (PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString() != "NoFilter") { otherSelectionForm.OtherSelection = PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value.ToString(); } else { otherSelectionForm.OtherSelection = ""; } DialogResult result = otherSelectionForm.ShowDialog(); if (result == DialogResult.OK) { string str = PropGrid[0, 0].Value.ToString(); if (otherSelectionForm.OtherSelection == "") { PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = "NoFilter"; } else { PropGrid[m_SampleGrid.m_ClickRow, m_SampleGrid.m_ClickColumn].Value = otherSelectionForm.OtherSelection; } PropGrid[0, 0].Value = str; PropGrid.Refresh(); PropGrid.Invalidate(); } } } } private void TSSaveAs_Click(object sender, EventArgs e) { OTSModelSharp.COTSDefaultParam m_cotsprogmgrparamfile = m_MeasureAppForm.m_ProjParam.GetDefaultParam(); COTSSample WSample = m_MeasureAppForm.m_ProjParam.GetResultData().GetWorkingSample(); m_cotsprogmgrparamfile.SetImageProcParam(WSample.GetMsrParams().GetImageProcessParam().Duplicate()); m_cotsprogmgrparamfile.SetImageScanParam(WSample.GetMsrParams().GetImageScanParam().Duplicate()); m_cotsprogmgrparamfile.SetXRayParam(WSample.GetMsrParams().GetXRayParam().Duplicate()); m_cotsprogmgrparamfile.SpecialGrayRangeParam = WSample.GetMsrParams().GetSpecialGrayRangeParam().Duplicate(); OTSModelSharp.COTSCommonParam m_cgenparam = m_cotsprogmgrparamfile.GetCommonParam(); m_cgenparam.SetEngineType(WSample.GetMsrParams().GetEngineType()); m_cgenparam.SetSteelTechnology((int)WSample.GetMsrParams().GetSteelTechnology()); m_cgenparam.SetSTDSelect(WSample.GetMsrParams().GetSTDName().ToString()); m_cotsprogmgrparamfile.SetCommonParam(m_cgenparam.duplicate()); if (m_cotsprogmgrparamfile.SaveInfoToProgMgrFile()) { //MessageBox.Show("Already saved!", "Tip"); } m_MeasureAppForm.m_ProjParam.SetDefaultParam(m_cotsprogmgrparamfile); } private void TSEdit_Click(object sender, EventArgs e) { } private void TSLoad_Click(object sender, EventArgs e) { if (m_SampleGrid.m_ClickRow <= 0) { m_MeasureAppForm.m_ProjParam.LoadWorkMeasureFile(); return; } if (OTS_SAMPLE_PROP_GRID_ITEMS.STD_FILE_NAME == (OTS_SAMPLE_PROP_GRID_ITEMS)PropGrid.Rows[m_SampleGrid.m_ClickRow].Tag) { return; } else { m_MeasureAppForm.m_ProjParam.LoadWorkMeasureFile(); return; } } private void toolStripButton_refresh_Click(object sender, EventArgs e) { var sample = m_MeasureAppForm.m_ProjParam.GetWorkSample(); var stype = m_MeasureAppForm.m_ProjParam.GetDefaultParam().GetSysType(); OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(sample, stype); DisplaySampleMeasureInfo(MeasureInfo); } } }