123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- 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().GetGenParam().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);
- }
- }
- 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.IMAGERESOLUTION_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.PrepareMeasureField(sam, MSR_RUN_TYPE.RUNMEASURE);
-
- 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.m_RibbonFun.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());
- m_cotsprogmgrparamfile.SetImageScanParam(WSample.GetMsrParams().GetImageScanParam());
- m_cotsprogmgrparamfile.SetXRayParam(WSample.GetMsrParams().GetXRayParam());
- OTSModelSharp.COTSGeneralParam m_cgenparam = m_cotsprogmgrparamfile.GetGenParam();
- m_cgenparam.SetSysSTD(WSample.GetMsrParams().GetSysSTDSwitch());
- m_cgenparam.SetSteelTechnology((int)WSample.GetMsrParams().GetSteelTechnology());
- m_cgenparam.SetSTDSelect(WSample.GetMsrParams().GetSTDName().ToString());
- m_cotsprogmgrparamfile.SetGenParam(m_cgenparam);
- if (m_cotsprogmgrparamfile.SaveInfoToProgMgrFile())
- {
- //MessageBox.Show("Already saved!", "Tip");
- }
- }
- 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);
- }
- }
- }
|