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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Drawing2D;
using System.Drawing;
using Eventech.Utils.Images;
 
namespace TProduct.PumpGraph.Picture
{
    public partial class LxpMultiSpeedChart3
    {
        private void DrawAxisX()
        {
            //DrawAxisMinorX_Up(this._chartDiagramQH);//画较短的刻度线
            //DrawAxisTitleQ_Up(this._chartDiagramQH);
            //DrawAxisMajorX_Up(this._chartDiagramQH);//画主要的刻度短线
            //DrawAxisLabelX_Up(this._chartDiagramQH);//画刻度数字
 
            DrawAxisLabelX_Bottom(this._chartDiagramQH);//画刻度数字
            DrawAxisMajorX_Bottom(this._chartDiagramQH);//画主要的刻度短线
            DrawAxisMinorX_Bottom(this._chartDiagramQH);//画较短的刻度线
            //DrawAxisTitleQ_Bottom(this._chartDiagramQH);//画“流量(m³/h)”
 
            if (!_chartDiagramNPSH.IsEmpty)
            {
                DrawAxisLabelX_Bottom(this._chartDiagramNPSH);//画刻度数字
                DrawAxisMajorX_Bottom(this._chartDiagramNPSH);//画主要的刻度短线
                DrawAxisMinorX_Bottom(this._chartDiagramNPSH);//画较短的刻度线
               // DrawAxisTitleQ_Bottom(this._chartDiagramNPSH);//画“流量(m³/h)”
            }
 
            if (_isDispCurveQE)
            {
                DrawAxisLabelX_Bottom(this._chartDiagramQE);//画刻度数字
                DrawAxisMajorX_Bottom(this._chartDiagramQE);//画主要的刻度短线
                DrawAxisMinorX_Bottom(this._chartDiagramQE);//画较短的刻度线
                //DrawAxisTitleQ_Bottom(this._chartDiagramQE);//画“流量(m³/h)”
            }
 
 
            if (_isDispCurveQP)
            {
                DrawAxisLabelX_Bottom(this._chartDiagramQP);//画刻度数字
                DrawAxisMajorX_Bottom(this._chartDiagramQP);//画主要的刻度短线
                DrawAxisMinorX_Bottom(this._chartDiagramQP);//画较短的刻度线
                DrawAxisTitleQ_Bottom(this._chartDiagramQP);//画“流量(m³/h)”
            }
 
 
 
 
        }
 
        private bool IsInteralDispX(RectangleF chartDiagram)
        {
            double coordspace = _coordinateParas.CoordSpaceQ;
            double coorminQ = _coordinateParas.CoordMinQ;//最小显示值
            double coormax = (_coordinateParas.GridNumberX + 1) * coordspace + coorminQ;//刻度显示最大值
            var gridSpaceWidthX = chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
 
            if (gridSpaceWidthX > coormax.ToString().Length * _axisLabelSizeX * 1.1)
            {
                return false;
            }
            else
            {
                return true;
            }
 
        }
 
