tx
2025-04-22 e0b138b3e057de6f57021e6c8963868f5c5acc5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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);
 
                }
            }
 
 
        }
    }
}