using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.Drawing.Drawing2D;
|
using System.Linq;
|
using System.Text;
|
|
namespace TProduct.PumpGraph.Picture
|
{
|
public class LxpSeriesSimuChart : LxpSeriesChart
|
{
|
private Eventech.Model.LxpSpectrumShapeExList _spectrumShapeList = null;
|
public Eventech.Model.LxpSpectrumShapeExList SimuSpectrumShapeList { get { return _spectrumShapeList; } set { _spectrumShapeList = value; } }
|
|
private Dictionary<long, Color> _specialSpectrumBoudaryColor = null;
|
public Dictionary<long, Color> SpecialSpectrumBoudaryColor
|
{
|
get { return _specialSpectrumBoudaryColor; }
|
set { _specialSpectrumBoudaryColor = value; }
|
}
|
|
private Dictionary<long, Color> _specialSpectrumFillColor = null;
|
public Dictionary<long, Color> SpecialSpectrumFillColor
|
{
|
get { return _specialSpectrumFillColor; }
|
set { _specialSpectrumFillColor = value; }
|
}
|
|
public LxpSeriesSimuChart( )
|
{
|
|
}
|
|
/// <summary>
|
/// 绘制图片
|
/// </summary>
|
/// <param name="imageWidth">图片的宽度</param>
|
/// <param name="imageHeight">图片的高度</param>
|
/// <returns>返回图片</returns>
|
public override Image CreateImage(int imageWidth, int imageHeight)
|
{
|
if (_coordinateParas == null)
|
return null;
|
|
//计算面板位置和尺寸
|
CalcDiagramSize(imageWidth, imageHeight);
|
|
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(this._imageWidth, this._imageHeight);
|
|
_graphics = Graphics.FromImage(bitmap);//句柄
|
|
//绘制背景色
|
_graphics.Clear(_backgroundColor);
|
|
//水印
|
DrawWaterMark(_graphics);
|
|
//绘制网格线
|
DrawDiagram();
|
|
//
|
if (_isDispAxisTitle)
|
{
|
DrawAxisTitleQ();
|
DrawAxisTitleH();
|
}
|
|
|
//绘制曲线
|
DrawSpectrumList();
|
|
|
DrawCurveNames();
|
|
|
DrawDesignPoints(_graphics);
|
|
|
_graphics.Dispose();
|
|
return bitmap;
|
}
|
|
|
#region 绘制型谱
|
protected float _spectrumBoundaryWith = 2f;
|
public float SpectrumBoundaryWith
|
{
|
get { return _spectrumBoundaryWith; }
|
set { _spectrumBoundaryWith = value; }
|
}
|
|
|
protected Color _spectrumBoundaryColor = Color.FromArgb(90, Color.Black);
|
public Color SpectrumBoundaryColor
|
{
|
get { return _spectrumBoundaryColor; }
|
set { _spectrumBoundaryColor = value; }
|
}
|
|
private void DrawSpectrumList()
|
{
|
if (_spectrumShapeList == null)
|
return;
|
using (SolidBrush general_brush = new SolidBrush(Color.FromArgb(80, Color.LavenderBlush)))
|
using (Pen general_pen = new Pen(_spectrumBoundaryColor, _spectrumBoundaryWith))
|
{
|
foreach (var shape in _spectrumShapeList)
|
{
|
if (_specialSpectrumBoudaryColor != null && _specialSpectrumBoudaryColor.ContainsKey(shape.PumpID))
|
{
|
continue;
|
}
|
if (_specialSpectrumFillColor != null && _specialSpectrumFillColor.ContainsKey(shape.PumpID))
|
{
|
continue;
|
}
|
|
GraphicsPath shapePath = null;
|
DrawSpectrumBoundary(general_pen, shape, out shapePath);
|
if (shapePath == null)
|
continue;
|
|
//图形框
|
System.Drawing.Region region = new Region(shapePath);
|
_graphics.FillRegion(general_brush, region);
|
}
|
}
|
|
if (_specialSpectrumBoudaryColor != null)
|
{
|
foreach (var shape in _spectrumShapeList)
|
{
|
if (_specialSpectrumBoudaryColor.ContainsKey(shape.PumpID))
|
{
|
GraphicsPath shapePath = null;
|
using (Pen special_pen = new Pen(_specialSpectrumBoudaryColor[shape.PumpID], _spectrumBoundaryWith))
|
{
|
DrawSpectrumBoundary(special_pen, shape, out shapePath);
|
}
|
if (shapePath == null)
|
continue;
|
|
//图形框
|
if (_specialSpectrumFillColor != null && _specialSpectrumFillColor.ContainsKey(shape.PumpID))
|
{
|
using (SolidBrush special_brush = new SolidBrush(_specialSpectrumFillColor[shape.PumpID]))
|
{
|
System.Drawing.Region region = new Region(shapePath);
|
_graphics.FillRegion(special_brush, region);
|
}
|
}
|
else
|
{
|
using (SolidBrush general_brush = new SolidBrush(Color.FromArgb(40, Color.White)))
|
{
|
System.Drawing.Region region = new Region(shapePath);
|
_graphics.FillRegion(general_brush, region);
|
}
|
|
}
|
}
|
}
|
}
|
|
|
|
if (_specialSpectrumFillColor != null)
|
{
|
foreach (var shape in _spectrumShapeList)
|
{
|
if (_specialSpectrumFillColor.ContainsKey(shape.PumpID))
|
{
|
GraphicsPath shapePath = null;
|
if (_specialSpectrumBoudaryColor != null && _specialSpectrumBoudaryColor.ContainsKey(shape.PumpID))
|
{
|
using (Pen special_pen = new Pen(_specialSpectrumBoudaryColor[shape.PumpID], _spectrumBoundaryWith))
|
{
|
DrawSpectrumBoundary(special_pen, shape, out shapePath);
|
}
|
}
|
else
|
{
|
DrawSpectrumBoundary(null, shape, out shapePath);
|
}
|
if (shapePath == null)
|
continue;
|
|
//图形框
|
using (SolidBrush special_brush = new SolidBrush(_specialSpectrumFillColor[shape.PumpID]))
|
{
|
System.Drawing.Region region = new Region(shapePath);
|
_graphics.FillRegion(special_brush, region);
|
}
|
}
|
}
|
}
|
|
|
|
|
|
#endregion
|
}
|
|
private void DrawSpectrumBoundary(Pen bundary_pen, Eventech.Model.LxpSpectrumShapeEx shapes, out GraphicsPath shapePath)
|
{
|
shapePath = new GraphicsPath();
|
|
#region 图形上边线
|
List<PointF> curvePts = new List<PointF>();
|
|
for (int i = 0; i < shapes.BasePoints.Count; i++)
|
{
|
PointF cPt = new PointF();
|
cPt.X = MapRealToPictQ(shapes.BasePoints[i].X);
|
cPt.Y = MapRealToPictH(shapes.BasePoints[i].Y);
|
if (float.IsInfinity(cPt.X) || float.IsNaN(cPt.X))
|
return;
|
if (float.IsInfinity(cPt.Y) || float.IsNaN(cPt.Y))
|
return;
|
curvePts.Add(cPt);
|
}
|
|
if (curvePts == null || curvePts.Count < 2)
|
return;
|
else if (curvePts.Count > 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawCurve(bundary_pen, curvePts.ToArray());
|
shapePath.AddCurve(curvePts.ToArray());
|
}
|
else if (curvePts.Count == 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawLine(bundary_pen, curvePts[0], curvePts[1]);
|
shapePath.AddLine(curvePts[0], curvePts[1]);
|
}
|
#endregion
|
|
|
#region 图形右边线
|
curvePts.Clear();
|
for (int i = shapes.RightParabolaPoints.Count - 1; i > -1; i--)
|
{
|
PointF cPt = new PointF();
|
cPt.X = MapRealToPictQ(shapes.RightParabolaPoints[i].X);
|
cPt.Y = MapRealToPictH(shapes.RightParabolaPoints[i].Y);
|
|
curvePts.Add(cPt);
|
}
|
|
if (curvePts == null || curvePts.Count < 2)
|
return;
|
else if (curvePts.Count > 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawCurve(bundary_pen, curvePts.ToArray());
|
shapePath.AddCurve(curvePts.ToArray());
|
}
|
else if (curvePts.Count == 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawLine(bundary_pen, curvePts[0], curvePts[1]);
|
shapePath.AddLine(curvePts[0], curvePts[1]);
|
}
|
#endregion
|
|
|
#region 图形下边线
|
curvePts.Clear();
|
for (int i = shapes.SimularPoints.Count - 1; i > -1; i--)
|
{
|
PointF cPt = new PointF();
|
cPt.X = MapRealToPictQ(shapes.SimularPoints[i].X);
|
cPt.Y = MapRealToPictH(shapes.SimularPoints[i].Y);
|
|
curvePts.Add(cPt);
|
}
|
|
if (curvePts == null || curvePts.Count < 2)
|
return;
|
else if (curvePts.Count > 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawCurve(bundary_pen, curvePts.ToArray());
|
shapePath.AddCurve(curvePts.ToArray());
|
}
|
else if (curvePts.Count == 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawLine(bundary_pen, curvePts[0], curvePts[1]);
|
shapePath.AddLine(curvePts[0], curvePts[1]);
|
}
|
#endregion
|
|
|
#region 图形左边线
|
curvePts.Clear();
|
|
for (int i = 0; i < shapes.LeftParabolaPoints.Count; i++)
|
{
|
PointF cPt = new PointF();
|
cPt.X = MapRealToPictQ(shapes.LeftParabolaPoints[i].X);
|
cPt.Y = MapRealToPictH(shapes.LeftParabolaPoints[i].Y);
|
|
curvePts.Add(cPt);
|
}
|
|
if (curvePts == null || curvePts.Count < 2)
|
return;
|
else if (curvePts.Count > 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawCurve(bundary_pen, curvePts.ToArray());
|
shapePath.AddCurve(curvePts.ToArray());
|
}
|
else if (curvePts.Count == 2)
|
{
|
if (bundary_pen != null)
|
_graphics.DrawLine(bundary_pen, curvePts[0], curvePts[1]);
|
shapePath.AddLine(curvePts[0], curvePts[1]);
|
}
|
#endregion
|
}
|
}
|
}
|