        //绘制刻度显示值(下部)
        private void DrawAxisLabelX_Bottom(RectangleF chartDiagram)
        {
            var gridSpaceWidthX = chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
            double coorminQ = _coordinateParas.CoordMinQ;//最小显示值
            double coordspace = _coordinateParas.CoordSpaceQ;
            double coormax = (_coordinateParas.GridNumberX + 1) * coordspace + coorminQ;//刻度显示最大值
 
 
            //X坐标显示刻度
            bool isInteralDisap = IsInteralDispX(chartDiagram);
 
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center; //水平居中
            sf.LineAlignment = StringAlignment.Near; //垂直上对齐
 
            using (var font = new System.Drawing.Font("Arial", _axisLabelSizeX, System.Drawing.FontStyle.Bold))
            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);
                }
            }
        }
 
        //绘制刻度显示值(上部)
        private void DrawAxisLabelX_Up(RectangleF chartDiagram)
        {
            var gridSpaceWidthX = chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
            double coorminQ = _coordinateParas.CoordMinQ;//最小显示值
            double coordspace = _coordinateParas.CoordSpaceQ;
            double coormax = (_coordinateParas.GridNumberX + 1) * coordspace + coorminQ;//刻度显示最大值
 
 
            //X坐标显示刻度
            bool isInteralDisap = IsInteralDispX(chartDiagram);
 
 
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center; //水平居中
            sf.LineAlignment = StringAlignment.Far; //垂直上对齐
 
            using (var font = new System.Drawing.Font("Arial", _axisLabelSizeX, System.Drawing.FontStyle.Bold))
            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.Top - _axisLabelSpaceToDiagramQ - 1), sf);
                }
            }
        }
 
        //画X轴长刻度线
        private void DrawAxisMajorX_Bottom(RectangleF chartDiagram)
        {
            using (System.Drawing.Pen pen = new System.Drawing.Pen(AxisTickLineColor, AxisTickLineWidth))
            {
                for (int i = 0; i <= _coordinateParas.GridNumberX; i++)
                {
                    float space = i * chartDiagram.Width / _coordinateParas.GridNumberX;//竖直线之间的间距
                    PointF startPt = new PointF(chartDiagram.Left + space, chartDiagram.Bottom);
                    PointF endPt = new PointF(chartDiagram.Left + space, chartDiagram.Bottom + _axisMajorTickLength);
                    _graphics.DrawLine(pen, startPt, endPt);
                }
            }
        }
 
        private void DrawAxisMajorX_Up(RectangleF chartDiagram)
        {
            using (System.Drawing.Pen pen = new System.Drawing.Pen(AxisTickLineColor, AxisTickLineWidth))
            {
                for (int i = 0; i <= _coordinateParas.GridNumberX; i++)
                {
                    float space = i * chartDiagram.Width / _coordinateParas.GridNumberX;//竖直线之间的间距
                    PointF startPt = new PointF(chartDiagram.Left + space, chartDiagram.Top);
                    PointF endPt = new PointF(chartDiagram.Left + space, chartDiagram.Top - _axisMajorTickLength);
                    _graphics.DrawLine(pen, startPt, endPt);
                }
            }
        }
 
 
        //画X轴短刻度线
        private void DrawAxisMinorX_Bottom(RectangleF chartDiagram)
        {
            var gridSpaceWidthX = chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
            using (System.Drawing.Pen pen = new System.Drawing.Pen(AxisTickLineColor, AxisTickLineWidth))
            {
                for (int i = 0; i < _coordinateParas.GridNumberX; i++)
                {
                    float space_tick = i * gridSpaceWidthX;//竖直线之间的间距
                    for (int j = 0; j < _axisMinorTickNumberX - 1; j++)
                    {
                        float space = j * gridSpaceWidthX / _axisMinorTickNumberX;
                        PointF startPt = new PointF(chartDiagram.Left + space + gridSpaceWidthX / _axisMinorTickNumberX + space_tick, chartDiagram.Bottom);
                        PointF endPt = new PointF(chartDiagram.Left + space + gridSpaceWidthX / _axisMinorTickNumberX + space_tick, chartDiagram.Bottom + _axisMinorTickLength);
                        _graphics.DrawLine(pen, startPt, endPt);
                    }
                }
            }
        }
        private void DrawAxisMinorX_Up(RectangleF chartDiagram)
        {
            var gridSpaceWidthX = chartDiagram.Width / _coordinateParas.GridNumberX;//X轴上格子的宽度
            using (System.Drawing.Pen pen = new System.Drawing.Pen(AxisTickLineColor, AxisTickLineWidth))
            {
                for (int i = 0; i < _coordinateParas.GridNumberX; i++)
                {
                    float space_tick = i * gridSpaceWidthX;//竖直线之间的间距
                    for (int j = 0; j < _axisMinorTickNumberX - 1; j++)
                    {
                        float space = j * gridSpaceWidthX / _axisMinorTickNumberX;
                        PointF startPt = new PointF(chartDiagram.Left + space + gridSpaceWidthX / _axisMinorTickNumberX + space_tick, chartDiagram.Top);
                        PointF endPt = new PointF(chartDiagram.Left + space + gridSpaceWidthX / _axisMinorTickNumberX + space_tick, chartDiagram.Top - _axisMinorTickLength);
                        _graphics.DrawLine(pen, startPt, endPt);
                    }
                }
            }
        }
 
 
        //画X坐标说明,流量(m³/h)
        private void DrawAxisTitleQ_Bottom(RectangleF chartDiagram)
        {
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center; //水平居中
            sf.LineAlignment = StringAlignment.Near; //垂直上对齐
 
            string title = string.Format("{0}({1})", TranslateString("流量"), Eventech.Common.UnitQHelper.GetEnUnitName(_unitQ));
            PointF posi = new PointF();
            posi.X = (chartDiagram.Left + _diagramRightBottomPt.X) / 2;
            posi.Y = chartDiagram.Bottom + _axisTitleSpaceToDiagramQ;
            using (var font = new System.Drawing.Font(GetAxisTitleFontName(), _axisTitleTextSizeQ, System.Drawing.FontStyle.Bold))
            using (var brush = new System.Drawing.SolidBrush(AxisTitleTextColorQ))
            {
                _graphics.DrawString(title, font, brush, posi, sf);
            }
        }
 
        private void DrawAxisTitleQ_Up(RectangleF chartDiagram)
        {
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center; //水平居中
            sf.LineAlignment = StringAlignment.Far; //垂直上对齐
      
 
            string title = string.Format("{0}({1})", TranslateString("流量"), Eventech.Common.UnitQHelper.GetEnUnitName(_unitQ));
            PointF posi = new PointF();
            posi.X = (chartDiagram.Left + _diagramRightBottomPt.X) / 2;
            posi.Y = chartDiagram.Top - _axisTitleSpaceToDiagramQ ;
            using (var font = new System.Drawing.Font(GetAxisTitleFontName(), _axisTitleTextSizeQ, System.Drawing.FontStyle.Bold))
            using (var brush = new System.Drawing.SolidBrush(AxisTitleTextColorQ))
            {
                _graphics.DrawString(title, font, brush, posi, sf);
            }
        }
 
 
        protected string GetAxisTitleFontName()
        {
            if (_language == Eventech.Model.eLocalizationType.zhCN)
            {
                return "宋体";
            }
            else
            {
                return "Arial";
            }
        }
    }
}