Browse Source

fix the bug when rename sample name

gsp 2 years ago
parent
commit
b670334cc0

+ 0 - 2
OTSIncAMeasureApp/0-OTSModel/OTSDataType/COTSSample.cs

@@ -516,8 +516,6 @@ namespace OTSDataType
             if (bSetFalg)
             {
                 this.GetMsrStatus().SetStatus(OTS_MSR_SAMPLE_STATUS.UNMEASURED);//change the state so that this sample can be processed again.
-
-
             }
 
             return bSetFalg;

+ 38 - 24
OTSIncAMeasureApp/3-OTSDisplaySourceGridData/OTSPropertyWindow.cs

@@ -96,7 +96,7 @@ namespace OTSMeasureApp
 
 
             var m_measurePara = m_MeasureAppForm.m_ProjParam;
-            string sWSampleName = m_measurePara.GetWorkSampleName();
+           
            
 
             OTSSamplePropertyInfo SMInfo = new OTSSamplePropertyInfo();
@@ -115,20 +115,30 @@ namespace OTSMeasureApp
                     }
                     break;
                 case OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME:
-                    string str = (string)ObjVal;
-                    str = str.Trim();
-
-                    if (m_measurePara.CheckSampleNameIsValid(str))
+                    string strNewName = (string)ObjVal;
+                    strNewName = strNewName.Trim();
+                    string oldName = m_measurePara.GetWorkSampleName();
+                    if (!m_measurePara.CheckSampleNameIsValid(strNewName))
                     {
-                        m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.SAMPLE_NAME, OTS_ITEM_TYPES.STRING, str);
-                       
-                       
+                        m_measurePara.GetWorkSamplePerameter(m_measurePara.GetWorkSample(), ref SMInfo);
+                        //update source grid,recover to the original value
+                        DisplaySampleMeasureInfo(SMInfo);
+                        return;
                     }
-                    m_measurePara.GetWorkSamplePerameter(m_measurePara.GetWorkSample(), ref SMInfo);
 
-                    DisplaySampleMeasureInfo(SMInfo);
+                    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;
-                    m_SolutionWindows.m_TreeViewBase.EditTreeWorkSampleName(sWSampleName, (string)ObjVal);
+                    //update the project sample list on the left of the main gui interface.
+                    m_SolutionWindows.m_TreeViewBase.EditTreeWorkSampleName(oldName, strNewName);
+
+                    m_measurePara.GetWorkSamplePerameter(m_measurePara.GetWorkSample(), ref SMInfo);
+                    //update source grid
+                    DisplaySampleMeasureInfo(SMInfo);
+
+                   
+                  
 
                     break;
                 case OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE:
@@ -165,6 +175,15 @@ namespace OTSMeasureApp
                         m_measurePara.GetWorkSamplePerameter(m_measurePara.GetWorkSample(), ref SMInfo);
 
 
+                        DisplaySampleMeasureInfo(SMInfo);
+                        return;
+                    }
+                    if (!m_measurePara.SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS.STOP_MODE, OTS_ITEM_TYPES.STRING, frmStopModeDialog.StopMode))    // Prop值变化,修改样品值成功
+                    {
+
+                        m_measurePara.GetWorkSamplePerameter(m_measurePara.GetWorkSample(), ref SMInfo);
+
+
                         DisplaySampleMeasureInfo(SMInfo);
                         return;
                     }
@@ -184,7 +203,7 @@ namespace OTSMeasureApp
            
             }
 
-            //---after modify the value of current sample properties,update the corresponding value of HMI.---
+            //---after modify the value of current sample properties,update the corresponding value of GUI.---
 
             if (OTS_SAMPLE_PROP_GRID_ITEMS.IMAGE_GRP_MAX == SampleId
                    || OTS_SAMPLE_PROP_GRID_ITEMS.MAGNIFICATION == SampleId
@@ -217,16 +236,9 @@ namespace OTSMeasureApp
             }
 
          
-           
-            m_measurePara.UpdateGroupValAndItemVal(SampleId);
-
-            sWSampleName = m_measurePara.GetWorkSampleName();
-          
-            m_MeasureAppForm.m_SamplepaceWindow.ChangeWorkSampleName(sWSampleName);
           
-
-           
-
+            m_measurePara.UpdateGroupValAndItemVal(SampleId);
+            //update the source grid value
             DisplaySampleMeasureInfo(SMInfo);
 
 
@@ -251,9 +263,10 @@ namespace OTSMeasureApp
             if(m_SampleGrid.m_ClickRow>=0 && m_SampleGrid.m_ClickColumn>=0)
             {
                 m_SampleGrid.SetGridTitleStatus();
-                if(m_MeasureAppForm.m_ProjData.m_systemTypeId == otsdataconst.OTS_SysType_ID.CleannessA || m_MeasureAppForm.m_ProjData.m_systemTypeId == otsdataconst.OTS_SysType_ID.MiningA)
+                if(m_MeasureAppForm.m_ProjData.m_systemTypeId == otsdataconst.OTS_SysType_ID.CleannessA )
                 {
-                    if (m_SampleGrid.m_ClickRow == 7 && m_SampleGrid.m_ClickColumn == 2)
+                    const int CleannessASysStopModeGridRowPos = 7;
+                    if (m_SampleGrid.m_ClickRow == CleannessASysStopModeGridRowPos && m_SampleGrid.m_ClickColumn == 2)
                     {
                         frmStopModeDialog = new frmMeasureStopMode();
                         frmStopModeDialog.FieldMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value.ToString());
@@ -281,7 +294,8 @@ namespace OTSMeasureApp
                 }
                 else
                 {
-                    if (m_SampleGrid.m_ClickRow == 9 && m_SampleGrid.m_ClickColumn == 2)
+                    const int IncASysStopModeGridRowPos = 9;
+                    if (m_SampleGrid.m_ClickRow == IncASysStopModeGridRowPos && m_SampleGrid.m_ClickColumn == 2)
                     {
                         frmStopModeDialog = new frmMeasureStopMode();
                         frmStopModeDialog.FieldMode = int.Parse(PropGrid[m_SampleGrid.m_ClickRow + 2, m_SampleGrid.m_ClickColumn].Value.ToString());