123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- namespace OTSMeasureApp
- {
- public abstract class ARectangleGDIObject
- {
- #region 共同属性
- /// <summary>
- /// 所有图形共同属性 尺寸(int类型)
- /// </summary>
- public abstract Rectangle Region { get; set; }
- /// <summary>
- /// 所有图形共同属性 尺寸(float类型)
- /// </summary>
- public abstract RectangleF RegionF { get; set; }
- /// <summary>
- /// 所有图形共同属性 绘制时与移动缩放时记录的位置与尺寸(float类型)
- /// </summary>
- public abstract RectangleF DrawRegionF { get; set; }
- /// <summary>
- /// 多边形点集合对象 位置(int类型)
- /// </summary>
- public abstract List<Point> PolygonPointRegion { get; set; }
- /// <summary>
- /// 多边形点集合对象 位置(float类型)
- /// </summary>
- public abstract List<PointF> PolygonPointRegionF { get; set; }
- /// <summary>
- /// 多边形点集合对象 绘制时与移动缩放时记录的位置(float类型)
- /// </summary>
- public abstract List<PointF> DrawPolygonPointRegionF { get; set; }
-
- /// <summary>
- /// 编号
- /// </summary>
- public abstract string ID { get; set; }
- /// <summary>
- /// 样品孔名称
- /// </summary>
- public abstract string Name { get; set; }
- /// <summary>
- /// 所有图形共同属性 是否拖动
- /// </summary>
- public abstract bool IsDragging { get; set; }
- /// <summary>
- /// 创建类型 记录生成的图形类型
- /// </summary>
- public abstract int CreateType { get; set; }
- //0:圆形 1:矩形
- public abstract int Shape { get; set; }
- /// <summary>
- /// 拖动到的位置
- /// </summary>
- public abstract Point DraggingPoint { get; set; }
- /// <summary>
- /// 绘制事件
- /// </summary>
- /// <param name="e"></param>
- public abstract void OnPaint(PaintEventArgs e);
- #endregion
- #region 样品台属性
- /// <summary>
- /// 记录样品台中的样品数量(样品台属性)
- /// </summary>
- public abstract int SampleCount { get; set; }
- /// <summary>
- /// 样品台中心与工作区域中心相差的位置
- /// </summary>
- public abstract PointF SampleCenterDifferCenterPoint { get; set; }
- #endregion
- #region 样品属性
- /// <summary>
- /// 样品名称
- /// </summary>
- public abstract string SampleName { get; set; }
- /// <summary>
- /// 是否选中 (测量区域与样品属性)
- /// </summary>
- public abstract bool IsSelect { get; set; }
- /// <summary>
- /// 是否为工作样品 (样品属性)
- /// </summary>
- public abstract bool IsWorkSample { get; set; }
- #endregion
- #region 测量区域属性
- /// <summary>
- /// 是否存在帧图 (测量区域属性)
- /// </summary>
- public abstract bool IsSingle { get; set; }
- /// <summary>
- /// 图形的路径 (圆角矩形、测量区域)
- /// </summary>
- public abstract GraphicsPath GPath { get; set; }
- #endregion
- #region 帧图属性
- /// <summary>
- /// 创建新图形时的颜色 (样品、帧图、标样)
- /// </summary>
- public abstract Color SelColor { get; set; }
- /// <summary>
- /// 绘制直线的开始位置 (帧图绘制直线)
- /// </summary>
- public abstract PointF StartPoint { get; set; }
- /// <summary>
- /// 绘制直线的开始位置 (帧图绘制直线)
- /// </summary>
- public abstract PointF EndPoint { get; set; }
- #endregion
- #region 颗粒属性
- /// <summary>
- /// 创建新图形时的颜色
- /// </summary>
- public abstract Color LineColor { get; set; }
- /// <summary>
- /// 创建颗粒直线长度
- /// </summary>
- public abstract float LineLength { get; set; }
- /// <summary>
- /// 创建颗粒直线长度
- /// </summary>
- public abstract PointF LineStartPoint { get; set; }
- /// <summary>
- /// SEM中心位置
- /// </summary>
- public abstract PointF SEMCenterPoint { get; set; }
- #endregion
- #region 测量区域
- /// <summary>
- /// OTS帧图X位置
- /// </summary>
- public abstract int OTSX { get; set; }
- /// <summary>
- /// OTS帧图Y位置
- /// </summary>
- public abstract int OTSY { get; set; }
- #endregion
- #region 绘制样品孔BSE图像
- public abstract Image BSEImage { get; set; }
- //绘制样品孔BSE图像宽度
- public abstract float BSEImageWitdh { get; set; }
- //绘制样品孔BSE图像高度
- public abstract float BSEImageHeight { get; set; }
- //绘制样品孔BSE图像位置
- public abstract PointF BSEImageLocation { get; set; }
- #endregion
- }
- public class CreateRectangle : ARectangleGDIObject // 同样的方式可以从ADraggableGDIObject生成其它图形的继承角类,比如矩形,三形等等。。
- {
- /// <summary>
- /// 创建图形
- /// </summary>
- /// <param name="startx">X位置</param>
- /// <param name="starty">Y位置</param>
- /// <param name="width">宽度</param>
- /// <param name="height">高度</param>
- /// <param name="cType">图形类型:createType=0 圆角矩形 createType=1 圆形 createType=2 文字</param>
- /// <param name="str">文字内容</param>
- public CreateRectangle(float startx, float starty, float width, float height, int cType, string str, string name)
- {
- m_Region = new Rectangle((int)startx, (int)starty, (int)width, (int)height);
- m_RegionF = new RectangleF(startx, starty, width, height);
- m_DrawRegionF = new RectangleF(startx, starty, width, height);
- CreateType = cType;
- strContent = str;
- Name = name;
- ID = System.Guid.NewGuid().ToString();
- OTSX = -1;
- OTSY = -1;
- }
- public CreateRectangle(RectangleF rect, int cType)
- {
- m_Region = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
- m_RegionF = rect;
- m_DrawRegionF = rect;
- CreateType = cType;
- ID = System.Guid.NewGuid().ToString();
- startPoint = new PointF(rect.Left, rect.Top);
- EndPoint = new PointF(rect.Right, rect.Bottom);
- OTSX = -1;
- OTSY = -1;
- }
- public CreateRectangle(RectangleF rect, int cType, string name)
- {
- m_Region = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
- m_RegionF = rect;
- m_DrawRegionF = rect;
- CreateType = cType;
- Name = name;
- ID = System.Guid.NewGuid().ToString();
- OTSX = -1;
- OTSY = -1;
- }
- public CreateRectangle(RectangleF rect, int cType, int shape, string name)
- {
- m_Region = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
- m_RegionF = rect;
- m_DrawRegionF = rect;
- CreateType = cType;
- Name = name;
- Shape = shape;
- ID = System.Guid.NewGuid().ToString();
- OTSX = -1;
- OTSY = -1;
- }
- public CreateRectangle(RectangleF rect, int cType, int shape, string name, Color selColor)
- {
- m_Region = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
- m_RegionF = rect;
- m_DrawRegionF = rect;
- CreateType = cType;
- Name = name;
- Shape = shape;
- SelColor = selColor;
- ID = System.Guid.NewGuid().ToString();
- OTSX = -1;
- OTSY = -1;
- }
- public CreateRectangle(RectangleF rectMeasure, PointF sampleCenterDifferPoint, int cType, int shape, string name, string sampleName, Color selColor)
- {
- m_Region = new Rectangle((int)rectMeasure.X, (int)rectMeasure.Y, (int)rectMeasure.Width, (int)rectMeasure.Height);
- m_RegionF = rectMeasure;
- m_DrawRegionF = rectMeasure;
- SampleCenterDifferCenterPoint = sampleCenterDifferPoint;
- CreateType = cType;
- Name = name;
- Shape = shape;
- SelColor = selColor;
- SampleName = sampleName;
- ID = System.Guid.NewGuid().ToString();
- OTSX = -1;
- OTSY = -1;
- }
- //绘制帧图
- public CreateRectangle(RectangleF rectSingle, int cType, string name, string sampleName, Color selColor)
- {
- m_Region = new Rectangle((int)rectSingle.X, (int)rectSingle.Y, (int)rectSingle.Width, (int)rectSingle.Height);
- m_RegionF = rectSingle;
- m_DrawRegionF = rectSingle;
- CreateType = cType;
- Name = name;
- Shape = 0;
- SelColor = selColor;
- SampleName = sampleName;
- ID = System.Guid.NewGuid().ToString();
- OTSX = -1;
- OTSY = -1;
- }
- //绘制帧图
- public CreateRectangle(RectangleF rectSingle, int OTSx, int OTSy, int cType, string name, string sampleName, Color selColor)
- {
- m_Region = new Rectangle((int)rectSingle.X, (int)rectSingle.Y, (int)rectSingle.Width, (int)rectSingle.Height);
- m_RegionF = rectSingle;
- m_DrawRegionF = rectSingle;
- CreateType = cType;
- Name = name;
- Shape = 0;
- SelColor = selColor;
- SampleName = sampleName;
- ID = System.Guid.NewGuid().ToString();
- OTSX = OTSx;
- OTSY = OTSy;
- }
- /// <summary>
- /// 绘制颗粒图
- /// </summary>
- /// <param name="lineStartPoint">绘制直线开始点</param>
- /// <param name="lineLength">直线的长度</param>
- /// <param name="cType">类型</param>
- /// <param name="lineColor">颜色</param>
- public CreateRectangle(PointF lineStartPoint, float lineLength, int cType, Color lineColor)
- {
- m_Region = new Rectangle((int)lineStartPoint.X, (int)lineStartPoint.Y, (int)lineLength, 1);
- m_RegionF = new RectangleF(lineStartPoint.X, lineStartPoint.Y, lineLength, 1);
- LineColor = lineColor;
- CreateType = cType;
- LineStartPoint = lineStartPoint;
- LineLength = lineLength;
- OTSX = -1;
- OTSY = -1;
- }
- /// <summary>
- /// 获取样品孔中BSE图像
- /// </summary>
- /// <param name="rect">位置大小</param>
- /// <param name="sampleHoleName">所在样品孔名称</param>
- /// <param name="bseImage">图像信息</param>
- /// <param name="bseImageWitdh">图像宽度</param>
- /// <param name="bseImageHeight">图像高度</param>
- /// <param name="drawImageLocation">图像开始位置</param>
- /// <param name="cType">绘制类型</param>
- public CreateRectangle(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName, Image bseImage, float bseImageWitdh, float bseImageHeight, Point drawImageLocation, int cType)
- {
- m_Region = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
- m_RegionF = rect;
- m_DrawRegionF = rect;
- Name = sampleHoleName;
- SampleName = sampleName;
- //生成编号
- ID = System.Guid.NewGuid().ToString();
- //图像信息
- BSEImage = bseImage;
- //图像宽度
- BSEImageWitdh = bseImageWitdh;
- //图像高度
- BSEImageHeight = bseImageHeight;
- //图像位置
- BSEImageLocation = rect.Location;
- OTSX = OTSx;
- OTSY = OTSy;
- //绘制类型
- CreateType = cType;
- }
- /// <summary>
- /// 获取SEM中心位置
- /// </summary>
- /// <param name="semCPoint"></param>
- /// <param name="cType"></param>
- public CreateRectangle(PointF semCPoint, int cType)
- {
- CreateType = cType;
- ID = System.Guid.NewGuid().ToString();
- semCenterPoint = semCPoint;
- }
- public CreateRectangle(RectangleF rect, Point ImgPoint, float m_Multiple, int cType)
- {
- m_Region = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
- m_RegionF.X = m_Region.X - ImgPoint.X * m_Multiple;
- m_RegionF.Y = m_Region.Y - ImgPoint.Y * m_Multiple;
- m_DrawRegionF = m_Region;
- CreateType = cType;
- ID = System.Guid.NewGuid().ToString();
- startPoint = new PointF(m_Region.Left, m_Region.Top);
- EndPoint = new PointF(m_Region.Right, m_Region.Bottom);
- OTSX = -1;
- OTSY = -1;
- }
- /// <summary>
- /// 获取多边形点集合
- /// </summary>
- /// <param name="mPoint"></param>
- /// <param name="cType"></param>
- public CreateRectangle(List<PointF> mPoint, int cType, int shape, string name, string sampleName, Color selColor)
- {
- ID = System.Guid.NewGuid().ToString();
- List<Point> PointRegion = new List<Point>();
- foreach (var item in mPoint)
- {
- PointRegion.Add(new Point((int)item.X, (int)item.Y));
- }
- PolygonPointRegion = PointRegion;
- PolygonPointRegionF = mPoint;
- List<PointF> DrawPoint = new List<PointF>();
- foreach (var item in mPoint)
- {
- DrawPoint.Add(item);
- }
- DrawPolygonPointRegionF = DrawPoint;
- Name = name;
- SampleName = sampleName;
- CreateType = cType;
- Shape = cType;
- SelColor = selColor;
- }
- #region 变量重写
- public override Image BSEImage
- {
- get { return bseImage; }
- set { bseImage = value; }
- }
- public override float BSEImageWitdh
- {
- get { return bseImageWidth; }
- set { bseImageWidth = value; }
- }
- public override float BSEImageHeight
- {
- get { return bseImageHeight; }
- set { bseImageHeight = value; }
- }
- public override PointF BSEImageLocation
- {
- get { return bseImageLocation; }
- set { bseImageLocation = value; }
- }
- public override Color LineColor
- {
- get { return lineColor; }
- set { lineColor = value; }
- }
- public override float LineLength
- {
- get { return lineLength; }
- set { lineLength = value; }
- }
- public override PointF LineStartPoint
- {
- get { return lineStartPoint; }
- set { lineStartPoint = value; }
- }
- public override PointF SEMCenterPoint
- {
- get { return semCenterPoint; }
- set { semCenterPoint = value; }
- }
- public override int OTSX
- {
- get { return otsX; }
- set { otsX = value; }
- }
- public override int OTSY
- {
- get { return otsY; }
- set { otsY = value; }
- }
- public override int CreateType
- {
- get { return createType; }
- set { createType = value; }
- }
- public override int Shape
- {
- get { return shape; }
- set { shape = value; }
- }
- public override Color SelColor
- {
- get { return selColor; }
- set { selColor = value; }
- }
- public override string Name
- {
- get { return name; }
- set { name = value; }
- }
- public override string ID
- {
- get { return id; }
- set { id = value; }
- }
- public override string SampleName
- {
- get { return sampleName; }
- set { sampleName = value; }
- }
- public override int SampleCount
- {
- get { return sampleCount; }
- set { sampleCount = value; }
- }
- public string StrContent
- {
- get { return strContent; }
- set { strContent = value; }
- }
- public override Rectangle Region
- {
- get { return m_Region; }
- set { m_Region = value; }
- }
- public override RectangleF RegionF
- {
- get { return m_RegionF; }
- set { m_RegionF = value; }
- }
- public override RectangleF DrawRegionF
- {
- get { return m_DrawRegionF; }
- set { m_DrawRegionF = value; }
- }
- public override List<Point> PolygonPointRegion
- {
- get { return m_PolygonPointRegion; }
- set { m_PolygonPointRegion = value; }
- }
- public override List<PointF> PolygonPointRegionF
- {
- get { return m_PolygonPointRegionF; }
- set { m_PolygonPointRegionF = value; }
- }
- public override List<PointF> DrawPolygonPointRegionF
- {
- get { return m_DrawPolygonPointRegionF; }
- set { m_DrawPolygonPointRegionF = value; }
- }
- public override GraphicsPath GPath
- {
- get { return g_Path; }
- set { g_Path = value; }
- }
- public override PointF StartPoint
- {
- get { return startPoint; }
- set { startPoint = value; }
- }
- public override PointF EndPoint
- {
- get { return endPoint; }
- set { endPoint = value; }
- }
- public override PointF SampleCenterDifferCenterPoint
- {
- get { return sampleCenterDifferCenterPoint; }
- set { sampleCenterDifferCenterPoint = value; }
- }
- #endregion
- public override void OnPaint(PaintEventArgs e)
- {
- //createType=0 圆角矩形 createType=1 圆形 createType=2 文字
- if (createType == (int)CreateRectangleType.SampleBackGround_Rectangle)
- {
- //获取颜色
- string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.RoundRectangleColor);
- Color myColor = ColorTranslator.FromHtml(ColorStr);
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- GraphicsPath grPath = CreateRoundedRectanglePath(m_Region, 20);
- e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
- e.Graphics.FillPath(sampleBrush, grPath);
- e.Graphics.DrawPath(Pens.Black, grPath);
- }
- //样品台-圆形
- else if (createType == (int)CreateRectangleType.SampleBackGround_Circle)
- {
- //获取颜色
- string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleBackGroundColor);
- Color myColor = ColorTranslator.FromHtml(ColorStr);
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- e.Graphics.FillEllipse(sampleBrush, m_Region);
- e.Graphics.DrawEllipse(Pens.Black, m_Region);
- }
- //圆形
- else if (createType == (int)CreateRectangleType.Circle)
- {
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- e.Graphics.FillEllipse(sampleBrush, m_Region);
- e.Graphics.DrawEllipse(Pens.Black, m_Region);
- }
- //文字
- else if (createType == (int)CreateRectangleType.Font)
- {
- //设置文字对齐方式
- StringFormat sf = new StringFormat();
- sf.Alignment = StringAlignment.Center;
- sf.LineAlignment = StringAlignment.Center;
- //文字颜色
- string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FontColor);
- 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 = m_Region.Width / 4;
- Font font = new Font("宋体", fontSize, FontStyle.Regular);
- if (fontSize == 0)
- {
- font = new Font("宋体", fontSize, FontStyle.Regular);
- }
- //消除锯齿
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- //绘制文字阴影
- Rectangle rectFont = m_Region;
- rectFont.X += 2;
- rectFont.Y += 2;
- e.Graphics.DrawString(strContent, font, solidBrush, rectFont, sf);
- e.Graphics.DrawString(strContent, font, sampleBrush, m_Region, sf);
- }
- //矩形
- else if (createType == (int)CreateRectangleType.Rectangle)
- {
- Color myColor = System.Drawing.Color.White;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- e.Graphics.FillRectangle(sampleBrush, m_Region);
- e.Graphics.DrawRectangle(Pens.Black, m_Region);
- }
- //选择样品台
- else if (createType == (int)CreateRectangleType.SelectSample)
- {
- Color myColor = selColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.AssumeLinear;//再加一点
- if (Shape == 0)
- {
- e.Graphics.FillEllipse(sampleBrush, m_Region);
- e.Graphics.DrawEllipse(Pens.Black, m_Region);
- }
- else
- {
- e.Graphics.FillRectangle(sampleBrush, m_Region);
- e.Graphics.DrawRectangle(Pens.Black, m_Region);
- }
- }
- //测试区域
- else if (createType == (int)CreateRectangleType.MeasureArea)
- {
- Color myColor = selColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen p = new Pen(myColor, 1);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- GraphicsPath MeasureAreaPath = new GraphicsPath();
- if (Shape == 0)
- {
- MeasureAreaPath.AddEllipse(m_RegionF);
- e.Graphics.DrawEllipse(p, m_Region);
- }
- else
- {
- MeasureAreaPath.AddRectangle(m_RegionF);
- e.Graphics.DrawRectangle(p, m_Region.X, m_Region.Y, m_Region.Width, m_Region.Height);
- }
- }
- //绘制帧图 直线
- else if (createType == (int)CreateRectangleType.SingleLine)
- {
- //设置颜色
- string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SingleColor);
- Color myColor = ColorTranslator.FromHtml(ColorStr);
- //设置画笔
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen pen = new Pen(sampleBrush, 0.0001f);
- //未抗锯齿
- e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
- e.Graphics.InterpolationMode = InterpolationMode.Default;
- e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
- //设置直线位置与尺寸
- PointF startPointF = new PointF(startPoint.X, startPoint.Y);
- PointF endPointF = new PointF(endPoint.X, endPoint.Y);
- //度量单位
- e.Graphics.PageUnit = GraphicsUnit.Display;
- e.Graphics.DrawLine(pen, startPointF, endPointF);
- }
- //绘制标样
- else if (createType == (int)CreateRectangleType.SpecimenRectangle)
- {
- Color myColor = System.Drawing.Color.Black;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen pen = new Pen(sampleBrush, 0.0001f);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
- e.Graphics.DrawRectangle(pen, m_Region);
- e.Graphics.FillRectangle(sampleBrush, m_Region);
- }
- //绘制标样
- else if (createType == (int)CreateRectangleType.SpecimenCircle)
- {
- Color myColor = System.Drawing.Color.Black;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen pen = new Pen(sampleBrush, 0.0001f);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
- e.Graphics.DrawEllipse(pen, m_Region);
- e.Graphics.FillEllipse(sampleBrush, m_Region);
- }
- //绘制帧图
- else if (createType == (int)CreateRectangleType.SingleRectangle)
- {
- Color myColor = SelColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen pen = new Pen(sampleBrush, 0.01f);
- e.Graphics.SmoothingMode = SmoothingMode.Default;
- //设置直线位置与尺寸
- PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
- PointF endPointF = new PointF(m_RegionF.Right, m_RegionF.Bottom);
- //绘制帧图
- e.Graphics.DrawRectangle(pen, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
- }
- //绘制颗粒
- else if (createType == (int)CreateRectangleType.ParticleLine)
- {
- Color myColor = LineColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen pen = new Pen(sampleBrush, 0.01f);
- e.Graphics.SmoothingMode = SmoothingMode.Default;
- //设置直线位置与长度
- PointF startPointF = LineStartPoint;
- float length = LineLength;
- PointF endPointF = new PointF(startPointF.X + length, startPointF.Y);
- e.Graphics.DrawLine(pen, startPointF, endPointF);
- }
- //矩形
- else if (createType == (int)CreateRectangleType.ParticleAreaRectangle)
- {
- Color myColor = System.Drawing.Color.White;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- e.Graphics.DrawRectangle(Pens.Black, m_Region);
- }
- //绘制样品孔BSE图像
- else if (createType == (int)CreateRectangleType.DrawSampleHoleBSEImage)
- {
- Color myColor = System.Drawing.Color.White;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- //设置直线位置与尺寸
- PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
- PointF endPointF = new PointF(m_RegionF.Right + 2, m_RegionF.Bottom + 2);
- //绘制样品孔中图像信息
- if (BSEImage != null)
- {
- e.Graphics.DrawImage(BSEImage, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
- }
- }
- else if (createType == (int)CreateRectangleType.DrawSEMCenterPoint)
- {
- Color myColor = System.Drawing.Color.Red;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- //X轴线
- PointF startPointX = semCenterPoint;
- startPointX.X = startPointX.X - 3;
- PointF endPointX = semCenterPoint;
- endPointX.X = endPointX.X + 3;
- //Y轴线
- PointF startPointY = semCenterPoint;
- startPointY.Y = startPointY.Y - 3;
- PointF endPointY = semCenterPoint;
- endPointY.Y = endPointY.Y + 3;
- //绘制XY轴交叉线+
- Pen pen = new Pen(sampleBrush, 0.0001f);
- e.Graphics.DrawLine(pen, startPointX, endPointX);
- e.Graphics.DrawLine(pen, startPointY, endPointY);
- }
- //绘制BSE标记
- else if (createType == (int)CreateRectangleType.DrawBSEElementSignPoint)
- {
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- Pen pen = new Pen(sampleBrush, 2f);
- int X = (int)m_DrawRegionF.X;
- int Y = (int)m_DrawRegionF.Y;
- e.Graphics.DrawLine(pen, new Point(X-8,Y), new Point(X+8, Y));
- e.Graphics.DrawLine(pen, new Point(X, Y-8), new Point(X, Y+8));
- }
- //绘制多边形测量区域
- else if (createType == (int)CreateRectangleType.Polygon)
- {
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- Color myColor = selColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen pen = new Pen(myColor, 1);
- if (PolygonPointRegionF.Count > 0)
- {
- List<PointF> PolygonPointF = new List<PointF>();
- foreach (var item in PolygonPointRegionF)
- {
- PolygonPointF.Add(item);
- }
- if (EndPoint.X != 0 && EndPoint.Y != 0)
- {
- PolygonPointF.Add(EndPoint);
- }
- try
- {
- e.Graphics.DrawLines(pen, PolygonPointF.ToArray());
- //多边形的外接矩形
- //if (Region != null)
- //{
- // e.Graphics.DrawRectangle(new Pen(Color.Green), Region);
- //}
- }
- catch (Exception)
- {
- }
- }
- }//多边形测量区域完成标识
- else if (createType == (int)CreateRectangleType.DrawPolygonFinish)
- {
- Color myColor = selColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- Pen pen = new Pen(myColor, 1);
- e.Graphics.DrawRectangle(pen, m_Region);
- }
- //绘制多边形测量区域
- else if (createType == (int)CreateRectangleType.CircleByThreePoints)
- {
- Color myColor = selColor;
- System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
- Pen p = new Pen(myColor, 1);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
- e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
- GraphicsPath MeasureAreaPath = new GraphicsPath();
-
- MeasureAreaPath.AddEllipse(m_RegionF);
- e.Graphics.DrawEllipse(p, m_Region);
-
- }
- }
- public override bool IsDragging
- {
- get { return m_IsDragging; }
- set { m_IsDragging = value; }
- }
- public override bool IsSelect
- {
- get { return m_IsSelect; }
- set { m_IsSelect = value; }
- }
- public override bool IsSingle
- {
- get { return m_IsSingle; }
- set { m_IsSingle = value; }
- }
- public override bool IsWorkSample
- {
- get { return m_IsWorkSample; }
- set { m_IsWorkSample = value; }
- }
- public override Point DraggingPoint
- {
- get { return m_DraggingPoint; }
- set { m_DraggingPoint = value; }
- }
- #region 画圆角矩形
- internal static GraphicsPath CreateRoundedRectanglePath(Rectangle rect, int cornerRadius)
- {
- GraphicsPath roundedRect = new GraphicsPath();
- roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
- roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
- roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
- roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
- roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
- roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
- roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
- roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
- roundedRect.CloseFigure();
- return roundedRect;
- }
- #endregion
- //是否设置为选择样品
- private bool m_IsSelect;
- //是否存在帧图信息
- private bool m_IsSingle;
- //是否设置为拖动
- private bool m_IsDragging;
- //是否为工作样品
- private bool m_IsWorkSample;
- private int createType;
- private int shape;
- private string id;
- private string name;
- public string sampleName;
- //样品孔中样品的数量
- public int sampleCount = 0;
- public string strContent;
- private Color selColor;
- private Point m_DraggingPoint;
- private Rectangle m_Region;
- private RectangleF m_RegionF;
- //绘制时与移动缩放时记录的位置与尺寸
- private RectangleF m_DrawRegionF;
- private GraphicsPath g_Path;
- private PointF startPoint;
- private PointF endPoint;
- private PointF sampleCenterDifferCenterPoint;
- //绘制颗粒图
- private Color lineColor;
- private float lineLength;
- private PointF lineStartPoint;
- private int otsX;
- private int otsY;
- //绘制样品孔BSE图像
- private Image bseImage;
- //绘制样品孔BSE图像宽度
- private float bseImageWidth;
- //绘制样品孔BSE图像高度
- private float bseImageHeight;
- //绘制样品孔BSE图像位置
- private PointF bseImageLocation;
- //绘制SEM中心位置
- private PointF semCenterPoint;
- //
- private List<Point> m_PolygonPointRegion;
- private List<PointF> m_PolygonPointRegionF;
- //绘制时与移动缩放时记录的位置
- private List<PointF> m_DrawPolygonPointRegionF;
- }
- public enum SEMControlIndex
- {
- Magnification=0,
- WorkingDistance=1
- }
- public enum XYIndex
- {
- X = 0,
- Y = 1
- }
- //public enum IndexNum
- //{
- // First = 0,
- // Second = 1
- //}
- public enum CreateRectangleType
- {
- //样品台-圆形
- SampleBackGround_Circle = -1,
- //圆形
- Circle = 0,
- //圆角矩形
- SampleBackGround_Rectangle = 1,
- //样品孔中的文字
- Font = 2,
- //矩形
- Rectangle = 3,
- //选择的样品
- SelectSample = 4,
- //测量区域
- MeasureArea = 5,
- //帧图-直线绘制方式
- SingleLine = 6,
- //表样-矩形
- SpecimenRectangle = 7,
- //表样-圆形
- SpecimenCircle = 8,
- //帧图-矩形绘制
- SingleRectangle = 9,
- //颗粒直线图
- ParticleLine = 10,
- //颗粒分布图 鼠标
- ParticleAreaRectangle = 11,
- //绘制拍摄样品孔BSE照片
- DrawSampleHoleBSEImage = 12,
- //绘制sem中心点+
- DrawSEMCenterPoint=13,
- //绘制BSE采集标记
- DrawBSEElementSignPoint = 14,
- //多边形
- Polygon = 15,
- //多边形完成标识
- DrawPolygonFinish = 16,
- //圆形三点法
- CircleByThreePoints=17
- }
- public enum ContextMenuType
- {
- //样品孔右键菜单
- SampleHoleMenu = 0,
- //样品右键菜单
- SampleMenu = 1,
- //测量区域右键菜单
- MeasureMenu = 2,
- //线程运行后菜单
- ThreadRunMenu = 3,
- //样品台右键菜单
- SampleStateMenu = 4,
- //样品孔BSE图像
- SampleHoleBSEImage = 5,
- //帧图菜单
- SingleMenu = 6
- }
- public enum MeasureStateMenuType
- {
- //获取BSE图
- SampleParaLock = 0,
- //设置可视化灰度
- SetVisualGray = 1,
- //显示BSE灰度曲线图
- SetVisualGrayForSpecialGray=2,
- grayToolStripMenuItem =4,
- //切换至BSE图
- ChangeDiffImageShow = 5,
- //BSE去背景图
- DelBSEBG =6,
- //显示BSE去背景灰度曲线图
- SampleHoleBSEImage = 7,
- //线扫描曲线
- MenuItemLineScam = 9,
- //单点采集Xray与元素信息
- PointScanElementMenuItem = 10,
- //导出采集信息报告
- ExportReport =11
- }
- //public enum photoMode
- //{
- // measureMode=0,
- // sampleHoleMode=1
- //}
- public enum MenuIndex
- {
- AddSample = 0,
- DeleteSample = 1,
- SampleStripSeparator = 2,
- ReadSEMData = 3,
- SetSemData = 4,
- SetSEMCenterLocation = 5,
- DriveSEMToCenterLocation = 6,
- DriveSEMToCurrentLocation = 7,
- SEMStripSeparator = 8,
- ShootBSEPicture = 9,
- DeleteBSEPicture = 10
- }
- public enum ColorType
- {
- SingleColor,//帧图fd8f8f
- RoundRectangleColor,//c8c8c8圆角矩形
- SampleBackGroundColor,//c0c0c0圆角矩形
- FontColor,//90ee90文字颜色
- SampleColor,//f4f4f4 样品未选择
- SampleSelColor//505050 样品选择后
- }
-
- public enum GrayLevel
- {
- Min=0,
- Max=255
- }
- }
|