Przeglądaj źródła

add DlgStageMgr.cs which is a form

CXS 5 lat temu
rodzic
commit
91712b26a5

+ 146 - 0
OTS/OTSModelSharp/Measure/GetStageInfo/DlgStageMgr.Designer.cs

@@ -0,0 +1,146 @@
+namespace OTSModelSharp.Measure.GetStageInfo
+{
+    partial class DlgStageMgr
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.IDC_BTN_RENAME = new System.Windows.Forms.Button();
+            this.IDC_BTN_DEL = new System.Windows.Forms.Button();
+            this.IDC_BTN_APLY = new System.Windows.Forms.Button();
+            this.IDD_STAGE_MGR = new System.Windows.Forms.PictureBox();
+            this.IDC_LIST_STAGE = new System.Windows.Forms.ListBox();
+            this.IDC_BTN_IMPORT = new System.Windows.Forms.Button();
+            this.IDC_BTN_EXPORT = new System.Windows.Forms.Button();
+            this.groupBox1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.IDD_STAGE_MGR)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // groupBox1
+            // 
+            this.groupBox1.Controls.Add(this.IDC_BTN_EXPORT);
+            this.groupBox1.Controls.Add(this.IDC_BTN_IMPORT);
+            this.groupBox1.Controls.Add(this.IDC_BTN_RENAME);
+            this.groupBox1.Controls.Add(this.IDC_BTN_DEL);
+            this.groupBox1.Controls.Add(this.IDC_BTN_APLY);
+            this.groupBox1.Controls.Add(this.IDD_STAGE_MGR);
+            this.groupBox1.Controls.Add(this.IDC_LIST_STAGE);
+            this.groupBox1.Location = new System.Drawing.Point(2, 1);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(697, 317);
+            this.groupBox1.TabIndex = 0;
+            this.groupBox1.TabStop = false;
+            // 
+            // IDC_BTN_RENAME
+            // 
+            this.IDC_BTN_RENAME.Location = new System.Drawing.Point(169, 291);
+            this.IDC_BTN_RENAME.Name = "IDC_BTN_RENAME";
+            this.IDC_BTN_RENAME.Size = new System.Drawing.Size(75, 23);
+            this.IDC_BTN_RENAME.TabIndex = 4;
+            this.IDC_BTN_RENAME.Text = "重命名";
+            this.IDC_BTN_RENAME.UseVisualStyleBackColor = true;
+            // 
+            // IDC_BTN_DEL
+            // 
+            this.IDC_BTN_DEL.Location = new System.Drawing.Point(87, 291);
+            this.IDC_BTN_DEL.Name = "IDC_BTN_DEL";
+            this.IDC_BTN_DEL.Size = new System.Drawing.Size(75, 23);
+            this.IDC_BTN_DEL.TabIndex = 3;
+            this.IDC_BTN_DEL.Text = "删除";
+            this.IDC_BTN_DEL.UseVisualStyleBackColor = true;
+            // 
+            // IDC_BTN_APLY
+            // 
+            this.IDC_BTN_APLY.Location = new System.Drawing.Point(6, 291);
+            this.IDC_BTN_APLY.Name = "IDC_BTN_APLY";
+            this.IDC_BTN_APLY.Size = new System.Drawing.Size(75, 23);
+            this.IDC_BTN_APLY.TabIndex = 2;
+            this.IDC_BTN_APLY.Text = "应用";
+            this.IDC_BTN_APLY.UseVisualStyleBackColor = true;
+            // 
+            // IDD_STAGE_MGR
+            // 
+            this.IDD_STAGE_MGR.Location = new System.Drawing.Point(316, 17);
+            this.IDD_STAGE_MGR.Name = "IDD_STAGE_MGR";
+            this.IDD_STAGE_MGR.Size = new System.Drawing.Size(378, 267);
+            this.IDD_STAGE_MGR.TabIndex = 1;
+            this.IDD_STAGE_MGR.TabStop = false;
+            // 
+            // IDC_LIST_STAGE
+            // 
+            this.IDC_LIST_STAGE.FormattingEnabled = true;
+            this.IDC_LIST_STAGE.ItemHeight = 12;
+            this.IDC_LIST_STAGE.Location = new System.Drawing.Point(6, 17);
+            this.IDC_LIST_STAGE.Name = "IDC_LIST_STAGE";
+            this.IDC_LIST_STAGE.Size = new System.Drawing.Size(294, 268);
+            this.IDC_LIST_STAGE.TabIndex = 0;
+            // 
+            // IDC_BTN_IMPORT
+            // 
+            this.IDC_BTN_IMPORT.Location = new System.Drawing.Point(525, 291);
+            this.IDC_BTN_IMPORT.Name = "IDC_BTN_IMPORT";
+            this.IDC_BTN_IMPORT.Size = new System.Drawing.Size(75, 23);
+            this.IDC_BTN_IMPORT.TabIndex = 5;
+            this.IDC_BTN_IMPORT.Text = "导入";
+            this.IDC_BTN_IMPORT.UseVisualStyleBackColor = true;
+            // 
+            // IDC_BTN_EXPORT
+            // 
+            this.IDC_BTN_EXPORT.Location = new System.Drawing.Point(619, 291);
+            this.IDC_BTN_EXPORT.Name = "IDC_BTN_EXPORT";
+            this.IDC_BTN_EXPORT.Size = new System.Drawing.Size(75, 23);
+            this.IDC_BTN_EXPORT.TabIndex = 6;
+            this.IDC_BTN_EXPORT.Text = "导出";
+            this.IDC_BTN_EXPORT.UseVisualStyleBackColor = true;
+            // 
+            // DlgStageMgr
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(699, 320);
+            this.Controls.Add(this.groupBox1);
+            this.Name = "DlgStageMgr";
+            this.Text = "DlgStageMgr";
+            this.Load += new System.EventHandler(this.DlgStageMgr_Load);
+            this.groupBox1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.IDD_STAGE_MGR)).EndInit();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.Button IDC_BTN_RENAME;
+        private System.Windows.Forms.Button IDC_BTN_DEL;
+        private System.Windows.Forms.Button IDC_BTN_APLY;
+        private System.Windows.Forms.PictureBox IDD_STAGE_MGR;
+        private System.Windows.Forms.ListBox IDC_LIST_STAGE;
+        private System.Windows.Forms.Button IDC_BTN_EXPORT;
+        private System.Windows.Forms.Button IDC_BTN_IMPORT;
+    }
+}

