Sfoglia il codice sorgente

modify DlgStageMgr.cs

CXS 5 anni fa
parent
commit
f9d2798d3a

+ 68 - 68
OTS/OTSModelSharp/Measure/GetStageInfo/DlgStageMgr.Designer.cs

@@ -29,93 +29,93 @@
         private void InitializeComponent()
         private void InitializeComponent()
         {
         {
             this.groupBox1 = new System.Windows.Forms.GroupBox();
             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.m_ctrlBtnExport = new System.Windows.Forms.Button();
             this.IDC_BTN_IMPORT = new System.Windows.Forms.Button();
             this.IDC_BTN_IMPORT = new System.Windows.Forms.Button();
-            this.IDC_BTN_EXPORT = new System.Windows.Forms.Button();
+            this.m_ctrlBtnRename = new System.Windows.Forms.Button();
+            this.m_ctrlBtnDelete = new System.Windows.Forms.Button();
+            this.m_ctrlBtnApply = new System.Windows.Forms.Button();
+            this.m_ctrlStagePicture = new System.Windows.Forms.PictureBox();
+            this.m_ctrlListBoxStageList = new System.Windows.Forms.ListBox();
             this.groupBox1.SuspendLayout();
             this.groupBox1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.IDD_STAGE_MGR)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.m_ctrlStagePicture)).BeginInit();
             this.SuspendLayout();
             this.SuspendLayout();
             // 
             // 
             // groupBox1
             // groupBox1
             // 
             // 
-            this.groupBox1.Controls.Add(this.IDC_BTN_EXPORT);
+            this.groupBox1.Controls.Add(this.m_ctrlBtnExport);
             this.groupBox1.Controls.Add(this.IDC_BTN_IMPORT);
             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.Controls.Add(this.m_ctrlBtnRename);
+            this.groupBox1.Controls.Add(this.m_ctrlBtnDelete);
+            this.groupBox1.Controls.Add(this.m_ctrlBtnApply);
+            this.groupBox1.Controls.Add(this.m_ctrlStagePicture);
+            this.groupBox1.Controls.Add(this.m_ctrlListBoxStageList);
             this.groupBox1.Location = new System.Drawing.Point(2, 1);
             this.groupBox1.Location = new System.Drawing.Point(2, 1);
             this.groupBox1.Name = "groupBox1";
             this.groupBox1.Name = "groupBox1";
             this.groupBox1.Size = new System.Drawing.Size(697, 317);
             this.groupBox1.Size = new System.Drawing.Size(697, 317);
             this.groupBox1.TabIndex = 0;
             this.groupBox1.TabIndex = 0;
             this.groupBox1.TabStop = false;
             this.groupBox1.TabStop = false;
             // 
             // 
-            // IDC_BTN_RENAME
+            // m_ctrlBtnExport
             // 
             // 
-            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;
+            this.m_ctrlBtnExport.Location = new System.Drawing.Point(619, 291);
+            this.m_ctrlBtnExport.Name = "m_ctrlBtnExport";
+            this.m_ctrlBtnExport.Size = new System.Drawing.Size(75, 23);
+            this.m_ctrlBtnExport.TabIndex = 6;
+            this.m_ctrlBtnExport.Text = "导出";
+            this.m_ctrlBtnExport.UseVisualStyleBackColor = true;
             // 
             // 
-            // IDC_BTN_DEL
+            // IDC_BTN_IMPORT
             // 
             // 
-            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;
+            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_APLY
+            // m_ctrlBtnRename
             // 
             // 
-            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;
+            this.m_ctrlBtnRename.Location = new System.Drawing.Point(169, 291);
+            this.m_ctrlBtnRename.Name = "m_ctrlBtnRename";
+            this.m_ctrlBtnRename.Size = new System.Drawing.Size(75, 23);
+            this.m_ctrlBtnRename.TabIndex = 4;
+            this.m_ctrlBtnRename.Text = "重命名";
+            this.m_ctrlBtnRename.UseVisualStyleBackColor = true;
             // 
             // 
