|
|
@@ -1,422 +0,0 @@
|
|
|
-
|
|
|
-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;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|