+ 76 - 66
OTS/OTSModelSharp/Measure/GetStageInfo/DlgStageMgr.cs

@@ -1,23 +1,27 @@
-
-using OTSDataType;
-using System;
+using System;
 using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
 using System.Drawing;
-using System.Drawing.Drawing2D;
 using System.Linq;
-using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
-using System.Windows;
 using System.Windows.Forms;
-using System.Media;
-
-
+using OTSDataType;
 
-namespace OTSModelSharp
+namespace OTSModelSharp.Measure.GetStageInfo
 {
-    public class DlgStageMgr
+    public partial class DlgStageMgr : Form
     {
+        public DlgStageMgr()
+        {
+            InitializeComponent();
+        }
+
+        private void DlgStageMgr_Load(object sender, EventArgs e)
+        {
+
+        }
         public static NLog.Logger loger = NLog.LogManager.GetCurrentClassLogger();
 
         otsdataconst model = new otsdataconst();
@@ -64,12 +68,12 @@ namespace OTSModelSharp
 
         public struct BLENDFUNCTION
         {
-          public  Byte BlendOp;
-          public  Byte BlendFlags;
-          public  Byte SourceConstantAlpha;
-          public  Byte AlphaFormat;
+            public Byte BlendOp;
+            public Byte BlendFlags;
+            public Byte SourceConstantAlpha;
+            public Byte AlphaFormat;
         }
-        
+
 
         public enum OTS_SOFT_PACKAGE_ID
         {
@@ -81,7 +85,7 @@ namespace OTSModelSharp
         }
 
         // soft pack id
-       public OTS_SOFT_PACKAGE_ID m_nPackId;
+        public OTS_SOFT_PACKAGE_ID m_nPackId;
 
         // CDlgStageMgr message map
         public void OnClickedBtnImport()
@@ -205,7 +209,8 @@ namespace OTSModelSharp
 
         }
 
-        public bool UpdateData(bool bSaveAndValidate) {
+        public bool UpdateData(bool bSaveAndValidate)
+        {
 
             return true;
 
@@ -219,7 +224,7 @@ namespace OTSModelSharp
                 return;
             }
 
-            Rect rc = new Rect();
+            Rectangle rc = new Rectangle();
             System.Drawing.Rectangle re = new System.Drawing.Rectangle();
             int pWnd = GetDlgItem(otsdataconst.IDC_PIC_STAGE);
 
@@ -259,17 +264,17 @@ namespace OTSModelSharp
                 }
                 //draw boundery
                 Brush pLTGrayBrush = GetStockObject(LTGRAY_BRUSH);
-              
+
                 DrawStageBoundery(pStage[LTGRAY_BRUSH], nWidth, nHeight, pDC, PixSize);
 
                 //draw STD
                 Brush pBlackBrush = GetStockObject(BLACK_BRUSH);
-               
+
                 DrawStageSTD(pStage[BLACK_BRUSH], nWidth, nHeight, pDC, PixSize);
 
                 //draw holes
                 Brush pWriteBrush = GetStockObject(WHITE_BRUSH);
-                
+
                 DrawStageHole(pStage[WHITE_BRUSH], nWidth, nHeight, pDC, PixSize);
 
                 // draw ratio
@@ -285,17 +290,19 @@ namespace OTSModelSharp
 
             }
 
