using System;
|
using System.Drawing;
|
|
namespace TProduct.PumpGraph.Picture
|
{
|
public partial class LxpFeatChartV1
|
{
|
|
|
#region 画X轴
|
private void DrawAxisX()
|
{
|
DrawAxisLabelX();//画刻度数字
|
|
DrawAxisMajorX();//画主要的刻度短线
|
|
DrawAxisMinorX();//画较短的刻度线
|
|
DrawAxisTitleQ();//画“流量(m³/h)”,
|
|
|
}
|
|
//绘制刻度显示值
|
private void DrawAxisLabelX()
|
{
|
var gridSpaceWidthX = _chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
|
double coorminQ = _coordinateParas.CoordMinQ;//最小显示值
|
double coordspace = _coordinateParas.CoordSpaceQ;
|
|
|
//X坐标显示刻度
|
bool isInteralDisap = true;
|
if (gridSpaceWidthX > 10)
|
{
|
if (this._imageTotalWidth > 900 && coordspace < 1000)
|
{
|
isInteralDisap = false;
|
}
|
}
|
|
StringFormat sf = new StringFormat();
|
sf.Alignment = StringAlignment.Center; //水平居中
|
sf.LineAlignment = StringAlignment.Near; //垂直上对齐
|
|
using (var font = new System.Drawing.Font("Arial", _axisLabelSizeX, System.Drawing.FontStyle.Regular))
|
using (var brush = new System.Drawing.SolidBrush(_axisLabelColorQ))
|
{
|
for (int i = 0; i < _coordinateParas.GridNumberX + 1; i = i + 1)
|
{
|
if (isInteralDisap && i % 2 == 1)
|
{//间隔显示
|
continue;
|
}
|
float space = i * gridSpaceWidthX;
|
double kedu_d = coorminQ + i * coordspace;
|
if (kedu_d <= 0)
|
kedu_d = 0;
|
string kedu_str = "";
|
if (_unitQ == Eventech.Model.UnitQ.M3H)
|
{
|
kedu_str = kedu_d.ToString();
|
}
|
else
|
{
|
kedu_str = Math.Round(Eventech.Common.UnitQHelper.fromM3H(_unitQ, kedu_d), 3).ToString();
|
}
|
_graphics.DrawString(kedu_str, font, brush, new PointF(_chartDiagram.Left + space, _chartDiagram.Bottom + _axisLabelSpaceToDiagramQ), sf);
|
}
|
}
|
|
|
}
|
|
|
//画X轴长刻度线
|
private void DrawAxisMajorX()
|
{
|
using (System.Drawing.Pen pen = new System.Drawing.Pen(AxisTickLineColor, AxisTickLineWidth))
|
{
|
var GridLineWidth_X = _chartDiagram.Width / (_coordinateParas.GridNumberX);//X轴上格子的宽度
|
for (int i = 0; i < _coordinateParas.GridNumberX + 1; i++)
|
{
|
float space = i * GridLineWidth_X;//竖直线之间的间距
|
PointF startPt = new PointF(this._chartDiagram.Left + space, this._chartDiagram.Bottom);
|
PointF endPt = new PointF(this._chartDiagram.Left + space, this._chartDiagram.Bottom + _axisMajorTickLength);
|
_graphics.DrawLine(pen, startPt, endPt);
|
}
|
}
|
|
}
|
|
//画X轴短刻度线
|
private void DrawAxisMinorX()
|
{
|
using (System.Drawing.Pen pen = new System.Drawing.Pen(AxisTickLineColor, AxisTickLineWidth))
|
{
|
var GridLineWidth_X = _chartDiagram.Width / (_coordinateParas.GridNumberX);//X轴上格子的宽度
|
for (int i = 0; i < _coordinateParas.GridNumberX; i++)
|
{
|
float Longspace = i * GridLineWidth_X;//竖直线之间的间距
|
for (int j = 0; j < _axisMinorTickNumberY - 1; j++)
|
{
|
float space = j * GridLineWidth_X / _axisMinorTickNumberY;
|
PointF startPt = new PointF(this._chartDiagram.Left + space + GridLineWidth_X / _axisMinorTickNumberY + Longspace, this._chartDiagram.Bottom);
|
PointF endPt = new PointF(this._chartDiagram.Left + space + GridLineWidth_X / _axisMinorTickNumberY + Longspace, this._chartDiagram.Bottom + _axisMinorTickLength);
|
_graphics.DrawLine(pen, startPt, endPt);
|
}
|
}
|
}
|
}
|
|
//画X坐标说明,流量(m³/h)
|
private void DrawAxisTitleQ()
|
{
|
StringFormat sf = new StringFormat();
|
sf.Alignment = StringAlignment.Center; //水平居中
|
sf.LineAlignment = StringAlignment.Near; //垂直上对齐
|
|
string title = string.Format("流量({0})", Eventech.Common.UnitQHelper.GetEnUnitName(_unitQ));
|
PointF posi = new PointF();
|
posi.X = this._chartDiagram.Left + _chartDiagram.Width / 2;
|
posi.Y = this._chartDiagram.Bottom + _axisTitleSpaceToDiagramQ;
|
using (var font = new System.Drawing.Font("Arial", _axisTitleSizeX, System.Drawing.FontStyle.Regular))
|
using (var brush = new System.Drawing.SolidBrush(_axisTitleColorQ))
|
{
|
_graphics.DrawString(title, font, brush, posi, sf);
|
}
|
}
|
|
#endregion
|
|
|
|
// 网格
|
private void DrawGridLine()
|
{
|
using (System.Drawing.Pen pen = new System.Drawing.Pen(_gridLineColorX, _gridLineWidthX))
|
{
|
for (int i = 0; i < _totalGridNumberY + 1; i++)
|
{
|
float Space = i * this._diagram_Cell_Height;
|
PointF startHPt = new PointF(this._chartDiagram.Left, this._chartDiagram.Bottom - Space);
|
PointF endHPt = new PointF(this._chartDiagram.Right, this._chartDiagram.Bottom - Space);
|
_graphics.DrawLine(pen, startHPt, endHPt);
|
}
|
}
|
|
|
using (System.Drawing.Pen pen = new System.Drawing.Pen(_gridLineColorY, _gridLineWidthY))
|
{
|
var GridLineWidth_X = _chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
|
|
for (int i = 0; i < _coordinateParas.GridNumberX + 1; i++)
|
{
|
float space = i * GridLineWidth_X;//竖直线之间的间距
|
PointF startXgeziPt = new PointF(this._chartDiagram.Left + space, this._chartDiagram.Bottom);
|
PointF endXgeziPt = new PointF(this._chartDiagram.Left + space, this._chartDiagram.Top);
|
_graphics.DrawLine(pen, startXgeziPt, endXgeziPt);
|
|
}
|
}
|
|
|
}
|
}
|
}
|