-            // IDD_STAGE_MGR
+            // m_ctrlBtnDelete
             // 
             // 
-            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;
+            this.m_ctrlBtnDelete.Location = new System.Drawing.Point(87, 291);
+            this.m_ctrlBtnDelete.Name = "m_ctrlBtnDelete";
+            this.m_ctrlBtnDelete.Size = new System.Drawing.Size(75, 23);
+            this.m_ctrlBtnDelete.TabIndex = 3;
+            this.m_ctrlBtnDelete.Text = "删除";
+            this.m_ctrlBtnDelete.UseVisualStyleBackColor = true;
             // 
             // 
-            // IDC_LIST_STAGE
+            // m_ctrlBtnApply
             // 
             // 
-            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;
+            this.m_ctrlBtnApply.Location = new System.Drawing.Point(6, 291);
+            this.m_ctrlBtnApply.Name = "m_ctrlBtnApply";
+            this.m_ctrlBtnApply.Size = new System.Drawing.Size(75, 23);
+            this.m_ctrlBtnApply.TabIndex = 2;
+            this.m_ctrlBtnApply.Text = "应用";
+            this.m_ctrlBtnApply.UseVisualStyleBackColor = true;
             // 
             // 
-            // IDC_BTN_IMPORT
+            // m_ctrlStagePicture
             // 
             // 
-            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;
+            this.m_ctrlStagePicture.Location = new System.Drawing.Point(316, 17);
+            this.m_ctrlStagePicture.Name = "m_ctrlStagePicture";
+            this.m_ctrlStagePicture.Size = new System.Drawing.Size(378, 267);
+            this.m_ctrlStagePicture.TabIndex = 1;
+            this.m_ctrlStagePicture.TabStop = false;
             // 
             // 
-            // IDC_BTN_EXPORT
+            // m_ctrlListBoxStageList
             // 
             // 
-            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;
+            this.m_ctrlListBoxStageList.FormattingEnabled = true;
+            this.m_ctrlListBoxStageList.ItemHeight = 12;
+            this.m_ctrlListBoxStageList.Location = new System.Drawing.Point(6, 17);
+            this.m_ctrlListBoxStageList.Name = "m_ctrlListBoxStageList";
+            this.m_ctrlListBoxStageList.Size = new System.Drawing.Size(294, 268);
+            this.m_ctrlListBoxStageList.TabIndex = 0;
             // 
             // 
             // DlgStageMgr
             // DlgStageMgr
             // 
             // 
@@ -127,7 +127,7 @@
             this.Text = "DlgStageMgr";
             this.Text = "DlgStageMgr";
             this.Load += new System.EventHandler(this.DlgStageMgr_Load);
             this.Load += new System.EventHandler(this.DlgStageMgr_Load);
             this.groupBox1.ResumeLayout(false);
             this.groupBox1.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.IDD_STAGE_MGR)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.m_ctrlStagePicture)).EndInit();
             this.ResumeLayout(false);
             this.ResumeLayout(false);
 
 
         }
         }
@@ -135,12 +135,12 @@
         #endregion
         #endregion
 
 
         private System.Windows.Forms.GroupBox groupBox1;
         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 m_ctrlBtnRename;
+        private System.Windows.Forms.Button m_ctrlBtnDelete;
+        private System.Windows.Forms.Button m_ctrlBtnApply;
+        private System.Windows.Forms.PictureBox m_ctrlStagePicture;
+        private System.Windows.Forms.ListBox m_ctrlListBoxStageList;
+        private System.Windows.Forms.Button m_ctrlBtnExport;
         private System.Windows.Forms.Button IDC_BTN_IMPORT;
         private System.Windows.Forms.Button IDC_BTN_IMPORT;
     }
     }
 }
 }

+ 110 - 41
OTS/OTSModelSharp/Measure/GetStageInfo/DlgStageMgr.cs

