Prechádzať zdrojové kódy

样品台编辑器初步完成

CXS 3 rokov pred
rodič
commit
8eccd8f089

+ 8 - 83
OTSIncAMeasureApp/0-OTSModel/Measure/ParamData/StageParam.cs

@@ -5,7 +5,7 @@ using System.IO;
 using System.Windows.Forms;
 using System.Xml;
 using OTSDataType;
-
+using OTSMeasureApp._7_OTSProgMgrInfo.Stage;
 using static OTSDataType.otsdataconst;
 
 namespace OTSModelSharp
@@ -14,7 +14,7 @@ namespace OTSModelSharp
     {
         protected static NLog.Logger logger = null;
 
-    
+        StageDisplayHelp stageDisplayHelp;
 
         // modify flag
         bool m_bModify;
@@ -30,11 +30,7 @@ namespace OTSModelSharp
 
         // SEM stage data
         CSEMStageData m_pStageData;
-
-        const int DOMAIN_ITEM_NUMBER = 5;
-
-         const int TEXTFILE_ITEM_COLUMN_NUMBER = 2;
-                
+        const int TEXTFILE_ITEM_COLUMN_NUMBER = 2; 
         public const int HOLE_ITEM_NUMBER = 6;
         public enum COORDINATE_SYSTEM_SETTING
         {
@@ -72,7 +68,7 @@ namespace OTSModelSharp
             m_strPathName = "";
             m_nWorkingStageId = -1;
             m_listStages.Clear();
-          
+            stageDisplayHelp = new StageDisplayHelp();
         }
 
 
@@ -139,7 +135,7 @@ namespace OTSModelSharp
                 if (strTitle.CompareTo(STAGE_ITEMS.BOUNDARY.ToString()) == 0)
                 {
                     // get boundary
-                    CDomain pDomain = GetDomain(strValue);
+                    CDomain pDomain = stageDisplayHelp.GetDomain(strValue);
                     if (pDomain != null)
                     {
                         pBoundary = pDomain;
@@ -159,7 +155,7 @@ namespace OTSModelSharp
                 if (strTitle.CompareTo(STAGE_ITEMS.STD.ToString()) == 0)
                 {
                     // get STD
-                    CDomain pDomain = GetDomain(strValue);
+                    CDomain pDomain = stageDisplayHelp.GetDomain(strValue);
                     if (pDomain != null)
                     {
                         pSTD = pDomain;
@@ -295,78 +291,7 @@ namespace OTSModelSharp
 
        
 
-        // get domain
-        public CDomain GetDomain(String a_strValue)
-        {
-            // domain
-            CDomain pDomain = null;
-
-            // check value string
-            a_strValue.Trim();
-            if (a_strValue == "")
-            {
-                return pDomain;
-            }
-
-            // split the value string   
-            List<string> listStr = new List<string>(a_strValue.Split(','));
-      
-           
-            pDomain = GetDomain(listStr);
-            // return the domain pointer
-            return pDomain;
-        }
-      CDomain  GetDomain(List<string> a_listString)
-        {
-            // domain
-            CDomain pDomain = null;
-
-            // check value string list size
-            if ((int)a_listString.Count != DOMAIN_ITEM_NUMBER)
-            {
-                return pDomain;
-            }
-
-            // shape 
-            int nValue;
-            string strValue = a_listString[0];
-            nValue = Convert.ToInt32(strValue);
-            
-            // check the shape value
-            if (nValue < (int)DOMAIN_SHAPE.ROUND || nValue > (int)DOMAIN_SHAPE.RECTANGLE)
-            {
-                return pDomain;
-            }
-            DOMAIN_SHAPE nShape = (DOMAIN_SHAPE)nValue;
-
-            // position 
-            strValue = a_listString[1];
-            nValue = Convert.ToInt32(strValue);
-            int nCentreX = nValue;
-            strValue = a_listString[2];
-            nValue = Convert.ToInt32(strValue);
-            int nCentreY = nValue;
-
-            // diameter/width
-            strValue = a_listString[3];
-            nValue = Convert.ToInt32(strValue);
-            int nDiameter_Width = nValue;
-
-            // height/spare
-            strValue = a_listString[4];
-            if (nShape == DOMAIN_SHAPE.RECTANGLE)
-            {
-                nValue = Convert.ToInt32(strValue);
-            }
-            int nDiameter_nHeight = nValue;
-
-            // create domain
-            Rectangle rectDomain=new Rectangle(0, 0, nDiameter_Width, nDiameter_nHeight);
-            pDomain = new CDomain(nShape, rectDomain);
-            pDomain.OffsetDomain(new Point(nCentreX - (nDiameter_Width / 2), nCentreY - (nDiameter_nHeight / 2)));
-            // return the domain pointer
-            return pDomain;
-        }
+        
         // get Hole
         public CHole GetHole(string strName,String a_strValue)  
         {
@@ -392,7 +317,7 @@ namespace OTSModelSharp
             int indexOf = a_strValue.IndexOf(',');
             a_strValue = a_strValue.Substring(indexOf + 1, a_strValue.Length - indexOf - 1);
             // domain
-            CDomain pDomain = GetDomain(a_strValue);
+            CDomain pDomain = stageDisplayHelp.GetDomain(a_strValue);
 
             // check the domain
             if (pDomain == null)

+ 73 - 52
OTSIncAMeasureApp/7-OTSProgMgrInfo/Stage/DlgStageEdit.Designer.cs

@@ -58,7 +58,7 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.tStandardsampleX = new System.Windows.Forms.TextBox();
             this.label12 = new System.Windows.Forms.Label();
             this.label13 = new System.Windows.Forms.Label();
-            this.radioButton__StandardsampleSqare = new System.Windows.Forms.RadioButton();
+            this.radioButton_StandardsampleSqare = new System.Windows.Forms.RadioButton();
             this.radioButton_StandardsampleCircle = new System.Windows.Forms.RadioButton();
             this.label14 = new System.Windows.Forms.Label();
             this.button_Generate = new System.Windows.Forms.Button();
@@ -66,6 +66,7 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.button_AddHole = new System.Windows.Forms.Button();
             this.button_DelHole = new System.Windows.Forms.Button();
             this.groupBox3 = new System.Windows.Forms.GroupBox();
+            this.button_Ok = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.m_ctrlStagePicture)).BeginInit();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
@@ -76,10 +77,10 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // m_ctrlStagePicture
             // 
             this.m_ctrlStagePicture.BackColor = System.Drawing.Color.White;
-            this.m_ctrlStagePicture.Location = new System.Drawing.Point(831, 13);
-            this.m_ctrlStagePicture.Margin = new System.Windows.Forms.Padding(4);
+            this.m_ctrlStagePicture.Location = new System.Drawing.Point(831, 14);
+            this.m_ctrlStagePicture.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.m_ctrlStagePicture.Name = "m_ctrlStagePicture";
-            this.m_ctrlStagePicture.Size = new System.Drawing.Size(917, 848);
+            this.m_ctrlStagePicture.Size = new System.Drawing.Size(916, 848);
             this.m_ctrlStagePicture.TabIndex = 2;
             this.m_ctrlStagePicture.TabStop = false;
             // 
@@ -129,11 +130,12 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.radioButton_SEM.TabStop = true;
             this.radioButton_SEM.Text = "SEM坐标系统";
             this.radioButton_SEM.UseVisualStyleBackColor = true;
+            this.radioButton_SEM.Visible = false;
             // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(19, 37);
+            this.label3.Location = new System.Drawing.Point(20, 38);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(152, 18);
             this.label3.TabIndex = 8;
@@ -164,13 +166,13 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             this.tBoundaryHeight.Location = new System.Drawing.Point(534, 114);
             this.tBoundaryHeight.Name = "tBoundaryHeight";
-            this.tBoundaryHeight.Size = new System.Drawing.Size(123, 28);
+            this.tBoundaryHeight.Size = new System.Drawing.Size(122, 28);
             this.tBoundaryHeight.TabIndex = 19;
             // 
             // label8
             // 
             this.label8.AutoSize = true;
-            this.label8.Location = new System.Drawing.Point(449, 117);
+            this.label8.Location = new System.Drawing.Point(448, 117);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(62, 18);
             this.label8.TabIndex = 18;
@@ -178,15 +180,15 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // tBoundaryWide
             // 
-            this.tBoundaryWide.Location = new System.Drawing.Point(534, 71);
+            this.tBoundaryWide.Location = new System.Drawing.Point(534, 70);
             this.tBoundaryWide.Name = "tBoundaryWide";
-            this.tBoundaryWide.Size = new System.Drawing.Size(123, 28);
+            this.tBoundaryWide.Size = new System.Drawing.Size(122, 28);
             this.tBoundaryWide.TabIndex = 17;
             // 
             // label7
             // 
             this.label7.AutoSize = true;
-            this.label7.Location = new System.Drawing.Point(449, 74);
+            this.label7.Location = new System.Drawing.Point(448, 74);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(62, 18);
             this.label7.TabIndex = 16;
@@ -194,9 +196,9 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // tBoundaryY
             // 
-            this.tBoundaryY.Location = new System.Drawing.Point(227, 114);
+            this.tBoundaryY.Location = new System.Drawing.Point(226, 114);
             this.tBoundaryY.Name = "tBoundaryY";
-            this.tBoundaryY.Size = new System.Drawing.Size(123, 28);
+            this.tBoundaryY.Size = new System.Drawing.Size(122, 28);
             this.tBoundaryY.TabIndex = 15;
             // 
             // label6
@@ -210,9 +212,9 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // tBoundaryX
             // 
-            this.tBoundaryX.Location = new System.Drawing.Point(227, 71);
+            this.tBoundaryX.Location = new System.Drawing.Point(226, 70);
             this.tBoundaryX.Name = "tBoundaryX";
-            this.tBoundaryX.Size = new System.Drawing.Size(123, 28);
+            this.tBoundaryX.Size = new System.Drawing.Size(122, 28);
             this.tBoundaryX.TabIndex = 13;
             // 
             // label5
@@ -236,7 +238,7 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // radioButton_BoundarySquare
             // 
             this.radioButton_BoundarySquare.AutoSize = true;
-            this.radioButton_BoundarySquare.Location = new System.Drawing.Point(281, 35);
+            this.radioButton_BoundarySquare.Location = new System.Drawing.Point(280, 34);
             this.radioButton_BoundarySquare.Name = "radioButton_BoundarySquare";
             this.radioButton_BoundarySquare.Size = new System.Drawing.Size(69, 22);
             this.radioButton_BoundarySquare.TabIndex = 10;
@@ -248,7 +250,7 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // radioButton_BoundaryCircle
             // 
             this.radioButton_BoundaryCircle.AutoSize = true;
-            this.radioButton_BoundaryCircle.Location = new System.Drawing.Point(189, 35);
+            this.radioButton_BoundaryCircle.Location = new System.Drawing.Point(189, 34);
             this.radioButton_BoundaryCircle.Name = "radioButton_BoundaryCircle";
             this.radioButton_BoundaryCircle.Size = new System.Drawing.Size(69, 22);
             this.radioButton_BoundaryCircle.TabIndex = 9;
@@ -268,12 +270,12 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.groupBox2.Controls.Add(this.tStandardsampleX);
             this.groupBox2.Controls.Add(this.label12);
             this.groupBox2.Controls.Add(this.label13);
-            this.groupBox2.Controls.Add(this.radioButton__StandardsampleSqare);
+            this.groupBox2.Controls.Add(this.radioButton_StandardsampleSqare);
             this.groupBox2.Controls.Add(this.radioButton_StandardsampleCircle);
             this.groupBox2.Controls.Add(this.label14);
-            this.groupBox2.Location = new System.Drawing.Point(6, 269);
+            this.groupBox2.Location = new System.Drawing.Point(6, 268);
             this.groupBox2.Name = "groupBox2";
-            this.groupBox2.Size = new System.Drawing.Size(806, 161);
+            this.groupBox2.Size = new System.Drawing.Size(806, 160);
             this.groupBox2.TabIndex = 13;
             this.groupBox2.TabStop = false;
             this.groupBox2.Text = "标样";
@@ -282,13 +284,13 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             this.tStandardsampleHeight.Location = new System.Drawing.Point(534, 114);
             this.tStandardsampleHeight.Name = "tStandardsampleHeight";
-            this.tStandardsampleHeight.Size = new System.Drawing.Size(123, 28);
+            this.tStandardsampleHeight.Size = new System.Drawing.Size(122, 28);
             this.tStandardsampleHeight.TabIndex = 19;
             // 
             // label9
             // 
             this.label9.AutoSize = true;
-            this.label9.Location = new System.Drawing.Point(449, 117);
+            this.label9.Location = new System.Drawing.Point(448, 117);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(62, 18);
             this.label9.TabIndex = 18;
@@ -296,15 +298,15 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // tStandardsampleWide
             // 
-            this.tStandardsampleWide.Location = new System.Drawing.Point(534, 71);
+            this.tStandardsampleWide.Location = new System.Drawing.Point(534, 70);
             this.tStandardsampleWide.Name = "tStandardsampleWide";
-            this.tStandardsampleWide.Size = new System.Drawing.Size(123, 28);
+            this.tStandardsampleWide.Size = new System.Drawing.Size(122, 28);
             this.tStandardsampleWide.TabIndex = 17;
             // 
             // label10
             // 
             this.label10.AutoSize = true;
-            this.label10.Location = new System.Drawing.Point(449, 74);
+            this.label10.Location = new System.Drawing.Point(448, 74);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(62, 18);
             this.label10.TabIndex = 16;
@@ -312,9 +314,9 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // tStandardsampleY
             // 
-            this.tStandardsampleY.Location = new System.Drawing.Point(227, 114);
+            this.tStandardsampleY.Location = new System.Drawing.Point(226, 114);
             this.tStandardsampleY.Name = "tStandardsampleY";
-            this.tStandardsampleY.Size = new System.Drawing.Size(123, 28);
+            this.tStandardsampleY.Size = new System.Drawing.Size(122, 28);
             this.tStandardsampleY.TabIndex = 15;
             // 
             // label11
@@ -328,9 +330,9 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // tStandardsampleX
             // 
-            this.tStandardsampleX.Location = new System.Drawing.Point(227, 71);
+            this.tStandardsampleX.Location = new System.Drawing.Point(226, 70);
             this.tStandardsampleX.Name = "tStandardsampleX";
-            this.tStandardsampleX.Size = new System.Drawing.Size(123, 28);
+            this.tStandardsampleX.Size = new System.Drawing.Size(122, 28);
             this.tStandardsampleX.TabIndex = 13;
             // 
             // label12
@@ -351,22 +353,22 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.label13.TabIndex = 11;
             this.label13.Text = "中心点坐标:";
             // 
-            // radioButton__StandardsampleSqare
+            // radioButton_StandardsampleSqare
             // 
-            this.radioButton__StandardsampleSqare.AutoSize = true;
-            this.radioButton__StandardsampleSqare.Location = new System.Drawing.Point(281, 35);
-            this.radioButton__StandardsampleSqare.Name = "radioButton__StandardsampleSqare";
-            this.radioButton__StandardsampleSqare.Size = new System.Drawing.Size(69, 22);
-            this.radioButton__StandardsampleSqare.TabIndex = 10;
-            this.radioButton__StandardsampleSqare.TabStop = true;
-            this.radioButton__StandardsampleSqare.Text = "方形";
-            this.radioButton__StandardsampleSqare.UseVisualStyleBackColor = true;
-            this.radioButton__StandardsampleSqare.Click += new System.EventHandler(this.radioButton__StandardsampleSqare_Click);
+            this.radioButton_StandardsampleSqare.AutoSize = true;
+            this.radioButton_StandardsampleSqare.Location = new System.Drawing.Point(280, 34);
+            this.radioButton_StandardsampleSqare.Name = "radioButton_StandardsampleSqare";
+            this.radioButton_StandardsampleSqare.Size = new System.Drawing.Size(69, 22);
+            this.radioButton_StandardsampleSqare.TabIndex = 10;
+            this.radioButton_StandardsampleSqare.TabStop = true;
+            this.radioButton_StandardsampleSqare.Text = "方形";
+            this.radioButton_StandardsampleSqare.UseVisualStyleBackColor = true;
+            this.radioButton_StandardsampleSqare.Click += new System.EventHandler(this.radioButton__StandardsampleSqare_Click);
             // 
             // radioButton_StandardsampleCircle
             // 
             this.radioButton_StandardsampleCircle.AutoSize = true;
-            this.radioButton_StandardsampleCircle.Location = new System.Drawing.Point(189, 35);
+            this.radioButton_StandardsampleCircle.Location = new System.Drawing.Point(189, 34);
             this.radioButton_StandardsampleCircle.Name = "radioButton_StandardsampleCircle";
             this.radioButton_StandardsampleCircle.Size = new System.Drawing.Size(69, 22);
             this.radioButton_StandardsampleCircle.TabIndex = 9;
@@ -378,7 +380,7 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // label14
             // 
             this.label14.AutoSize = true;
-            this.label14.Location = new System.Drawing.Point(19, 37);
+            this.label14.Location = new System.Drawing.Point(20, 38);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(98, 18);
             this.label14.TabIndex = 8;
@@ -386,12 +388,13 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             // 
             // button_Generate
             // 
-            this.button_Generate.Location = new System.Drawing.Point(848, 879);
+            this.button_Generate.Location = new System.Drawing.Point(831, 876);
             this.button_Generate.Name = "button_Generate";
-            this.button_Generate.Size = new System.Drawing.Size(898, 44);
+            this.button_Generate.Size = new System.Drawing.Size(699, 44);
             this.button_Generate.TabIndex = 16;
             this.button_Generate.Text = "生成";
             this.button_Generate.UseVisualStyleBackColor = true;
+            this.button_Generate.Click += new System.EventHandler(this.button_Generate_Click);
             // 
             // dataGridView_Holes
             // 
@@ -405,43 +408,60 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.dataGridView_Holes.Name = "dataGridView_Holes";
             this.dataGridView_Holes.RowHeadersVisible = false;
             this.dataGridView_Holes.RowHeadersWidth = 62;
-            this.dataGridView_Holes.RowTemplate.Height = 30;
-            this.dataGridView_Holes.Size = new System.Drawing.Size(773, 466);
+            this.dataGridView_Holes.RowTemplate.Height = 20;
+            this.dataGridView_Holes.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
+            this.dataGridView_Holes.Size = new System.Drawing.Size(772, 467);
             this.dataGridView_Holes.TabIndex = 17;
+            this.dataGridView_Holes.CurrentCellChanged += new System.EventHandler(this.dataGridView_Holes_CurrentCellChanged);
+            this.dataGridView_Holes.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dataGridView_Holes_Scroll);
             // 
             // button_AddHole
             // 
             this.button_AddHole.Location = new System.Drawing.Point(788, 454);
             this.button_AddHole.Name = "button_AddHole";
-            this.button_AddHole.Size = new System.Drawing.Size(34, 127);
+            this.button_AddHole.Size = new System.Drawing.Size(34, 128);
             this.button_AddHole.TabIndex = 18;
             this.button_AddHole.Text = "增加样品孔";
             this.button_AddHole.UseVisualStyleBackColor = true;
+            this.button_AddHole.Click += new System.EventHandler(this.button_AddHole_Click);
             // 
             // button_DelHole
             // 
-            this.button_DelHole.Location = new System.Drawing.Point(788, 587);
+            this.button_DelHole.Location = new System.Drawing.Point(788, 586);
             this.button_DelHole.Name = "button_DelHole";
-            this.button_DelHole.Size = new System.Drawing.Size(34, 127);
+            this.button_DelHole.Size = new System.Drawing.Size(34, 128);
             this.button_DelHole.TabIndex = 19;
             this.button_DelHole.Text = "删除样品孔";
             this.button_DelHole.UseVisualStyleBackColor = true;
+            this.button_DelHole.Click += new System.EventHandler(this.button_DelHole_Click);
             // 
             // groupBox3
             // 
             this.groupBox3.Controls.Add(this.dataGridView_Holes);
             this.groupBox3.Location = new System.Drawing.Point(6, 430);
             this.groupBox3.Name = "groupBox3";
-            this.groupBox3.Size = new System.Drawing.Size(779, 493);
+            this.groupBox3.Size = new System.Drawing.Size(778, 494);
             this.groupBox3.TabIndex = 20;
             this.groupBox3.TabStop = false;
             this.groupBox3.Text = "样品孔信息:";
             // 
+            // button_Ok
+            // 
+            this.button_Ok.Enabled = false;
+            this.button_Ok.Location = new System.Drawing.Point(1570, 876);
+            this.button_Ok.Name = "button_Ok";
+            this.button_Ok.Size = new System.Drawing.Size(177, 44);
+            this.button_Ok.TabIndex = 21;
+            this.button_Ok.Text = "保存";
+            this.button_Ok.UseVisualStyleBackColor = true;
+            this.button_Ok.Click += new System.EventHandler(this.button_Ok_Click);
+            // 
             // DlgStageEdit
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
-            this.ClientSize = new System.Drawing.Size(1758, 935);
+            this.ClientSize = new System.Drawing.Size(1755, 927);
+            this.Controls.Add(this.button_Ok);
             this.Controls.Add(this.button_DelHole);
             this.Controls.Add(this.groupBox3);
             this.Controls.Add(this.button_Generate);
@@ -455,9 +475,9 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
             this.Controls.Add(this.label1);
             this.Controls.Add(this.m_ctrlStagePicture);
             this.MaximizeBox = false;
-            this.MaximumSize = new System.Drawing.Size(1780, 991);
+            this.MaximumSize = new System.Drawing.Size(1777, 983);
             this.MinimizeBox = false;
-            this.MinimumSize = new System.Drawing.Size(1780, 991);
+            this.MinimumSize = new System.Drawing.Size(1274, 678);
             this.Name = "DlgStageEdit";
             this.ShowIcon = false;
             this.ShowInTaskbar = false;
@@ -507,7 +527,7 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
         private System.Windows.Forms.TextBox tStandardsampleX;
         private System.Windows.Forms.Label label12;
         private System.Windows.Forms.Label label13;
-        private System.Windows.Forms.RadioButton radioButton__StandardsampleSqare;
+        private System.Windows.Forms.RadioButton radioButton_StandardsampleSqare;
         private System.Windows.Forms.RadioButton radioButton_StandardsampleCircle;
         private System.Windows.Forms.Label label14;
         private System.Windows.Forms.Button button_Generate;
@@ -515,5 +535,6 @@ namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
         private System.Windows.Forms.Button button_AddHole;
         private System.Windows.Forms.Button button_DelHole;
         private System.Windows.Forms.GroupBox groupBox3;
+        private System.Windows.Forms.Button button_Ok;
     }
 }

+ 430 - 53
OTSIncAMeasureApp/7-OTSProgMgrInfo/Stage/DlgStageEdit.cs

@@ -1,106 +1,483 @@
-using System;
+using OTSDataType;
+using OTSModelSharp;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
+using System.Drawing.Drawing2D;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using OTSModelSharp.Measure.GetStageInfo;
 
 namespace OTSMeasureApp._7_OTSProgMgrInfo.Stage
 {
     public partial class DlgStageEdit : Form
     {
+        // stage file
+        CStageParam m_pStageFile;
+        public CStage m_pStage;
+        StageDisplayHelp stageDisplayHelp;
         public DlgStageEdit()
         {
             InitializeComponent();
         }
-
+        
+        public DlgStageEdit(CStage cStage)
+        {
+            InitializeComponent();
+            m_pStage = cStage;
+        }
+        ComboBox cmb_Temp = new ComboBox();
         private void DlgStageEdit_Load(object sender, EventArgs e)
         {
             radioButton_OTS.Checked = true;
             radioButton_BoundarySquare.Checked = true;
-            radioButton__StandardsampleSqare.Checked = true;
+            radioButton_StandardsampleSqare.Checked = true;
             dataGridView_Holes.Columns.Add("HoleName", "样品孔名称");
-            //dataGridView_Holes.Columns.Add("HoleShape", "样品孔形状");
-            DataGridViewComboBoxColumn HoleShape = new DataGridViewComboBoxColumn();//新建一个列,列的类型是DataGridViewComboBoxColumn
-            HoleShape.HeaderText = "样品孔形状";
-            HoleShape.Items.Add("圆形");//下拉列表选项
-            HoleShape.Items.Add("方形");
-            HoleShape.DefaultCellStyle.NullValue = HoleShape.Items[0];
-            dataGridView_Holes.Columns.Add(HoleShape);//把d这个列添加到datagridview里
+            dataGridView_Holes.Columns.Add("HoleShape", "样品孔形状");
             dataGridView_Holes.Columns.Add("CenterCoordinatesX", "中心x坐标");
             dataGridView_Holes.Columns.Add("CenterCoordinatesY", "中心y坐标");
             dataGridView_Holes.Columns.Add("Param1", "宽度或直径");
             dataGridView_Holes.Columns.Add("Param2", "高度或0");
-            dataGridView_Holes.Rows.Add("", HoleShape.Items[0], "", "", "", "");
+            dataGridView_Holes.Rows.Add("1", "圆形", -4250, -16000, 12000, 0);
             //SetDataGridViewStyle();
+            cmb_Temp.Visible = false;
+            cmb_Temp.Items.Add("圆形");
+            cmb_Temp.Items.Add("方形");
+            cmb_Temp.SelectedIndexChanged += new EventHandler(cmb_Temp_SelectedIndexChanged);
+            dataGridView_Holes.Controls.Add(cmb_Temp);
+            stageDisplayHelp = new StageDisplayHelp();
+            if(m_pStage!=null)
+            {
+                LoadStageData(m_pStage);
+            }
+        }
+        void LoadStageData(CStage cStage)
+        {
+            tStageName.Text = m_pStage.GetName();
+            if(m_pStage.GetBoundary().GetShape()== otsdataconst.DOMAIN_SHAPE.ROUND)
+            {
+                radioButton_BoundaryCircle.Checked = true;
+                tBoundaryWide.Text = m_pStage.GetBoundary().GetDiameter().ToString();
+                tBoundaryHeight.Text = "0";
+            }
+            else
+            {
+                radioButton_BoundarySquare.Checked = true;
+                tBoundaryWide.Text = m_pStage.GetBoundary().GetRectDomain().Width.ToString();
+                tBoundaryHeight.Text = m_pStage.GetBoundary().GetRectDomain().Height.ToString();
+            }
+            tBoundaryX.Text= m_pStage.GetBoundary().GetDomainCenter().X.ToString();
+            tBoundaryY.Text = m_pStage.GetBoundary().GetDomainCenter().Y.ToString();
+            if(m_pStage.GetSTD().GetShape()== otsdataconst.DOMAIN_SHAPE.ROUND)
+            {
+                radioButton_StandardsampleCircle.Checked = true;
+                tStandardsampleWide.Text = m_pStage.GetSTD().GetDiameter().ToString();
+            }
+            else
+            {
+                radioButton_StandardsampleSqare.Checked = true;
+                tStandardsampleWide.Text = m_pStage.GetSTD().GetRectDomain().Width.ToString();
+            }
+            tStandardsampleX.Text = m_pStage.GetSTD().GetDomainCenter().X.ToString();
+            tStandardsampleY.Text = m_pStage.GetSTD().GetDomainCenter().Y.ToString();
+            tStandardsampleHeight.Text = m_pStage.GetSTD().GetRectDomain().Height.ToString();
+            dataGridView_Holes.Rows[0].Cells[0].Value = m_pStage.GetHoleList()[0].GetName();
+            if (m_pStage.GetHoleList()[0].GetShape() == otsdataconst.DOMAIN_SHAPE.ROUND)
+            {
+                dataGridView_Holes.Rows[0].Cells[1].Value = "圆形";
+                dataGridView_Holes.Rows[0].Cells[4].Value = m_pStage.GetHoleList()[0].GetDiameter().ToString();
+                dataGridView_Holes.Rows[0].Cells[5].Value = "0";
+            }
+            else
+            {
+                dataGridView_Holes.Rows[0].Cells[1].Value = "方形";
+                dataGridView_Holes.Rows[0].Cells[4].Value = m_pStage.GetHoleList()[0].GetRectDomain().Width.ToString();
+                dataGridView_Holes.Rows[0].Cells[5].Value = m_pStage.GetHoleList()[0].GetRectDomain().Height.ToString();
+            }
+            
+            dataGridView_Holes.Rows[0].Cells[2].Value = m_pStage.GetHoleList()[0].GetDomainCenter().X.ToString();
+            dataGridView_Holes.Rows[0].Cells[3].Value = m_pStage.GetHoleList()[0].GetDomainCenter().Y.ToString();
+            
+            for (int i=1;i< m_pStage.GetHoleList().Count;i++)
+            {
+                string sr = "";
+                string pra1 = "";
+                string pra2 = "";
+                if (m_pStage.GetHoleList()[i].GetShape() == otsdataconst.DOMAIN_SHAPE.ROUND)
+                {
+                    sr= "圆形";
+                    pra1 = m_pStage.GetHoleList()[i].GetDiameter().ToString();
+                    pra2 = "0";
+                }
+                else
+                {
+                    sr= "方形";
+                    pra1 = m_pStage.GetHoleList()[i].GetRectDomain().Width.ToString();
+                    pra2 = m_pStage.GetHoleList()[i].GetRectDomain().Height.ToString();
+                }
+                dataGridView_Holes.Rows.Add(m_pStage.GetHoleList()[i].GetName(), sr, m_pStage.GetHoleList()[i].GetDomainCenter().X.ToString(), m_pStage.GetHoleList()[i].GetDomainCenter().Y.ToString(), pra1, pra2);
+            }
+        }
+        private void radioButton_BoundaryCircle_Click(object sender, EventArgs e)
+        {
+            label8.Enabled = false;
+            tBoundaryHeight.Enabled = false;
+            tBoundaryHeight.Text = "0";
+            label7.Text = "半径:";
+        }
+
+        private void radioButton_BoundarySquare_Click(object sender, EventArgs e)
+        {
+            label8.Enabled = true;
+            tBoundaryHeight.Enabled = true;
+            label7.Text = "宽度:";
+        }
+
+        private void radioButton_StandardsampleCircle_Click(object sender, EventArgs e)
+        {
+            label9.Enabled = false;
+            tStandardsampleHeight.Enabled = false;
+            tStandardsampleHeight.Text = "0";
+            label10.Text = "半径:";
+        }
+
+        private void radioButton__StandardsampleSqare_Click(object sender, EventArgs e)
+        {
+            label9.Enabled = true;
+            tStandardsampleHeight.Enabled = true;
+            label10.Text = "宽度:";
+        }
+
+        private void dataGridView_Holes_CurrentCellChanged(object sender, EventArgs e)
+        {
+            if(dataGridView_Holes.CurrentRow==null)
+            {
+                return;
+            }
+            if(dataGridView_Holes.CurrentCell.ColumnIndex==1)
+            {
+                Rectangle rect = dataGridView_Holes.GetCellDisplayRectangle(dataGridView_Holes.CurrentCell.ColumnIndex, dataGridView_Holes.CurrentCell.RowIndex, false);
+                string HoleShape = dataGridView_Holes.CurrentCell.Value.ToString();
+                cmb_Temp.Left = rect.Left;
+                cmb_Temp.Top = rect.Top;
+                cmb_Temp.Width = rect.Width;
+                cmb_Temp.SelectedIndex = 0;
+                cmb_Temp.Visible = true;
+            }
+            else
+            {
+                cmb_Temp.Visible = false;
+            }
         }
-        private void SetDataGridViewStyle()
+        void cmb_Temp_SelectedIndexChanged(object sender ,EventArgs e)
         {
-            //用户不能调整标题的高度
-            dataGridView_Holes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+            
+                if (dataGridView_Holes.CurrentRow == null)
+                {
+                    return;
+                }
+                if (((ComboBox)sender).SelectedIndex == 0)
+                {
+                    dataGridView_Holes.CurrentCell.Value = "圆形";
+                    dataGridView_Holes.CurrentRow.Cells[5].Value = 0;
+                }
+                else
+                {
+                    dataGridView_Holes.CurrentCell.Value = "方形";
+                    dataGridView_Holes.CurrentRow.Cells[5].Value = "";
+                }
+     
+        }
 
-            //用户不能调整 行高
-            dataGridView_Holes.AllowUserToResizeRows = false;
+        private void dataGridView_Holes_Scroll(object sender, ScrollEventArgs e)
+        {
+            this.cmb_Temp.Visible = false;
+        }
 
-            //点击选择整行
-            //dataGridView_Holes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
+        private void button_Generate_Click(object sender, EventArgs e)
+        {
+            if (!CheckParams())
+            {
+                this.button_Ok.Enabled = false;
+                return;
+            }
+            CSEMStageData a_pCSEMStageData = new CSEMStageData();
+            //获取配置文件中 StageData 内容
+            COTSDefaultParam m_DefaultParam = new COTSDefaultParam();
+            m_DefaultParam.LoadInfoFromProgMgrFile();
+            a_pCSEMStageData = m_DefaultParam.GetStageDataParam();
 
-            //居中显示
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
-            dataGridView_Holes.DefaultCellStyle = dataGridViewCellStyle1;
-            dataGridView_Holes.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
+            m_pStage = new CStage();
+            m_pStage.SetName(tStageName.Text);
+            // boundary
+            string strValue = "";
+            if(radioButton_BoundaryCircle.Checked)
+            {
+                strValue += "0";
+                tBoundaryHeight.Text="0";
+            }
+            else
+            {
+                strValue += "1";
+            }
+            strValue += "," + tBoundaryX.Text+","+tBoundaryY.Text+","+tBoundaryWide.Text+","+ tBoundaryHeight.Text;
+            CDomain pBoundary = stageDisplayHelp.GetDomain(strValue);
+            // STD
+            strValue = "";
+            if(radioButton_StandardsampleCircle.Checked)
+            {
+                strValue += "0";
+                tStandardsampleHeight.Text = "0";
+            }
+            else
+            {
+                strValue += "1";
+            }
+            strValue += "," + tStandardsampleX.Text + "," + tStandardsampleY.Text + "," + tStandardsampleWide.Text + "," + tStandardsampleHeight.Text;
+            CDomain pSTD = stageDisplayHelp.GetDomain(strValue);
+            // coordinate system
+            CStageParam.COORDINATE_SYSTEM_SETTING nCoodrSysSetting = CStageParam.COORDINATE_SYSTEM_SETTING.INVALID;
+            if(radioButton_OTS.Checked)
+            {
+                nCoodrSysSetting = (CStageParam.COORDINATE_SYSTEM_SETTING)0;
+            }
+            else
+            {
+                nCoodrSysSetting = (CStageParam.COORDINATE_SYSTEM_SETTING)1;
+            }
+            // Holes list
+            List<CHole> listHoles = new List<CHole>();
+            for(int i=0;i<dataGridView_Holes.Rows.Count;i++)
+            {
+                strValue = "";
+                if(dataGridView_Holes.Rows[i].Cells[1].Value=="圆形")
+                {
+                    strValue += "0";
+                }
+                else
+                {
+                    strValue += "1";
+                }
+                strValue += ","+ dataGridView_Holes.Rows[i].Cells[2].Value + "," + dataGridView_Holes.Rows[i].Cells[3].Value + "," + dataGridView_Holes.Rows[i].Cells[4].Value + "," + dataGridView_Holes.Rows[i].Cells[5].Value;
+                CDomain pDomain = stageDisplayHelp.GetDomain(strValue);
+                //add holes
+                listHoles.Add(new CHole(dataGridView_Holes.Rows[i].Cells[0].Value.ToString(), pDomain));
+            }
 
-            //再次重覆禁用拖动表头高度,居然有效果了
-            dataGridView_Holes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+            // check stage components
+            // name should be ok
+            if (pBoundary == null)
+            {
+                return ;
+            }
+            if (pBoundary.IsInvalid())
+            {
+                // boundary is invalid
+                return ;
+            }
+            if (pSTD != null)
+            {
+                // STD has to be inside of the boundary
+                if (!pBoundary.DomainInDomain(pSTD))
+                {
+                    // STD is over the boundary
+                    return ;
+                }
+            }
+            else
+            {
+                return ;
+            }
 
-            //设置grid可以复制
-            //dataGridView_Holes.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
+            // hole has to be inside of the boundary and can't have common part with STD and each other
+            List<CHole> listStageHoles = new List<CHole>();
+            foreach (var pHole in listHoles)
+            {
+                if (!pBoundary.DomainInDomain(pHole))
+                {
+                    // this hole is over the boundary, jump over
+                    continue;
+                }
+                else if (pSTD.IntersectDomain(pHole))
+                {
+                    // this hole has common part with STD, jump over
+                    continue;
+                }
+                bool bHasCommonPart = false;
+                foreach (var pStageHole in listStageHoles)
+                {
+                    if (pStageHole.IntersectDomain(pHole))
+                    {
+                        // this hole has common part with a hole already on the stage
+                        bHasCommonPart = true;
+                        break;
+                    }
+                }
+                if (bHasCommonPart)
+                {
+                    // this hole has common part with a hole already on the stage, jump over
+                    continue;
+                }
 
-            //设置每列的宽度
-            //dataGridView_Holes.Columns[0].Width = 100;//第一列序号的宽度设置一下吧,要不太丑
-            //dataGridView_Holes.Columns[1].Width = 150;
-            //dataGridView_Holes.Columns[dataGridView_Holes.Columns.Count - 1].Width = 450;
-            //dataGridView_Holes.Columns[dataGridView_Holes.Columns.Count - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
+                // the hole is ok, add it into stage holes list
+                listStageHoles.Add(pHole);
+            }
+            if (listStageHoles.Count == 0)
+            {
+                // no hole at all
+                return ;
+            }
 
-            //设置序号列不排序
-            dataGridView_Holes.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
+            // the stage is in SEM coordinate system, convert all components to OTS system 
+            if (nCoodrSysSetting == CStageParam.COORDINATE_SYSTEM_SETTING.SEM)
+            {
+                if (!a_pCSEMStageData.ConverSEMToOTSSystem(pBoundary, pSTD, listStageHoles))
+                {
+                    return ;
+                }
+            }
 
-            //设置序号列不可以设置宽度
-            //dataGridView_Holes.Columns[0].Resizable = DataGridViewTriState.False;
 
-            dataGridView_Holes.RowsDefaultCellStyle.BackColor = Color.Azure;
+            m_pStage.SetBoundary(pBoundary);
+            m_pStage.SetSTD(pSTD);
+            m_pStage.SetHoleList(listStageHoles, true);
+            DrawStage();
+            this.button_Ok.Enabled = true;
         }
 
-        private void radioButton_BoundaryCircle_Click(object sender, EventArgs e)
+        public void DrawStage()
         {
-            label8.Visible = false;
-            tBoundaryHeight.Visible = false;
-            label7.Text = "半径:";
+            Rectangle rc = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
+            Rectangle re = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
+            int pWnd = otsdataconst.IDC_PIC_STAGE;
+
+            int nWidth = (int)rc.Width;
+            int nHeight = (int)rc.Height;
+            Object pDC = new Object();
+
+            bool DeleteObject = false;
+            //paint the DC with white
+            Brush pOldBrush = new SolidBrush(Color.FromArgb(50, Color.White));
+            m_ctrlStagePicture.Refresh();
+            //Image img = (Image)new Bitmap(m_ctrlStagePicture.Width, m_ctrlStagePicture.Height);
+            //Graphics graphics = m_ctrlStagePicture.CreateGraphics();// Graphics.FromImage(img);
+            //graphics.FillRectangle(new SolidBrush(Color.Beige), re);
+            pDC = m_ctrlStagePicture.CreateGraphics();
+            //消除锯齿
+            ((Graphics)pDC).SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
+            ((Graphics)pDC).InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
+            ((Graphics)pDC).CompositingQuality = CompositingQuality.HighQuality;//再加一点
+                                                                                //get stage information              
+            CDomain pBoundery = m_pStage.GetBoundary();// GetBoundary();
+            System.Drawing.Rectangle BounderyRect = pBoundery.GetDomainRect();
+            int nBounderyWidth = (int)(BounderyRect.Width);//um,,pixle is (nWidth - PIC_EDGE * 2 )
+            int nBounderyHeight = (int)(BounderyRect.Height);
+            double PixSize = 0;
+            if (nBounderyWidth > nBounderyHeight)
+            {
+                PixSize = (long)((double)nBounderyWidth / (double)(nWidth - StageDisplayHelp.PIC_EDGE * 2));
+            }
+            else
+            {
+                PixSize = (long)((double)nBounderyHeight / (double)(nHeight - StageDisplayHelp.PIC_EDGE * 2));
+            }
+            //draw boundery
+            Brush pLTGrayBrush = new SolidBrush(Color.FromArgb(255, 0, 0));
+            stageDisplayHelp.DrawStageBoundery(m_pStage, nWidth, nHeight, pDC, PixSize);
+
+            ////draw STD
+            //Brush pBlackBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
+
+            //DrawStageSTD(m_pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
+
+            ////draw holes
+            //Brush pWriteBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
+
+            stageDisplayHelp.DrawStageHole(m_pStage, nWidth, nHeight, pDC, PixSize);
+
+            // draw ratio
+            stageDisplayHelp.DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
+
+            pLTGrayBrush.Dispose();
+            //pBlackBrush.Dispose();
+            //pWriteBrush.Dispose();
+            //graphics.Dispose();
+            //((Graphics)pDC).Dispose();
+            pOldBrush.Dispose();
+
         }
 
-        private void radioButton_BoundarySquare_Click(object sender, EventArgs e)
+        private void button_Ok_Click(object sender, EventArgs e)
         {
-            label8.Visible = true;
-            tBoundaryHeight.Visible = true;
-            label7.Text = "高度:";
+            this.DialogResult = DialogResult.OK;
+            this.Close();
         }
 
-        private void radioButton_StandardsampleCircle_Click(object sender, EventArgs e)
+        private void button_AddHole_Click(object sender, EventArgs e)
         {
-            label9.Visible = false;
-            tStandardsampleHeight.Visible = false;
-            label10.Text = "半径:";
+            dataGridView_Holes.Rows.Add("1", "圆形", -4250, -16000, 12000, 0);
         }
 
-        private void radioButton__StandardsampleSqare_Click(object sender, EventArgs e)
+        private void button_DelHole_Click(object sender, EventArgs e)
+        {
+            if(dataGridView_Holes.Rows.Count<1)
+            {
+                return;
+            }
+            int index = dataGridView_Holes.CurrentCell.RowIndex;
+            dataGridView_Holes.Rows.RemoveAt(index);
+        }
+
+        bool CheckParams()
         {
-            label9.Visible = true;
-            tStandardsampleHeight.Visible = true;
-            label10.Text = "高度:";
+            double dout;
+            if (!double.TryParse(tBoundaryX.Text,out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tBoundaryY.Text, out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tBoundaryWide.Text, out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tBoundaryHeight.Text, out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tStandardsampleX.Text, out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tStandardsampleY.Text, out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tStandardsampleWide.Text, out dout))
+            {
+                return false;
+            }
+            if (!double.TryParse(tStandardsampleHeight.Text, out dout))
+            {
+                return false;
+            }
+            for (int i=0;i<dataGridView_Holes.Rows.Count;i++)
+            {
+                for(int j=2;j<=5;j++)
+                {
+                    if (!double.TryParse(dataGridView_Holes.Rows[i].Cells[j].Value.ToString(), out dout))
+                    {
+                        return false;
+                    }
+                }
+            }
+            return true;
         }
     }
 }

+ 0 - 2
OTSIncAMeasureApp/7-OTSProgMgrInfo/Stage/DlgStageMgr.Designer.cs

@@ -70,7 +70,6 @@
             this.button_New.TabIndex = 8;
             this.button_New.Text = "新建";
             this.button_New.UseVisualStyleBackColor = true;
-            this.button_New.Visible = false;
             this.button_New.Click += new System.EventHandler(this.button_New_Click);
             // 
             // button_edit
@@ -82,7 +81,6 @@
             this.button_edit.TabIndex = 7;
             this.button_edit.Text = "编辑";
             this.button_edit.UseVisualStyleBackColor = true;
-            this.button_edit.Visible = false;
             this.button_edit.Click += new System.EventHandler(this.button_edit_Click);
             // 
             // m_ctrlBtnExport

+ 43 - 230
OTSIncAMeasureApp/7-OTSProgMgrInfo/Stage/DlgStageMgr.cs

@@ -22,8 +22,8 @@ namespace OTSModelSharp.Measure.GetStageInfo
 
         otsdataconst model = new otsdataconst();
         // stage file
-        CStageParam m_pStageFile;
-
+        public CStageParam m_pStageFile;
+        StageDisplayHelp stageDisplayHelp;
         // stage list value
         int m_nListBoxStageListIndex=0;
 
@@ -33,10 +33,7 @@ namespace OTSModelSharp.Measure.GetStageInfo
         // boundary
         CDomain m_poBourary;
 
-        const int RATIO_RECT_LEFT = 22;   //ratio rect left edge
-        const int PIC_EDGE = 12;		  //edge width
-        const int RATIO_RECT_HEIGHT = 30; //ratio rect height
-        const int RATIO_RECT_DOWN = 10;   //ratio rect down edge
+        
         const int LTGRAY_BRUSH = 1;
         const int BLACK_BRUSH = 4;
         const int WHITE_BRUSH = 0;
@@ -57,6 +54,7 @@ namespace OTSModelSharp.Measure.GetStageInfo
         {
             InitializeComponent();
             m_pStageFile = m_cstagefile;
+            stageDisplayHelp = new StageDisplayHelp();
         }
 
         private void DlgStageMgr_Load(object sender, EventArgs e)
@@ -380,28 +378,28 @@ namespace OTSModelSharp.Measure.GetStageInfo
                 double PixSize = 0;
                 if (nBounderyWidth > nBounderyHeight)
                 {
-                    PixSize = (long)((double)nBounderyWidth / (double)(nWidth - PIC_EDGE * 2));
+                    PixSize = (long)((double)nBounderyWidth / (double)(nWidth - StageDisplayHelp.PIC_EDGE * 2));
                 }
                 else
                 {
-                    PixSize = (long)((double)nBounderyHeight / (double)(nHeight - PIC_EDGE * 2));
+                    PixSize = (long)((double)nBounderyHeight / (double)(nHeight - StageDisplayHelp.PIC_EDGE * 2));
                 }
                 //draw boundery
                 Brush pLTGrayBrush = new SolidBrush(Color.FromArgb(255, 0, 0));
-                DrawStageBoundery(pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
+                stageDisplayHelp.DrawStageBoundery(pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
 
                 ////draw STD
                 //Brush pBlackBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
 
-                //DrawStageSTD(pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
+                //DrawStageSTD(m_pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
 
                 ////draw holes
                 //Brush pWriteBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
 
-                DrawStageHole(pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
+                stageDisplayHelp.DrawStageHole(pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
 
                 // draw ratio
-                DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
+                stageDisplayHelp.DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
 
                 pLTGrayBrush.Dispose();
                 //pBlackBrush.Dispose();
@@ -441,85 +439,6 @@ namespace OTSModelSharp.Measure.GetStageInfo
 
         //public void SetPackId(otsdataconst.OTS_SysType_ID a_nPackId) { m_nPackId = a_nPackId; }
 
-        // draw shape
-        public void DrawShape(Rectangle a_PixRect, Object a_pDC, otsdataconst.DOMAIN_SHAPE a_nShape, bool a_bIsRand) 
-        {
-            if (a_pDC == null)
-            {
-                return;
-            }
-            Graphics graphicsShape = (Graphics)a_pDC;
-            switch ((int)a_nShape)
-            {
-                case (int)otsdataconst.DOMAIN_SHAPE.ROUND:
-                    graphicsShape.DrawEllipse(new Pen(Color.Black),a_PixRect);
-                    break;
-                case (int)otsdataconst.DOMAIN_SHAPE.RECTANGLE:
-                    if (a_bIsRand)
-                    {
-                        //graphicsShape.DrawRectangle(new Pen(Color.Black), a_PixRect, new Point(ROUND_VALUE, ROUND_VALUE));
-                        graphicsShape.DrawRectangle(new Pen(Color.Black), a_PixRect);
-                    }
-                    else
-                    {
-                        graphicsShape.DrawEllipse(new Pen(Color.Black), a_PixRect);
-                    }
-                    break;
-            }
-        }
-
-        // get pixle rect
-        public bool GetPixRect(CDomain a_pDomain, int a_nWidth, int a_nHeight, double a_dPixSize,ref Rectangle PixRect) 
-        {
-            if (a_pDomain == null)
-            {
-                return false;
-            }
-
-            Rectangle DomainRect = a_pDomain.GetDomainRect();
-
-            int CenterX = a_nWidth / 2;     //pixle center
-            int CenterY = a_nHeight / 2;
-
-            Point DomainCenter = a_pDomain.GetDomainCenter();  // um center
-
-            Point PixCenter = new Point();
-            PixCenter.X = (int)((double)DomainCenter.X / a_dPixSize);
-            PixCenter.Y = (int)((double)DomainCenter.Y / a_dPixSize); // um to pixle
-
-            int PixRectCenterX = CenterX + PixCenter.X;
-            int PixRectCenterY = CenterY - PixCenter.Y;//OTS y dirction is different with pixle direction
-
-            int delteX = PixRectCenterX - PixCenter.X;
-            int delteY = PixRectCenterY - PixCenter.Y;
-
-            int Left = (int)(DomainRect.Left / a_dPixSize + delteX);
-            int Top = (int)(DomainRect.Top / a_dPixSize + delteY);
-            int Right = (int)(DomainRect.Right / a_dPixSize + delteX);
-            int Bottom = (int)(DomainRect.Bottom / a_dPixSize + delteY);
-
-            PixRect.Location = new Point(Left, Top);
-            PixRect.Size = new Size(Math.Abs(Right - Left), Math.Abs(Bottom - Top));
-            return true; 
-        }
-
-        // draw stage boundery
-        public void DrawStageBoundery(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) 
-        {
-            if (a_pStage == null)
-            {
-                return;
-            }
-
-            CDomain pBoundery = a_pStage.GetBoundary();
-            otsdataconst.DOMAIN_SHAPE nShape = (otsdataconst.DOMAIN_SHAPE)(-1);
-            nShape = pBoundery.GetShape();
-
-            Rectangle PixRect = new Rectangle();
-            GetPixRect(pBoundery, a_nWidth, a_nHeight, a_dPixSize,ref PixRect);
-            DrawShape(PixRect, pDC, nShape, true);
-        }
-
         public void DrawStageSTD(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) 
         {
             if (a_pStage == null)
@@ -532,142 +451,10 @@ namespace OTSModelSharp.Measure.GetStageInfo
             nShape = pSTD.GetShape();
 
             Rectangle PixRect = new Rectangle();
-            GetPixRect(pSTD, a_nWidth, a_nHeight, a_dPixSize,ref PixRect);
+            stageDisplayHelp.GetPixRect(pSTD, a_nWidth, a_nHeight, a_dPixSize,ref PixRect);
 
-            DrawShape(PixRect, pDC, nShape, false);
+            stageDisplayHelp.DrawShape(PixRect, pDC, nShape, false);
         }
-
-        // draw stage hole
-        public void DrawStageHole(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) 
-        {
-            if (a_pStage == null)
-            {
-                return;
-            }
-
-            if (a_pStage.GetHoleList().Count == 0)
-            {
-                return;
-            }
-
-            foreach (var pHole in a_pStage.GetHoleList())
-            {
-                otsdataconst.DOMAIN_SHAPE nShape = (otsdataconst.DOMAIN_SHAPE)(-1);
-                nShape = pHole.GetShape();
-
-                Rectangle PixRect = new Rectangle();
-                GetPixRect(pHole, a_nWidth, a_nHeight, a_dPixSize,ref PixRect);
-
-                DrawShape(PixRect, pDC, nShape, false);
-
-                int nHeight = PixRect.Height * 2 / 3;
-
-                //设置文字对齐方式
-                StringFormat sf = new StringFormat();
-                sf.Alignment = StringAlignment.Center;
-                sf.LineAlignment = StringAlignment.Center;
-                //文字颜色
-                string ColorStr = "#90ee90";
-                Color myColor = ColorTranslator.FromHtml(ColorStr);
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                SolidBrush solidBrush = new SolidBrush(Color.FromArgb(50, Color.Black));
-                //字体大小 根据样品孔Rectangle大小
-                float fontSize = PixRect.Width / 4;
-                Font font = new Font("宋体", fontSize, FontStyle.Regular);
-                if (fontSize == 0)
-                {
-                    font = new Font("宋体", fontSize, FontStyle.Regular);
-                }
-                //绘制文字阴影
-                Rectangle rectFont = PixRect;
-                rectFont.X += 2;
-                rectFont.Y += 2;
-                ((Graphics)pDC).DrawString(pHole.GetName(), font, solidBrush, rectFont, sf);
-                ((Graphics)pDC).DrawString(pHole.GetName(), font, sampleBrush, PixRect, sf);
-            }
-        }
-
-        // draw ratio
-        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, Object pDC, IntPtr pWnd, Rectangle rc) 
-        {
-            if (pDC == null)
-            {
-                return;
-            }
-
-            if (pWnd == null)
-            {
-                return;
-            }
-
-
-            int nRatio = a_nBounderyWidth * (a_nWidth / 2 - RATIO_RECT_LEFT - 10) / (a_nWidth - PIC_EDGE * 2) / 1000; //显示在标尺上的mm数
-            string sRatio;
-
-            Point oRatioStart = new Point();
-            oRatioStart.X = RATIO_RECT_LEFT;
-            oRatioStart.Y = a_nHeight - RATIO_RECT_HEIGHT - RATIO_RECT_DOWN;
-
-            Point oRatioEnd = new Point();
-            oRatioEnd.X = a_nWidth / 2;
-            oRatioEnd.Y = a_nHeight - RATIO_RECT_DOWN;
-
-            //标尺
-
-            //Pen pen = new Pen(Color.Black, 10f);
-            //((Graphics)pDC).DrawLine(pen,new Point(oRatioStart.X + 5, oRatioStart.Y + 5),new Point(oRatioStart.X + 5, oRatioEnd.Y - 15));
-            //((Graphics)pDC).DrawLine(pen, new Point(oRatioStart.X + 5, oRatioStart.Y + 10),new Point(oRatioEnd.X - 5, oRatioStart.Y + 10));
-            //((Graphics)pDC).DrawLine(pen, new Point(oRatioEnd.X - 5, oRatioStart.Y + 5),new Point(oRatioEnd.X - 5, oRatioEnd.Y - 15));
-
-
-            //pDC->MoveTo(CPoint(oRatioStart.x + 5, oRatioStart.y + 5));
-            //pDC->LineTo(CPoint(oRatioStart.x + 5, oRatioEnd.y - 15));
-            //pDC->MoveTo(CPoint(oRatioStart.x + 5, oRatioStart.y + 10));
-            //pDC->LineTo(CPoint(oRatioEnd.x - 5, oRatioStart.y + 10));
-            //pDC->MoveTo(CPoint(oRatioEnd.x - 5, oRatioStart.y + 5));
-            //pDC->LineTo(CPoint(oRatioEnd.x - 5, oRatioEnd.y - 15));
-
-            //CFont font;
-            //VERIFY(font.CreateFont(
-            //    12,                        // nHeight
-            //    0,                         // nWidth
-            //    0,                         // nEscapement
-            //    0,                         // nOrientation
-            //    FW_THIN,                 // nWeight
-            //    FALSE,                     // bItalic
-            //    FALSE,                     // bUnderline
-            //    0,                         // cStrikeOut
-            //    ANSI_CHARSET,              // nCharSet
-            //    OUT_DEFAULT_PRECIS,        // nOutPrecision
-            //    CLIP_DEFAULT_PRECIS,       // nClipPrecision
-            //    DEFAULT_QUALITY,           // nQuality
-            //    DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
-            //    _T("Arial")));                 // lpszFacename
-
-
-            //CFont* def_font = pDC->SelectObject(&font);
-            //pDC->TextOut(oRatioStart.x + 70, oRatioStart.y + 15, sRatio);
-            //pDC->SelectObject(def_font);
-
-            //// Done with the font.  Delete the font object.
-            //font.DeleteObject();
-
-            //CRect oRect(oRatioStart, oRatioEnd);
-
-            //HDC hDC;
-            //hDC = ::GetDC(pWnd->m_hWnd);
-            //HDC hBitmapDC = CreateCompatibleDC(hDC);
-            //HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rc.Width(), rc.Height());
-            //SelectObject(hBitmapDC, hBitmap);
-
-            //BLENDFUNCTION bf;
-            //bf.BlendOp = AC_SRC_OVER;
-            //bf.BlendFlags = 0;
-            //bf.AlphaFormat = 0;
-            //bf.SourceConstantAlpha = 10;
-            //AlphaBlend(hDC, oRect.left, oRect.top, oRect.Width(), oRect.Height(), hBitmapDC, 0, 0, oRect.Width(), oRect.Height(), bf);
-        }
-
         //public Brush GetStockObject(int i) {
 
         //      BrushConverter brushConverter = new BrushConverter(Color.Brown);
@@ -705,16 +492,16 @@ namespace OTSModelSharp.Measure.GetStageInfo
             }
 
 
-            int nRatio = a_nBounderyWidth * (a_nWidth / 2 - RATIO_RECT_LEFT - 10) / (a_nWidth - PIC_EDGE * 2) / 1000; //显示在标尺上的mm数        
+            int nRatio = a_nBounderyWidth * (a_nWidth / 2 - StageDisplayHelp.RATIO_RECT_LEFT - 10) / (a_nWidth - StageDisplayHelp.PIC_EDGE * 2) / 1000; //显示在标尺上的mm数        
             String.Format("%dcm", nRatio);
 
             System.Drawing.Point oRatioStart = new System.Drawing.Point();
-            oRatioStart.X = RATIO_RECT_LEFT;
-            oRatioStart.Y = a_nHeight - RATIO_RECT_HEIGHT - RATIO_RECT_DOWN;
+            oRatioStart.X = StageDisplayHelp.RATIO_RECT_LEFT;
+            oRatioStart.Y = a_nHeight - StageDisplayHelp.RATIO_RECT_HEIGHT - StageDisplayHelp.RATIO_RECT_DOWN;
 
             System.Drawing.Point oRatioEnd = new System.Drawing.Point();
             oRatioEnd.X = a_nWidth / 2;
-            oRatioEnd.Y = a_nHeight - RATIO_RECT_DOWN;
+            oRatioEnd.Y = a_nHeight - StageDisplayHelp.RATIO_RECT_DOWN;
 
             Control control = new Control();
             //标尺
@@ -737,13 +524,39 @@ namespace OTSModelSharp.Measure.GetStageInfo
 
         private void button_edit_Click(object sender, EventArgs e)
         {
+            DlgStageEdit dlgStageEdit = new DlgStageEdit(m_pStageFile.GetStagesList()[m_ctrlListBoxStageList.SelectedIndex]);
 
+            if (dlgStageEdit.ShowDialog() == DialogResult.OK)
+            {
+                List<CStage> cli = m_pStageFile.GetStagesList();
+                cli[m_ctrlListBoxStageList.SelectedIndex]=dlgStageEdit.m_pStage;
+                //m_pStageFile.SetStagesList(cli, true);
+                m_pStageFile.SetModify(true);
+                SetStageListControlData();
+            }
+            else
+            {
+
+            }
         }
 
         private void button_New_Click(object sender, EventArgs e)
         {
             DlgStageEdit dlgStageEdit = new DlgStageEdit();
-            dlgStageEdit.ShowDialog();
+
+            if (dlgStageEdit.ShowDialog() == DialogResult.OK)
+            {
+                List<CStage> cli = m_pStageFile.GetStagesList();
+                cli.Add(dlgStageEdit.m_pStage);
+                //m_pStageFile.SetStagesList(cli, true);
+                m_pStageFile.SetModify(true);
+                SetStageListControlData();
+            }
+            else
+            {
+
+            }
+
         }
 
         //public CStageParam ShowStageMgrDialog(otsdataconst.OTS_SysType_ID a_nPackId, CStageParam a_pStageFile)

+ 1 - 0
OTSIncAMeasureApp/OTSIncAMeasureApp.csproj

@@ -268,6 +268,7 @@
     <Compile Include="7-OTSProgMgrInfo\Stage\DlgStageRename.Designer.cs">
       <DependentUpon>DlgStageRename.cs</DependentUpon>
     </Compile>
+    <Compile Include="7-OTSProgMgrInfo\Stage\StageDisplayHelp.cs" />
     <Compile Include="ResourceManage\ResourceData.cs" />
     <Compile Include="ResourceManage\ResourceID.cs" />
     <Compile Include="ServiceCenter\CClassifyEngine.cs" />