-           
+
             pOldBrush.Dispose();
 
         }
 
-        public int GetDlgItem(int nID) {
+        public int GetDlgItem(int nID)
+        {
             return nID;
         }
 
         // stage file get and set
-        public CStageFile GetStageFile() {
+        public CStageFile GetStageFile()
+        {
             return m_pStageFile;
         }
 
@@ -311,10 +318,10 @@ namespace OTSModelSharp
         public void SetPackId(OTS_SOFT_PACKAGE_ID a_nPackId) { m_nPackId = a_nPackId; }
 
         // draw shape
-        public void DrawShape(Rect a_PixRect, Object a_pDC, DOMAIN_SHAPE a_nShape, bool a_bIsRand) { }
+        public void DrawShape(Rectangle a_PixRect, Object a_pDC, DOMAIN_SHAPE a_nShape, bool a_bIsRand) { }
 
         // get pixle rect
-        public bool GetPixRect(CDomain a_pDomain, int a_nWidth, int a_nHeight, double a_dPixSize, Rect PixRect) { return true; }
+        public bool GetPixRect(CDomain a_pDomain, int a_nWidth, int a_nHeight, double a_dPixSize, Rectangle PixRect) { return true; }
 
         // draw stage boundery
         public void DrawStageBoundery(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) { }
@@ -325,7 +332,7 @@ namespace OTSModelSharp
         public void DrawStageHole(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) { }
 
         // draw ratio
-        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, Object pDC, IntPtr pWnd, Rect rc) { }
+        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, Object pDC, IntPtr pWnd, Rectangle rc) { }
 
         //public Brush GetStockObject(int i) {
 
@@ -333,67 +340,70 @@ namespace OTSModelSharp
         //      return (Brush)brushConverter.ConvertFromString(LTGRAY_BRUSH.ToString());
 
         //}