@@ -13,36 +13,16 @@ namespace OTSModelSharp.Measure.GetStageInfo
 {
 {
     public partial class DlgStageMgr : Form
     public partial class DlgStageMgr : Form
     {
     {
-        public DlgStageMgr()
-        {
-            InitializeComponent();
-        }
-
-        private void DlgStageMgr_Load(object sender, EventArgs e)
-        {
-
-        }
+        
         public static NLog.Logger loger = NLog.LogManager.GetCurrentClassLogger();
         public static NLog.Logger loger = NLog.LogManager.GetCurrentClassLogger();
 
 
         otsdataconst model = new otsdataconst();
         otsdataconst model = new otsdataconst();
-
         // stage file
         // stage file
         CStageFile m_pStageFile;
         CStageFile m_pStageFile;
 
 
-        System.Windows.Forms.Button m_ctrlBtnApply;
-
-        // stage list control
-        System.Windows.Forms.ListBox m_ctrlListBoxStageList;
-
         // stage list value
         // stage list value
         int m_nListBoxStageList;
         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
         // flag if the stage should be re-paint
         bool m_bShowFlag;
         bool m_bShowFlag;
 
 
@@ -50,21 +30,13 @@ namespace OTSModelSharp.Measure.GetStageInfo
         CDomain m_poBourary;
         CDomain m_poBourary;
 
 
         const int RATIO_RECT_LEFT = 22;   //ratio rect left edge
         const int RATIO_RECT_LEFT = 22;   //ratio rect left edge
-
         const int PIC_EDGE = 12;		  //edge width
         const int PIC_EDGE = 12;		  //edge width
-
         const int RATIO_RECT_HEIGHT = 30; //ratio rect height
         const int RATIO_RECT_HEIGHT = 30; //ratio rect height
-
         const int RATIO_RECT_DOWN = 10;   //ratio rect down edge
         const int RATIO_RECT_DOWN = 10;   //ratio rect down edge
-
         const int LTGRAY_BRUSH = 1;
         const int LTGRAY_BRUSH = 1;
-
         const int BLACK_BRUSH = 4;
         const int BLACK_BRUSH = 4;
-
         const int WHITE_BRUSH = 0;
         const int WHITE_BRUSH = 0;
-
-
-
+        const int ROUND_VALUE = 20;		  //round rect angle
 
 
         public struct BLENDFUNCTION
         public struct BLENDFUNCTION
         {
         {
@@ -75,21 +47,25 @@ namespace OTSModelSharp.Measure.GetStageInfo
         }
         }
 
 
 
 
-        public enum OTS_SOFT_PACKAGE_ID
+        // soft pack id
+        public otsdataconst.OTS_SOFT_PACKAGE_ID m_nPackId;
+
+        public DlgStageMgr()
         {
         {
-            INVALID = -1,
-            MIN = 0,
-            OTSIncA = 0,
-            OTSPartA = 1,
-            MAX = 1
+            InitializeComponent();
+        }
+
+        private void DlgStageMgr_Load(object sender, EventArgs e)
+        {
+
         }
         }
 
 
-        // soft pack id
-        public OTS_SOFT_PACKAGE_ID m_nPackId;
 
 
         // CDlgStageMgr message map
         // CDlgStageMgr message map
         public void OnClickedBtnImport()
         public void OnClickedBtnImport()
         {
         {
+            loger.Trace("OnClickedBtnImport: import a stage from txt file.");
+
             String strDlgTitle = "";
             String strDlgTitle = "";
             if (strDlgTitle == "")
             if (strDlgTitle == "")
             {
             {
@@ -105,14 +81,14 @@ namespace OTSModelSharp.Measure.GetStageInfo
                     String strPathName = openFileDialog.FileName;
                     String strPathName = openFileDialog.FileName;
                     if (strPathName == "")
                     if (strPathName == "")
                     {
                     {
-
+                        loger.Error("OnClickedBtnImport: input an empty path.");
                         return;
                         return;
                     }
                     }
 
 
                     // load a stage from txt file
                     // load a stage from txt file
                     if (!m_pStageFile.LoadStageFromTextFile(strPathName))
                     if (!m_pStageFile.LoadStageFromTextFile(strPathName))
                     {
                     {
-
+                        loger.Error("OnClickedBtnImport: failed to import a stage.");
                         return;
                         return;
                     }
                     }
 
 
@@ -120,13 +96,14 @@ namespace OTSModelSharp.Measure.GetStageInfo
                     m_pStageFile.SetModify(true);
                     m_pStageFile.SetModify(true);
                     // the new stage insert to stage list
                     // the new stage insert to stage list
                     SetStageListControlData();
                     SetStageListControlData();
+                    loger.Trace("OnClickedBtnImport: a stage has been import.");
                 }
                 }
 
 
 
 
             }
             }
             else
             else
             {
             {
-
+                loger.Error("OnClickedBtnImport: import action has been cancled.");
                 return;
                 return;
             }
             }
 
 
@@ -135,6 +112,98 @@ namespace OTSModelSharp.Measure.GetStageInfo
 
 
         }
         }
 
 
+        public void OnClickedBtnAply()
+        {
+
+            loger.Info("OnClickedBtnAply: the selected stage will be the working stage.");
+
+            UpdateStageFileData(true);
+
+            //create stage manager file
+            if (m_pStageFile.IsModified())
+            {
+                if (!m_pStageFile.Save(m_nPackId))
+                {
+                    loger.Error("OnClickedBtnAply: save a stage file failed.");
+                    return;
+                }
+            }
+
+            this.Close();   //CDialog::OnOK();
+        }
+
+        public void OnClickedBtnDel()
+        {
+            loger.Info("OnClickedBtnDel: the selected stage will be deleted.");
+
+            if (DialogResult.Cancel == MessageBox.Show("确定删除该样品台吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
+            {
+                loger.Info("OnClickedBtnDel: user cancled.");
+                return;
+            }
+
+            UpdateStageFileData(true);
+
+            // remove the stage
+            if (m_pStageFile.GetStagesList().Count() > 0)
+            {
+                m_pStageFile.GetStagesList().RemoveAt(m_nListBoxStageList);
+                // set new working stage
+                if (!m_pStageFile.GetInUse())
+                {
+                    m_pStageFile.SetWorkingStageId(0);
+                }
+                m_pStageFile.SetModify();
+                //m_nListBoxStageList--;
+                Invalidate();
+            }
+            SetStageListControlData();
+
+        }
+
+        public void OnClickedBtnExport()
+        {
+            loger.Info("OnClickedBtnExport: the selected stage will be export stage into a txt.");
+
+            UpdateStageFileData(true);
+
+
+            // export a stage into text file
+            CFileDialog dlg(FALSE, NULL, NULL, OFN_FILEMUSTEXIST, TEXTFILE_FILTER);
+            if (dlg.DoModal() == IDOK)
+            {
+                // get file path
+                CString strPathName = dlg.GetPathName() + TEXTFILE_FILE_EXT;
+                if (strPathName.IsEmpty())
+                {
+                    LogErrorTrace(__FILE__, __LINE__, _T("OnClickedBtnExport: empty path."));
+                    return;
+                }
+                m_pStageFile->SaveStageIntoTextFile(m_nListBoxStageList, strPathName);
+            }
+            else
+            {
+                LogErrorTrace(__FILE__, __LINE__, _T("OnClickedBtnExport: export action is cancled."));
+                return;
+            }
+
+            SaveFileDialog saveFileDialog = new SaveFileDialog();
+            saveFileDialog.DefaultExt = null;
+            saveFileDialog.InitialDirectory = null;
+            saveFileDialog.
+
+            DialogResult dr = saveFileDialog.ShowDialog();
+            if (dr == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(saveFileDialog.FileName.ToString()))
+            {
+                StreamWriter sw = new StreamWriter(filename, true, Encoding.UTF8);
+                sw.Write(textBox1.Text);
+                sw.Close();
+            }
+
+
+            SetStageListControlData();
+        }
+
         public void SetStageListControlData()
         public void SetStageListControlData()
         {
         {
             m_ctrlListBoxStageList.Dispose();
             m_ctrlListBoxStageList.Dispose();