using Eventech.Utils.Images; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; namespace TProduct.PumpGraph.Picture { public partial class FeatChart { public static TProduct.PumpGraph.Picture.LxpFeatChart Build(int Template) { if (Template == 0) { if (TProduct.CorpConfig.Instance.CorpFlag == Model.eCorpFlag.LIFU) { return new LxpFeatChartLIFU(); } } if (Template == 1) return new LxpFeatChartV1(); else if (Template == 2) return new LxpFeatChartV2(); else if (Template == 3) return new LxpFeatChartV3(); else return new LxpFeatChartV1(); } //导出目的 public enum eDockType { 未知, 单独导出, 测试报告, } public virtual Image CreateImage() { return null; } protected Graphics _graphics; protected bool _isMonoColor = false; protected int _imageTotalWidth = 1200; protected int _imageTotalHeight = 1800; protected eDockType _dockType = eDockType.单独导出; public virtual void SetDockType(eDockType type, int imageWidth, int imageHeight) { if (imageWidth > 10) this._imageTotalWidth = imageWidth; if (imageHeight > 10) this._imageTotalHeight = imageHeight; _dockType = type; } #region 网格线 //网格线X颜色 protected Color _gridLineColorX = Color.FromArgb(30, Color.Black); public Color GridLineColorX { get { return _gridLineColorX; } set { _gridLineColorX = value; } } //网格线Y颜色 protected Color _gridLineColorY = Color.FromArgb(30, Color.Black); public Color GridLineColorY { get { return _gridLineColorY; } set { _gridLineColorY = value; } } /// /// 画笔宽度 /// protected float _gridLineWidthX = 1f; public float GridLineWidthX { get { return _gridLineWidthX; } set { _gridLineWidthX = value; } } protected float _gridLineWidthY = 1f; public float GridLineWidthY { get { return _gridLineWidthY; } set { _gridLineWidthY = value; } } //是否显示Y的网格线 protected bool _isDispGridLineY = true; public bool IsDispGridLineY { get { return _isDispGridLineY; } set { _isDispGridLineY = value; } } //是否显示汽蚀曲线X的网格线 protected bool _isDispGridLineX = true; public bool IsDispGridLineX { get { return _isDispGridLineX; } set { _isDispGridLineX = value; } } #endregion #region 产品属性: 转速, 功率等 protected double _ratedN = -1; public double RatedN { get { return _ratedN; } set { _ratedN = value; } } protected string GetSpeedDispContent(double value) {//返回 return Math.Round(value, 1).ToString() + "rpm"; } protected double _workSpeed = 0; public double WorkSpeed { get { return _workSpeed; } set { _workSpeed = value; } } //电机功率 protected string _motorPower = null; public string MotorPower { get { return _motorPower; } set { _motorPower = value; } } #endregion #region D2 protected string GetD2DispContent(double value) {//返回 叶轮直径 if (_isD2Meter) { return Math.Round(value, 1).ToString() + "mm"; } else { return Math.Round(value / 25.4, 2).ToString() + "″"; } } protected bool _isD2Meter = true;//叶轮直径是否是公制 public bool IsD2Meter { get { return _isD2Meter; } set { _isD2Meter = value; } } protected double _originD2 = 0; protected double _workD2 = 0; protected double _minD2 = 0; public void SetYeLunD2(double max_d2, double min_d2, double work_d2) { this._originD2 = max_d2; this._minD2 = min_d2; this._workD2 = work_d2; } //是否显示直径单位 protected bool _isDispImpellerDiameterUnit = true; public bool IsDispImpellerDiameterUnit { get { return _isDispImpellerDiameterUnit; } set { _isDispImpellerDiameterUnit = value; } } #endregion #region 曲线以及曲线文字显示设置 public virtual void SetColorQH(Color color) { _axisTitleColorH = color; _curveColorQH = color; _axisLabelColorH = color; } public virtual void SetColorQE(Color color) { _curveColorQE = color; } public virtual void SetColorQP(Color color) { _curveColorQP = color; } protected Color _curveColorQH = Color.Blue; public Color CurveColorQH { get { return _curveColorQH; } set { _curveColorQH = value; } } protected Color _curveColorQE = Color.Green; public Color CurveColorQE { get { return _curveColorQE; } set { _curveColorQE = value; } } protected Color _curveColorQP = Color.Blue; public Color CurveColorQP { get { return _curveColorQP; } set { _curveColorQP = value; } } protected Color _curveColorNPSH = Color.Red; public Color CurveColorNPSH { get { return _curveColorNPSH; } set { _curveColorNPSH = value; } } protected float _curveWidth = 1f; public float CurveWidth { get { return _curveWidth; } set { _curveWidth = value; } } protected Color _curveParasLabelColor = Color.Black; public Color CurveParasLabelColor { get { return _curveParasLabelColor; } set { _curveParasLabelColor = value; } } protected short _curveParasLabelHeight = 9;//曲线上文字的高度 public short CurveParasLabelHeight { get { return _curveParasLabelHeight; } set { _curveParasLabelHeight = value; } } //文字辅助类 protected ChartCurveLabelHelper theCurveLabelHelper = null; //等效线效率值 protected Eventech.Model.AnnoAnchorPointList _annoAnchorPointList = null; public Eventech.Model.AnnoAnchorPointList AnnoAnchorPointList { get { return _annoAnchorPointList; } set { _annoAnchorPointList = value; } } #endregion #region 等效线及显示 //是否显示等效线 protected bool _isDispEqualParaCurveE = true; public bool IsDispEqualParaCurveE { get { return _isDispEqualParaCurveE; } set { _isDispEqualParaCurveE = value; } } //是否显示等效线的文字 protected bool _isDispEqualParaTextE = true; public bool IsDispEqualParaTextE { get { return _isDispEqualParaTextE; } set { _isDispEqualParaTextE = value; } } //等效线线框 protected float _equalParaCurveWidth = 1f; public float EqualParaCurveWidth { get { return _equalParaCurveWidth; } set { _equalParaCurveWidth = value; } } //等效线文字高度 protected short _equalCurveParaLabelHeight = 10; public short EqualCurveParaLabelHeight { get { return _equalCurveParaLabelHeight; } set { _equalCurveParaLabelHeight = value; } } //等效线文字颜色 protected System.Drawing.Color _equalParaCurveColor = Color.Red; public System.Drawing.Color EqualParaCurveColor { get { return _equalParaCurveColor; } set { _equalParaCurveColor = value; } } //等效线 protected Eventech.Model.CombineCurveList _equalParaCurveE = null; public Eventech.Model.CombineCurveList EqualParaCurveE { get { return _equalParaCurveE; } set { _equalParaCurveE = value; } } #endregion #region 图表尺寸 protected RectangleF _chartDiagram; protected PointF _diagramLeftBottomPt = new PointF(); protected PointF _diagramRightBottomPt = new PointF(0, 0);//X轴右端点 protected PointF _diagramRightTopPt = new PointF(0, 0);//y轴上端点 protected PointF _diagramLeftTopPt = new PointF(0, 0); protected int _diagramSpaceMarginBottom = 0;//控制X轴起始点到图像底部的距离 public int DiagramMarginSpaceBottom { get { return _diagramSpaceMarginBottom; } set { _diagramSpaceMarginBottom = value; } } protected int _diagramSpaceMarginRight = 0;//控制X轴最右端点到图像右边的距离 public int DiagramMarginSpaceRight { get { return _diagramSpaceMarginRight; } set { _diagramSpaceMarginRight = value; } } protected int _diagramSpaceMarginLeft = 0;//X轴起始点到图框的距离 public int DiagramMarginSpaceLeft { get { return _diagramSpaceMarginLeft; } set { _diagramSpaceMarginLeft = value; } } protected int _diagramSpaceMarginTop = 0;//控制Y轴顶点到图框上边界的距离 public int DiagramMarginSpaceTop { get { return _diagramSpaceMarginTop; } set { _diagramSpaceMarginTop = value; } } protected int _diagram_Space = 0;//控制Y轴顶点到图框上边界的距离 public int DiagramSpace { get { return _diagram_Space; } set { _diagram_Space = value; } } protected virtual void CalcDiagramSize(int space_top = 20, int space_left = 100, int space_bottom = 60, int space_right = 100) { this._diagramSpaceMarginBottom = space_bottom; this._diagramSpaceMarginRight = space_right; this._diagramSpaceMarginLeft = space_left; this._diagramSpaceMarginTop = space_top; this._diagramLeftTopPt = new PointF(space_left, space_top); this._diagramLeftBottomPt = new PointF(space_left, _imageTotalHeight - space_bottom); this._diagramRightTopPt = new PointF(_imageTotalWidth - space_left, space_top); this._diagramRightBottomPt = new PointF(_imageTotalWidth - space_left, _imageTotalHeight - space_bottom); this._chartDiagram = new RectangleF(space_left, space_top, _imageTotalWidth - space_left - space_right, _imageTotalHeight - space_top - space_bottom); } #endregion #region 水印 //水印文字 protected string _waterMarkText = "上海义维科技"; public string WaterMarkText { get { return _waterMarkText; } set { _waterMarkText = value; } } public void SetChartWaterText(string WaterText) { this._waterMarkText = WaterText; } private Color _colorWaterMark = Color.FromArgb(70, Color.Blue); public Color WaterMarkTextColor { get { return _colorWaterMark; } set { _colorWaterMark = value; } } protected bool isPrintWaterMark = false;//是否有水印 public bool IsPrintWaterMark { get { return isPrintWaterMark; } set { isPrintWaterMark = value; } } public virtual void DrawWaterMark() { if (!isPrintWaterMark) return; if (string.IsNullOrEmpty(_waterMarkText)) return; using (Font fontText = new Font("Arial", 30, FontStyle.Bold)) { _graphics.DrawString(_waterMarkText, new PointF(_imageTotalWidth / 2, _imageTotalHeight / 4), fontText, _colorWaterMark, StringAlignment.Center, StringAlignment.Center, 30); _graphics.DrawString(_waterMarkText, new PointF(_imageTotalWidth / 2, _imageTotalHeight * 3 / 4), fontText, _colorWaterMark, StringAlignment.Center, StringAlignment.Center, 30); } } // 标题LOGO图片 public string TitleLogoPictureFiltPath { get; set; } public virtual void DrawTitleLogoPicture() { if (string.IsNullOrEmpty(TitleLogoPictureFiltPath)) return; if (!System.IO.File.Exists(TitleLogoPictureFiltPath)) { return; } var img_logo = System.Drawing.Image.FromFile(TitleLogoPictureFiltPath); RectangleF rt1 = new RectangleF( 30, 5, 75, 50); _graphics.DrawImage(img_logo, rt1); } #endregion #region 型号 //产品型号 protected string _productName = null; public string ProductName { get { return _productName; } set { _productName = value; } } //产品型号 protected string _seriesName = null; public string SeriesName { get { return _seriesName; } set { _seriesName = value; } } //产品型号 protected string _catalogName = null; public string CatalogName { get { return _catalogName; } set { _catalogName = value; } } //曲线号 protected string _curveCode = null; public string CurveCode { get { return _curveCode; } set { _curveCode = value; } } #endregion #region 工作点及显示设置 protected Eventech.Model.GroupPoint _waterWorkPoint; public Eventech.Model.GroupPoint WaterWorkPoint { get { return _waterWorkPoint; } set { _waterWorkPoint = value; } } protected Eventech.Model.GroupPoint _viscoWorkPoint = null;//粘度工作点 public Eventech.Model.GroupPoint ViscoWorkPoint { get { return _viscoWorkPoint; } set { _viscoWorkPoint = value; } } protected float _workPointLineWidth = 2f; public float WorkingPointLineWidth { get { return _workPointLineWidth; } set { _workPointLineWidth = value; } } protected Color _workPointLineColor = Color.FromArgb(80, Color.DarkBlue); public Color WorkingPointLineColor { get { return _workPointLineColor; } set { _workPointLineColor = value; } } protected float _workPointTextHeight = 11f; public float WorkingPointTextHeight { get { return _workPointTextHeight; } set { _workPointTextHeight = value; } } protected Color _workPointTextColor = Color.DarkBlue; public Color WorkingPointTextColor { get { return _workPointTextColor; } set { _workPointTextColor = value; } } protected bool _isDispWorkingPointLine = true; public bool IsDispWorkingPointLine { get { return _isDispWorkingPointLine; } set { _isDispWorkingPointLine = value; } } #endregion #region 网格GridLine及Diagram显示 protected Color _backgroundColor = Color.White; public Color BackgroundColor { get { return _backgroundColor; } set { _backgroundColor = value; } } protected System.Drawing.Color _frameTextColor = Color.Black; protected System.Drawing.Color _diagramBorderColor = Color.Black; public System.Drawing.Color DiagramBorderColor { get { return _diagramBorderColor; } set { _diagramBorderColor = value; } } protected Color _gridLineColorQ = Color.FromArgb(100, Color.Black); protected Color _gridLineColorH = Color.FromArgb(100, Color.Black); // protected float _gridLineWidth = 1f; public float GridLineWidth { get { return _gridLineWidth; } set { _gridLineWidth = value; } } //边框宽度 protected float _diagramBorderWidht = 2f; #endregion #region 坐标Axis以及单位 protected Color _axisTickLineColor = Color.Black; public Color AxisTickLineColor { get { return _axisTickLineColor; } set { _axisTickLineColor = value; } } protected float _axisTickLineWidth = 1f; public float AxisTickLineWidth { get { return _axisTickLineWidth; } set { _axisTickLineWidth = value; } } protected float _axisLabelSizeX = 11f; public float AxisLabelSizeX { get { return _axisLabelSizeX; } set { _axisLabelSizeX = value; } } protected float _axisLabelSizeY = 11f; public float AxisLabelSizeY { get { return _axisLabelSizeY; } set { _axisLabelSizeY = value; } } protected float _axisTitleSizeX = 14f; public float AxisTitleTextSizeQ { get { return _axisTitleSizeX; } set { _axisTitleSizeX = value; } } protected float _axisTitleSizeY = 14f; public float AxisTitleTextSizeY { get { return _axisTitleSizeY; } set { _axisTitleSizeY = value; } } //字体 protected string _axisTitleFontName = "Arial"; protected string _axisLabelFontName = "Arial"; protected float _axisMajorTickLength = 8;//长刻度线的长度 protected float _axisMinorTickLength = 4;//短刻度线的长度 //子刻度数 protected int _axisMinorTickNumberX = 4;//X轴上一个大格划分的数量(3:一个格子划分成3个小格子) public int AxisMinorTickNumberX { get { return _axisMinorTickNumberX; } set { _axisMinorTickNumberX = value; } } //子刻度数 protected int _axisMinorTickNumberY = 4;//曲线Y轴上一个大格划分的数量(2:一个格子划分成两个小格子) public int AxisMinorTickNumberY { get { return _axisMinorTickNumberY; } set { _axisMinorTickNumberY = value; } } protected float _axisTitleSpaceToDiagramQ = 38;//Title离图表的距离 public float AxisTitleSpaceToDiagramQ { get { return _axisTitleSpaceToDiagramQ; } set { _axisTitleSpaceToDiagramQ = value; } } protected float _axisLabelSpaceToDiagramQ = 12;//刻度文字离X轴的距离 public float AxisLabelSpaceToDiagramQ { get { return _axisLabelSpaceToDiagramQ; } set { _axisLabelSpaceToDiagramQ = value; } } protected float _axisTitleSpaceToDiagramY = 55;//文字离Y轴的距离 public float AxisTitleSpaceToDiagramY { get { return _axisTitleSpaceToDiagramY; } set { _axisTitleSpaceToDiagramY = value; } } protected float _axisLabelSpaceToDiagramY = 12;//刻度文字离Y轴的距离 public float AxisLabelSpaceToDiagramY { get { return _axisLabelSpaceToDiagramY; } set { _axisLabelSpaceToDiagramY = value; } } public enum eAxisTitlePosiStyle { Center = 0, Top = 1 } public enum eAxisAignmentStyle { Near = 0, Far = 1 } //对齐方式 protected eAxisAignmentStyle _axisAignmentE = eAxisAignmentStyle.Near; public eAxisAignmentStyle AxisAignmentE { get { return _axisAignmentE; } set { _axisAignmentE = value; } } //对齐方式 protected eAxisAignmentStyle _axisAignmentNPSH = eAxisAignmentStyle.Near; public eAxisAignmentStyle AxisAignmentNPSH { get { return _axisAignmentNPSH; } set { _axisAignmentNPSH = value; } } //纵坐标标题的位置 0表示 中间, 1表示刻度的上面 protected eAxisTitlePosiStyle _axisTitlePosiStyleY = eAxisTitlePosiStyle.Center; public eAxisTitlePosiStyle AxisTitlePosiStyleY { get { return _axisTitlePosiStyleY; } set { _axisTitlePosiStyleY = value; } } protected Eventech.Model.UnitQ _unitQ = Eventech.Model.UnitQ.M3H; protected Eventech.Model.UnitH _unitH = Eventech.Model.UnitH.M; protected Eventech.Model.UnitP _unitP = Eventech.Model.UnitP.KW; protected Eventech.Model.UnitH _unitNPSH = Eventech.Model.UnitH.M; //注意即使改了单位,曲线里面的数据没有变,只变化了图表的坐标显示 public Eventech.Model.UnitH UnitH { get { return _unitH; } set { _unitH = value; } } public Eventech.Model.UnitQ UnitQ { get { return _unitQ; } set { _unitQ = value; } } public Eventech.Model.UnitP UnitP { get { return _unitP; } set { _unitP = value; } } public Eventech.Model.UnitH UnitNPSH { get { return _unitNPSH; } set { _unitNPSH = value; } } // 第二刻度 public Eventech.Model.CoordAxis2 SecondAxisQ { get; set; } public Eventech.Model.CoordAxis2 SecondAxisH { get; set; } protected System.Drawing.Color _axisTitleTextColorH = Color.Black; public System.Drawing.Color AxisTitleTextColorH { get { return _axisTitleTextColorH; } set { _axisTitleTextColorH = value; } } protected System.Drawing.Color _axisTitleTextColorQ = Color.Black; public System.Drawing.Color AxisTitleTextColorQ { get { return _axisTitleTextColorQ; } set { _axisTitleTextColorQ = value; } } protected System.Drawing.Color _axisTitleColorQ = Color.Black; public System.Drawing.Color AxisTitleColorQ { get { return _axisTitleColorQ; } set { _axisTitleColorQ = value; } } protected System.Drawing.Color _axisLabelColorH = Color.Black; public System.Drawing.Color AxisLabelColorH { get { return _axisLabelColorH; } set { _axisLabelColorH = value; } } protected System.Drawing.Color _axisTitleColorH = Color.Black; public System.Drawing.Color AxisTitleColorH { get { return _axisTitleColorH; } set { _axisTitleColorH = value; } } protected System.Drawing.Color _axisLabelColorQ = Color.Black; public System.Drawing.Color AxisLabelColorQ { get { return _axisLabelColorQ; } set { _axisLabelColorQ = value; } } #endregion #region 介质 protected TProduct.PumpGraph.Picture.JieZhiFullPara _jieZhiFullPara = null;// TProduct.Model.JieZhiFullPara的 toJsonString public void SetJieZhiInfo(string jieZhiJsonInfo) { if (string.IsNullOrEmpty(jieZhiJsonInfo)) return; try { this._jieZhiFullPara = new JieZhiFullPara(jieZhiJsonInfo); } catch { _jieZhiFullPara = null; } } #endregion #region 语言以及翻译 protected Dictionary _titleDict = new Dictionary(); protected Eventech.Model.eLocalizationType _language = Eventech.Model.eLocalizationType.zhCN; public Eventech.Model.eLocalizationType Language { get { return _language; } set { _language = value; InitialLanguageDict(); } } private void InitialLanguageDict() { if (_language == Eventech.Model.eLocalizationType.ru) { if (_titleDict == null) _titleDict = new Dictionary(); _titleDict["流量"] = "Расход"; _titleDict["扬程"] = "Напор"; _titleDict["效率"] = "КПД"; _titleDict["功率"] = "Мощность вала"; _titleDict["汽蚀余量"] = "NPSHr"; _titleDict["汽蚀"] = "NPSHr"; _titleDict["气蚀"] = "NPSHr"; _titleDict["压力"] = "Pressure"; } else { if (_titleDict == null) _titleDict = new Dictionary(); _titleDict["流量"] = "Flow"; _titleDict["扬程"] = "Head"; _titleDict["效率"] = "Efficiency"; _titleDict["功率"] = "Power"; _titleDict["汽蚀余量"] = "NPSHr"; _titleDict["汽蚀"] = "NPSHr"; _titleDict["压力"] = "Pressure"; } } protected string TranslateString(string cn_content) { if (string.IsNullOrEmpty(cn_content)) return ""; if (_language == Eventech.Model.eLocalizationType.zhCN) { return cn_content; } else { if (_titleDict.ContainsKey(cn_content)) return _titleDict[cn_content]; else return cn_content; } } #endregion //图片选择过滤器 public static string GetPictSelFilter() { //return "图片(*.jpg)|*.jpg|位图(*.bmp)|*.bmp|图片(*.gif)|*.gif|图片(*.png)|*.png"; return @"所有图片格式|*.bmp;*.gif;*.jpeg;*.jpg;*.png|" + "Bitmap图片文件(*.bmp)|*.bmp|" + "Graphics Interchange Format (*.gif)|(*.gif)|" + "JPEG File Interchange Format (*.jpg)|*.jpg;*.jpeg|" + "Portable Network Graphics (*.png)|*.png"; } //是否是图片的后缀 public static bool IsImageSuffix(string suffix) { if (suffix == "gif" || suffix == "jpg" || suffix == "jpeg" || suffix == "png" || suffix == "bmp" || suffix == "tif") return true; else return false; } //是否绘制日期 protected bool _isDrawCreateDay = true; public bool IsDrawCreateDay { get { return _isDrawCreateDay; } set { _isDrawCreateDay = value; } } #region 字体 protected string _defaultFontName = "Arial"; //软件自带字体文件夹名 private string _fontFolder = null; public string FontFolder { get { return _fontFolder; } set { _fontFolder = value; } } //获取系统自带字体(方法二) public List GetSystemFont() { System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection(); List fontList = new List(); foreach (FontFamily ff in ifc.Families) { fontList.Add(ff.Name); } return fontList; } public bool IsExitFont(string FontName) { System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection(); List fontList = new List(); foreach (FontFamily ff in ifc.Families) { if (ff.Name == FontName) { return true; } } return false; } protected void CheckAndAddFont(string FontName, string FontFileName) { if (string.IsNullOrEmpty(_fontFolder)) { this._fontFolder = System.IO.Path.Combine(System.Environment.CurrentDirectory, "font"); } var list = GetSystemFont(); var findFont = (from x in list where x == FontName select x).FirstOrDefault(); if (findFont != null) return; if (!string.IsNullOrEmpty(FontFileName)) AddFont(FontFileName); } public void AddFont(string fontFileName) { if (string.IsNullOrEmpty(_fontFolder)) { this._fontFolder = System.IO.Path.Combine(System.Environment.CurrentDirectory, "font"); } try { var font_file_path = System.IO.Path.Combine(_fontFolder, fontFileName); if (System.IO.File.Exists(font_file_path)) { //读取字体文件 System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection(); pfc.AddFontFile(font_file_path); } } catch { return; } } #endregion protected void DrawPoint_RectStyle(PointF pt, bool isFill, Color color, float size, float curveWidth) { if (pt == null) return; PointF ptRectangle = new PointF(); ptRectangle.X = pt.X - size / 2; ptRectangle.Y = pt.Y - size / 2; if (isFill == true) { using (Brush bush = new SolidBrush(color)) { _graphics.FillRectangle(bush, ptRectangle.X, ptRectangle.Y, size, size); } } else { using (Pen pen = new Pen(color, curveWidth)) { _graphics.DrawRectangle(pen, ptRectangle.X, ptRectangle.Y, size, size); } } } protected void DrawPoint_CircleStyle(PointF pt, bool isFill, Color color, float size, float curveWidth) { if (pt == null) return; PointF ptRectangle = new PointF(); ptRectangle.X = pt.X - size / 2; ptRectangle.Y = pt.Y - size / 2; if (isFill == true) { using (Brush bush = new SolidBrush(color)) { _graphics.FillEllipse(bush, ptRectangle.X, ptRectangle.Y, size, size); } } else { using (Pen pen = new Pen(color, curveWidth)) { _graphics.DrawEllipse(pen, ptRectangle.X, ptRectangle.Y, size, size); } } } protected void DrawPoint_CrossStyle(PointF pt, Color color, float size, float curveWidth) { if (pt == null) return; //左上 PointF pt1 = new PointF(); pt1.X = pt.X - size / 2; pt1.Y = pt.Y - size / 2; //右上 PointF pt2 = new PointF(); pt2.X = pt.X + size / 2; pt2.Y = pt.Y - size / 2; //左下 PointF pt3 = new PointF(); pt3.X = pt.X - size / 2; pt3.Y = pt.Y + size / 2; //右下 PointF pt4 = new PointF(); pt4.X = pt.X + size / 2; pt4.Y = pt.Y + size / 2; using (Pen pen = new Pen(color, curveWidth)) { _graphics.DrawLine(pen, pt, pt1); _graphics.DrawLine(pen, pt, pt2); _graphics.DrawLine(pen, pt, pt3); _graphics.DrawLine(pen, pt, pt4); } } } }