-        public Brush GetStockObject(int i) {
+        public Brush GetStockObject(int i)
+        {
 
             return null;
         }
 
         // boundary
-        public CDomain GetBoundary() {
+        public CDomain GetBoundary()
+        {
             return m_poBourary;
         }
 
-        public Brush SelectObject(Brush pBrush) {
+        public Brush SelectObject(Brush pBrush)
+        {
 
             return pBrush;
         }
 
-        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, int pDC, int pWnd,  Rect rc)
-	    {
-		if (pDC ==0)
-		{			
-			return;
-		}
-		
-		if (pWnd == 0)
-		{			
-			return;
-		}
+        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, int pDC, int pWnd, Rectangle rc)
+        {
+            if (pDC == 0)
+            {
+                return;
+            }
 
+            if (pWnd == 0)
+            {
+                return;
+            }
 
-        int nRatio = a_nBounderyWidth * (a_nWidth / 2 - RATIO_RECT_LEFT - 10) / (a_nWidth - 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;
+            int nRatio = a_nBounderyWidth * (a_nWidth / 2 - RATIO_RECT_LEFT - 10) / (a_nWidth - PIC_EDGE * 2) / 1000; //显示在标尺上的mm数        
+            String.Format("%dcm", nRatio);
 
-        System.Drawing.Point oRatioEnd = new System.Drawing.Point();
-        oRatioEnd.X = a_nWidth / 2;
-	    oRatioEnd.Y = a_nHeight - RATIO_RECT_DOWN;
+            System.Drawing.Point oRatioStart = new System.Drawing.Point();
+            oRatioStart.X = RATIO_RECT_LEFT;
+            oRatioStart.Y = a_nHeight - RATIO_RECT_HEIGHT - RATIO_RECT_DOWN;
 
-        Control control = new Control();
+            System.Drawing.Point oRatioEnd = new System.Drawing.Point();
+            oRatioEnd.X = a_nWidth / 2;
+            oRatioEnd.Y = a_nHeight - RATIO_RECT_DOWN;
+
+            Control control = new Control();
             //标尺
-      
-        FontDialog fontdialog = new FontDialog();
-        fontdialog.ShowDialog();
-        control.Font = fontdialog.Font;
-        control.Font = new System.Drawing.Font("华文新魏", 22.2f, FontStyle.Bold );
 
-        System.Drawing.Font def_font = new System.Drawing.Font(control.Font, FontStyle.Regular);
+            FontDialog fontdialog = new FontDialog();
+            fontdialog.ShowDialog();
+            control.Font = fontdialog.Font;
+            control.Font = new System.Drawing.Font("华文新魏", 22.2f, FontStyle.Bold);
+
+            System.Drawing.Font def_font = new System.Drawing.Font(control.Font, FontStyle.Regular);
+
 
-           
             BLENDFUNCTION bf = new BLENDFUNCTION();
             bf.BlendOp = 1;
-		    bf.BlendFlags = 0;
-		    bf.AlphaFormat = 0;
-	     	bf.SourceConstantAlpha = 10;
-		    
-    }
+            bf.BlendFlags = 0;
+            bf.AlphaFormat = 0;
+            bf.SourceConstantAlpha = 10;
+
+        }
 
         public CStageFile ShowStageMgrDialog(OTS_SOFT_PACKAGE_ID a_nPackId, CStageFile a_pStageFile)
         {
-            if (a_pStageFile==null)
+            if (a_pStageFile == null)
             {
                 //LogErrorTrace(__FILE__, __LINE__, _T("ShowStageMgrDialog:invalid stage file."));
                 loger.Error("ShowStageMgrDialog:invalid stage file.");
@@ -401,7 +411,7 @@ namespace OTSModelSharp
             }
 
             //show the dialog
-            DlgStageMgr dlg=new DlgStageMgr();
+            DlgStageMgr dlg = new DlgStageMgr();
             dlg.SetStageFile(a_pStageFile);
             dlg.SetPackId(a_nPackId);
 
@@ -409,7 +419,7 @@ namespace OTSModelSharp
 
             CStageFile pStageFile = dlg.GetStageFile();
             //ASSERT(pStageFile);
-            if (pStageFile==null)
+            if (pStageFile == null)
             {
                 //LogErrorTrace(__FILE__, __LINE__, _T("ShowStageMgrDialog: Load stage from stage manager dlg failed."));
                 loger.Error("ShowStageMgrDialog: Load stage from stage manager dlg failed.");

+ 120 - 0
OTS/OTSModelSharp/Measure/GetStageInfo/DlgStageMgr.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 422 - 0
OTS/OTSModelSharp/Measure/GetStageInfo/DlgStageMgr2.cs

@@ -0,0 +1,422 @@
+
+using OTSDataType;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+using System.Media;
+
+
+
+namespace OTSModelSharp
+{
+    public class DlgStageMgr
+    {
+        public static NLog.Logger loger = NLog.LogManager.GetCurrentClassLogger();
+
+        otsdataconst model = new otsdataconst();
+
+        // stage file
+        CStageFile m_pStageFile;
+
+        System.Windows.Forms.Button m_ctrlBtnApply;
+
+        // stage list control
+        System.Windows.Forms.ListBox m_ctrlListBoxStageList;
+
+        // stage list value
+        int m_nListBoxStageList;
+
+        System.Windows.Forms.Button m_ctrlBtnDelete;
+
+        System.Windows.Forms.Button m_ctrlBtnRename;
+
+        System.Windows.Forms.Button m_ctrlBtnExport;
+
+        // flag if the stage should be re-paint
+        bool m_bShowFlag;
+
+        // 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;
+
+
+
+
+        public struct BLENDFUNCTION
+        {
+          public  Byte BlendOp;
+          public  Byte BlendFlags;
+          public  Byte SourceConstantAlpha;
+          public  Byte AlphaFormat;
+        }
+        
+
+        public enum OTS_SOFT_PACKAGE_ID
+        {
+            INVALID = -1,
+            MIN = 0,
+            OTSIncA = 0,
+            OTSPartA = 1,
+            MAX = 1
+        }
+
+        // soft pack id
+       public OTS_SOFT_PACKAGE_ID m_nPackId;
+
+        // CDlgStageMgr message map
+        public void OnClickedBtnImport()
+        {
+            String strDlgTitle = "";
+            if (strDlgTitle == "")
+            {
+                // file open dialog
+                OpenFileDialog openFileDialog = new OpenFileDialog();
+                // get file pathname
+                openFileDialog.Filter = otsdataconst.IDS_OPEN_STAGE_FILE.ToString();
+
+                strDlgTitle = openFileDialog.FileName;
+
+                if (openFileDialog.ShowDialog() != DialogResult.OK)
+                {
+                    String strPathName = openFileDialog.FileName;
+                    if (strPathName == "")
+                    {
+
+                        return;
+                    }
+
+                    // load a stage from txt file
+                    if (!m_pStageFile.LoadStageFromTextFile(strPathName))
+                    {
+
+                        return;
+                    }
+
+                    // set modify flag
+                    m_pStageFile.SetModify(true);
+                    // the new stage insert to stage list
+                    SetStageListControlData();
+                }
+
+
+            }
+            else
+            {
+
+                return;
+            }
+
+            // show the stage
+            m_bShowFlag = false;
+
+        }
+
+        public void SetStageListControlData()
+        {
+            m_ctrlListBoxStageList.Dispose();
+
+            // there is stage in the stage file?
+            if (m_pStageFile.GetStagesList().Count > 0)
+            {
+                // there is sample on the work stage
+                if (m_pStageFile.GetInUse() == true)
+                {
+                    // can't change working stage
+                    m_ctrlBtnApply.Enabled = false;
+
+
+                    // if working stage id == selected id
+                    if (m_nListBoxStageList == m_pStageFile.GetWorkingStageId())
+                    {
+                        // can't delete and rename the woking stage
+                        m_ctrlBtnDelete.Enabled = false;
+                        m_ctrlBtnRename.Enabled = false;
+                    }
+                    else
+                    {
+                        m_ctrlBtnDelete.Enabled = true;
+                        m_ctrlBtnRename.Enabled = true;
+                    }
+                }
+                else
+                {
+                    m_ctrlBtnApply.Enabled = true;
+                    m_ctrlBtnDelete.Enabled = true;
+                    m_ctrlBtnRename.Enabled = true;
+                }
+
+                foreach (var pStage in m_pStageFile.GetStagesList())
+                {
+                    String sCurrentName = pStage.GetName();
+                    m_ctrlListBoxStageList.FindString(sCurrentName);
+
+
+                }
+
+                //default is the first item			               
+                m_ctrlListBoxStageList.SelectedIndex = m_nListBoxStageList;
+                m_ctrlBtnExport.Enabled = true;
+            }
+            else
+            {
+                // the control can't be used because there is no stage in the file
+                m_ctrlBtnApply.Enabled = false;
+                m_ctrlBtnApply.Enabled = false;
+                m_ctrlBtnDelete.Enabled = false;
+                m_ctrlBtnExport.Enabled = false;
+                m_ctrlBtnRename.Enabled = false;
+            }
+
+        }
+
+        public void UpdateStageFileData(bool a_bUpdateData/* = TRUE*/)
+        {
+            if (a_bUpdateData)
+            {
+                UpdateData(true);
+            }
+
+            if (!m_pStageFile.GetInUse())
+            {
+                // if there is sample on the stage, the working stage can't be changed.
+                m_pStageFile.SetWorkingStageId(m_nListBoxStageList);
+            }
+
+
+        }
+
+        public bool UpdateData(bool bSaveAndValidate) {
+
+            return true;
+
+        }
+
+        public void DrawStage()
+        {
+
+            if (m_nListBoxStageList < 0 || m_nListBoxStageList > (int)(m_pStageFile.GetStagesList().Count))
+            {
+                return;
+            }
+
+            Rect rc = new Rect();
+            System.Drawing.Rectangle re = new System.Drawing.Rectangle();
+            int pWnd = GetDlgItem(otsdataconst.IDC_PIC_STAGE);
+
+            int nWidth = (int)rc.X;
+            int nHeight = (int)rc.Y;
+            Object pDC = new Object();
+
+            bool DeleteObject = false;
+
+
+            //paint the DC with white
+
+            Brush pOldBrush = new SolidBrush(Color.FromArgb(50, Color.White));
+
+
+            //Draw stage
+            if (m_pStageFile.GetStagesList().Count > 0)
+            {
+                Image img = Image.FromFile("");
+                Graphics graphics = Graphics.FromImage(img);
+                graphics.FillRectangle(new SolidBrush(Color.White), re);
+
+                //get stage information              
+                List<CStage> pStage = m_pStageFile.GetStagesList();//get curretn working stage
+                CDomain pBoundery = 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 - PIC_EDGE * 2));
+                }
+                else
+                {
+                    PixSize = (long)((double)nBounderyHeight / (double)(nHeight - PIC_EDGE * 2));
+                }
+                //draw boundery
+                Brush pLTGrayBrush = GetStockObject(LTGRAY_BRUSH);
+              
+                DrawStageBoundery(pStage[LTGRAY_BRUSH], nWidth, nHeight, pDC, PixSize);
+
+                //draw STD
+                Brush pBlackBrush = GetStockObject(BLACK_BRUSH);
+               
+                DrawStageSTD(pStage[BLACK_BRUSH], nWidth, nHeight, pDC, PixSize);
+
+                //draw holes
+                Brush pWriteBrush = GetStockObject(WHITE_BRUSH);
+                
+                DrawStageHole(pStage[WHITE_BRUSH], nWidth, nHeight, pDC, PixSize);
+
+                // draw ratio
+                DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
+
+                pLTGrayBrush.Dispose();
+                pBlackBrush.Dispose();
+            }
+            else
+            {
+                // paint the stage
+                m_bShowFlag = true;
+
+            }
+
+           
+            pOldBrush.Dispose();
+
+        }
+
+        public int GetDlgItem(int nID) {
+            return nID;
+        }
+
+        // stage file get and set
+        public CStageFile GetStageFile() {
+            return m_pStageFile;
+        }
+
+        public void SetStageFile(CStageFile a_pStageFile)
+        {
+            m_pStageFile = a_pStageFile;
+
+        }
+
+        // soft pack id get and set
+        public OTS_SOFT_PACKAGE_ID GetPackId() { return m_nPackId; }
+
+        public void SetPackId(OTS_SOFT_PACKAGE_ID a_nPackId) { m_nPackId = a_nPackId; }
+
+        // draw shape
+        public void DrawShape(Rect a_PixRect, Object a_pDC, DOMAIN_SHAPE a_nShape, bool a_bIsRand) { }
+
+        // get pixle rect
+        public bool GetPixRect(CDomain a_pDomain, int a_nWidth, int a_nHeight, double a_dPixSize, Rect PixRect) { return true; }
+
+        // draw stage boundery
+        public void DrawStageBoundery(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) { }
+
+        public void DrawStageSTD(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) { }
+
+        // draw stage hole
+        public void DrawStageHole(CStage a_pStage, int a_nWidth, int a_nHeight, Object pDC, double a_dPixSize) { }
+
+        // draw ratio
+        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, Object pDC, IntPtr pWnd, Rect rc) { }
+
+        //public Brush GetStockObject(int i) {
+
+        //      BrushConverter brushConverter = new BrushConverter(Color.Brown);
+        //      return (Brush)brushConverter.ConvertFromString(LTGRAY_BRUSH.ToString());
+
+        //}
+        public Brush GetStockObject(int i) {
+
+            return null;
+        }
+
+        // boundary
+        public CDomain GetBoundary() {
+            return m_poBourary;
+        }
+
+        public Brush SelectObject(Brush pBrush) {
+
+            return pBrush;
+        }
+
+        public void DrawRatio(int a_nBounderyWidth, int a_nWidth, int a_nHeight, int pDC, int pWnd,  Rect rc)
+	    {
+		if (pDC ==0)
+		{			
+			return;
+		}
+		
+		if (pWnd == 0)
+		{			
+			return;
+		}
+
+
+        int nRatio = a_nBounderyWidth * (a_nWidth / 2 - RATIO_RECT_LEFT - 10) / (a_nWidth - 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;
+
+        System.Drawing.Point oRatioEnd = new System.Drawing.Point();
+        oRatioEnd.X = a_nWidth / 2;
+	    oRatioEnd.Y = a_nHeight - RATIO_RECT_DOWN;
+
+        Control control = new Control();
+            //标尺
+      
+        FontDialog fontdialog = new FontDialog();
+        fontdialog.ShowDialog();
+        control.Font = fontdialog.Font;
+        control.Font = new System.Drawing.Font("华文新魏", 22.2f, FontStyle.Bold );
+
+        System.Drawing.Font def_font = new System.Drawing.Font(control.Font, FontStyle.Regular);
+
+           
+            BLENDFUNCTION bf = new BLENDFUNCTION();
+            bf.BlendOp = 1;
+		    bf.BlendFlags = 0;
+		    bf.AlphaFormat = 0;
+	     	bf.SourceConstantAlpha = 10;
+		    
+    }
+
+        public CStageFile ShowStageMgrDialog(OTS_SOFT_PACKAGE_ID a_nPackId, CStageFile a_pStageFile)
+        {
+            if (a_pStageFile==null)
+            {
+                //LogErrorTrace(__FILE__, __LINE__, _T("ShowStageMgrDialog:invalid stage file."));
+                loger.Error("ShowStageMgrDialog:invalid stage file.");
+                return null;
+            }
+
+            //show the dialog
+            DlgStageMgr dlg=new DlgStageMgr();
+            dlg.SetStageFile(a_pStageFile);
+            dlg.SetPackId(a_nPackId);
+
+            dlg.ShowDialog();
+
+            CStageFile pStageFile = dlg.GetStageFile();
+            //ASSERT(pStageFile);
+            if (pStageFile==null)
+            {
+                //LogErrorTrace(__FILE__, __LINE__, _T("ShowStageMgrDialog: Load stage from stage manager dlg failed."));
+                loger.Error("ShowStageMgrDialog: Load stage from stage manager dlg failed.");
+                return null;
+            }
+
+            return pStageFile;
+        }
+    }
+}

+ 10 - 1
OTS/OTSModelSharp/OTSModelSharp.csproj

@@ -136,7 +136,13 @@
     <Compile Include="Measure\GetParticle\SmallParticles\SmallParticleInfoTable.cs" />
     <Compile Include="Measure\GetParticle\XRayDataDB.cs" />
     <Compile Include="Measure\GetParticle\XRayDataTable.cs" />
-    <Compile Include="Measure\GetStageInfo\DlgStageMgr.cs" />
+    <Compile Include="Measure\GetStageInfo\DlgStageMgr.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Measure\GetStageInfo\DlgStageMgr.Designer.cs">
+      <DependentUpon>DlgStageMgr.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Measure\GetStageInfo\DlgStageMgr2.cs" />
     <Compile Include="Measure\GetStageInfo\DlgStageRename.cs" />
     <Compile Include="Measure\GetStageInfo\StageFile.cs" />
     <Compile Include="Measure\GetXrayInfo\PosXrayFileMgr.cs" />
@@ -185,6 +191,9 @@
     <EmbeddedResource Include="Measure\GetParam\DIALOG_CHECK_PARAM_RESULT.resx">
       <DependentUpon>DIALOG_CHECK_PARAM_RESULT.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="Measure\GetStageInfo\DlgStageMgr.resx">
+      <DependentUpon>DlgStageMgr.cs</DependentUpon>
+    </EmbeddedResource>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">