| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using OTSDataType;
- using static OTSModelSharp.ResourceManage.ResourceID;
- using static OTSModelSharp.ResourceManage.ResourceData;
- using System.Drawing.Drawing2D;
- namespace OTSModelSharp.Measure.GetStageInfo
- {
- public partial class DlgStageMgr : Form
- {
-
- public static NLog.Logger loger = NLog.LogManager.GetCurrentClassLogger();
- otsdataconst model = new otsdataconst();
- // stage file
- CStageParam m_pStageFile;
- // stage list value
- int m_nListBoxStageListIndex=0;
- // 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;
- const int ROUND_VALUE = 20; //round rect angle
- public struct BLENDFUNCTION
- {
- public Byte BlendOp;
- public Byte BlendFlags;
- public Byte SourceConstantAlpha;
- public Byte AlphaFormat;
- }
- public DlgStageMgr(CStageParam m_cstagefile)
- {
- InitializeComponent();
- m_pStageFile = m_cstagefile;
- }
- private void DlgStageMgr_Load(object sender, EventArgs e)
- {
- // 加载样品台文件; \Config\SysData\OTSStage.stg
- if (!m_pStageFile.Load( true, false))
- {
- return;
- }
- SetStageListControlData();
- m_ctrlListBoxStageList.Text = XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_StageList);
- m_ctrlBtnApply.Text = XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_Apply);
- m_ctrlBtnDelete.Text = XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_Delete);
- m_ctrlBtnRename.Text=XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_Rename);
- IDC_BTN_IMPORT.Text= XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_Import);
- m_ctrlBtnExport.Text=XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_Export);
- this.Text=XmlResourceData.GetInstance().GetStringByKey(GrpOtherParam, DlgStageMgr_Title);
- }
- // CDlgStageMgr message map
- public void OnClickedBtnImport(object sender, EventArgs e)
- {
- loger.Trace("OnClickedBtnImport: import a stage from txt file.");
- String strDlgTitle = "";
- if (strDlgTitle == "")
- {
- // file open dialog
- OpenFileDialog openFileDialog = new OpenFileDialog();
- // get file pathname
- openFileDialog.Filter = "txt files(*.txt)|*.txt|All files(*.*)|*.*";
-
- strDlgTitle = openFileDialog.FileName;
- DialogResult dresult = openFileDialog.ShowDialog();
- if (dresult == DialogResult.OK)
- {
- String strPathName = openFileDialog.FileName;
- if (strPathName == "")
- {
- loger.Error("OnClickedBtnImport: input an empty path.");
- return;
- }
- CSEMStageData a_pCSEMStageData = new CSEMStageData();
- //获取配置文件中 StageData 内容
- COTSDefaultParam m_DefaultParam = new COTSDefaultParam();
- m_DefaultParam.LoadInfoFromProgMgrFile();
- a_pCSEMStageData = m_DefaultParam.GetStageDataParam();
- // load a stage from txt file
- if (!m_pStageFile.LoadStageFromTextFile(strPathName, a_pCSEMStageData))
- {
- loger.Error("OnClickedBtnImport: failed to import a stage.");
- return;
- }
- // set modify flag
- m_pStageFile.SetModify(true);
- // the new stage insert to stage list
- SetStageListControlData();
- loger.Trace("OnClickedBtnImport: a stage has been import.");
- }
- }
- else
- {
- loger.Error("OnClickedBtnImport: import action has been cancled.");
- return;
- }
- // show the stage
- m_bShowFlag = false;
- }
- public void OnClickedBtnAply(object sender, EventArgs e)
- {
- 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())
- {
- loger.Error("OnClickedBtnAply: save a stage file failed.");
- return;
- }
- }
- this.Close(); //CDialog::OnOK();
- }
- public void OnClickedBtnDel(object sender, EventArgs e)
- {
- loger.Info("OnClickedBtnDel: the selected stage will be deleted.");
- if (DialogResult.Cancel == MessageBox.Show("Are you sure to delete this sample station?", "Warning", 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_nListBoxStageListIndex);
- // set new working stage
-
- m_nListBoxStageListIndex = 0;
- m_pStageFile.SetWorkingStageId(m_nListBoxStageListIndex);
-
- m_pStageFile.SetModify();
- //m_nListBoxStageList--;
- Invalidate();
- }
- SetStageListControlData();
- }
- public void OnClickedBtnExport(object sender, EventArgs e)
- {
- loger.Info("OnClickedBtnExport: the selected stage will be export stage into a txt.");
- UpdateStageFileData(true);
- // export a stage into text file
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.DefaultExt = null;
- saveFileDialog.InitialDirectory = null;
- saveFileDialog.CheckPathExists = true;
- saveFileDialog.Filter = "txt files(*.txt)|*.txt|All files(*.*)|*.*";
- DialogResult dr = saveFileDialog.ShowDialog();
- if (dr == System.Windows.Forms.DialogResult.OK)
- {
- string strPathName = saveFileDialog.FileName;
- if (string.IsNullOrEmpty(strPathName))
- {
- loger.Error("OnClickedBtnExport: empty path.");
- return;
- }
- m_pStageFile.SaveStageIntoTextFile(m_nListBoxStageListIndex, strPathName);
- }
- else
- {
- loger.Error("OnClickedBtnExport: export action is cancled.");
- return;
- }
- SetStageListControlData();
- }
- public void OnClickedBtnRename(object sender, EventArgs e)
- {
- loger.Trace("OnClickedBtnRename: the selected stage will be renamed.");
- UpdateStageFileData(true);
- CStage pStage = m_pStageFile.GetStagesList()[m_nListBoxStageListIndex];
- DlgStageRename dlg = new DlgStageRename();
- dlg.m_sEditName = pStage.GetName();
- if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- pStage.SetName(dlg.m_sStageName);
- m_pStageFile.SetModify();
- }
- else
- {
- loger.Error("OnClickedBtnRename: rename action is cancled.");
- return;
- }
- SetStageListControlData();
- }
- void OnSelchangeListStage(object sender, EventArgs e)
- {
- m_nListBoxStageListIndex = m_ctrlListBoxStageList.SelectedIndex;
- //UpdateStageFileData(true); 为避免关闭界面仍然保存当前选择的样品台,此处注销了
- m_ctrlStagePicture.Refresh();
- DrawStage();
- }
- void OnPaint(object sender, PaintEventArgs e)
- {
- //CPaintDC dc(this); // device context for painting
- if (!m_bShowFlag)
- {
- DrawStage();
- }
- }
- public void SetStageListControlData()
- {
- if (m_ctrlListBoxStageList.Items.Count > 0)
- {
- m_ctrlListBoxStageList.Items.Clear();
- }
- // 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_nListBoxStageListIndex == 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();
- int findIndex = m_ctrlListBoxStageList.FindString(sCurrentName);
- if (findIndex < 0)
- {
- m_ctrlListBoxStageList.Items.Add(sCurrentName);
- }
- }
- //default is the first item
- m_ctrlListBoxStageList.SelectedIndex = m_nListBoxStageListIndex;
- 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 there is sample on the stage, the working stage can't be changed.
- m_pStageFile.SetWorkingStageId(m_nListBoxStageListIndex);
-
- }
- public bool UpdateData(bool bSaveAndValidate)
- {
- return true;
- }
- public void DrawStage()
- {
- if (m_nListBoxStageListIndex < 0 || m_nListBoxStageListIndex > (int)(m_pStageFile.GetStagesList().Count))
- {
- return;
- }
- Rectangle rc = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
- Rectangle re = new Rectangle(m_ctrlStagePicture.Location, m_ctrlStagePicture.Size);
- int pWnd = GetDlgItem(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));
- //Draw stage
- if (m_pStageFile.GetStagesList().Count > 0)
- {
- 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
- List<CStage> pStage = m_pStageFile.GetStagesList();//get curretn working stage
- CDomain pBoundery = pStage[m_nListBoxStageListIndex].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 - PIC_EDGE * 2));
- }
- else
- {
- PixSize = (long)((double)nBounderyHeight / (double)(nHeight - PIC_EDGE * 2));
- }
- //draw boundery
- Brush pLTGrayBrush = new SolidBrush(Color.FromArgb(255, 0, 0));
- 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);
- ////draw holes
- //Brush pWriteBrush = new SolidBrush(Color.FromArgb(255, 0, 0)); ;
- DrawStageHole(pStage[m_nListBoxStageListIndex], nWidth, nHeight, pDC, PixSize);
- // draw ratio
- DrawRatio(nBounderyWidth, nWidth, nHeight, pDC, (IntPtr)pWnd, rc);
- pLTGrayBrush.Dispose();
- //pBlackBrush.Dispose();
- //pWriteBrush.Dispose();
- //graphics.Dispose();
- //((Graphics)pDC).Dispose();
- }
- else
- {
- // paint the stage
- m_bShowFlag = true;
- }
- pOldBrush.Dispose();
- }
- public int GetDlgItem(int nID)
- {
- return nID;
- }
- //// stage file get and set
- //public CStageParam GetStageFile()
- //{
- // return m_pStageFile;
- //}
- //public void SetStageFile(CStageParam a_pStageFile)
- //{
- // m_pStageFile = a_pStageFile;
- //}
- //// soft pack id get and set
- //public otsdataconst.OTS_SysType_ID GetPackId() { return m_nPackId; }
- //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)
- {
- return;
- }
- CDomain pSTD = a_pStage.GetSTD();
- otsdataconst.DOMAIN_SHAPE nShape = (otsdataconst.DOMAIN_SHAPE)(-1);
- nShape = pSTD.GetShape();
- Rectangle PixRect = new Rectangle();
- GetPixRect(pSTD, a_nWidth, a_nHeight, a_dPixSize,ref PixRect);
- 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);
- // 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, 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;
- 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 CStageParam ShowStageMgrDialog(otsdataconst.OTS_SysType_ID a_nPackId, CStageParam 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(a_pStageFile);
- // dlg.SetStageFile(a_pStageFile);
- // dlg.SetPackId(a_nPackId);
- // dlg.ShowDialog();
- // CStageParam 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;
- //}
- }
- }
|