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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using Eventech.Utils.Images;
 
namespace TProduct.PumpGraph.Picture
{
    public partial class LxpSeriesChart
    {
        #region 坐标
        protected Eventech.Model.QhCoordinateParas _coordinateParas = null;
        public void SetCoordinate(string strChartCoord)
        {
            SetCoordinate(Eventech.Model.QhCoordinateParas.ToParameter(strChartCoord));
        }
        public void SetCoordinate(Eventech.Model.QhCoordinateParas coordinateParas)
        {
            this._coordinateParas = coordinateParas;
        }
        #endregion
 
 
        #region 显示设置
 
        protected bool _isDispAxisTitle = true;
 
        //刻度线颜色
        protected Color _axisTitleLineColor = Color.FromArgb(120, Color.Black);
 
        //网格线Y颜色
        protected Color _gridLineColor = Color.FromArgb(60, Color.Black);
        public Color GridLineColor
        {
            get { return _gridLineColor; }
            set { _gridLineColor = value; }
        }
 
        /// <summary>
        /// 
        /// </summary>
        protected float _gridLineWidth = 1f;
        public float GridLineWidthY
        {
            get { return _gridLineWidth; }
            set { _gridLineWidth = value; }
        }
 
        /// <summary>
        /// 
        /// </summary>
        protected Color _axisLabelColor = Color.Black;
        public Color AxisLabelColor
        {
            get { return _axisLabelColor; }
            set { _axisLabelColor = value; }
        }
 
 
 
        /// <summary>
        /// 长刻度线的长度
        /// </summary>
        public float AxisMajorTickLength
        {
            get { return _axisMajorTickLength; }
            set { _axisMajorTickLength = value; }
        }
        protected float _axisMajorTickLength = 10;
 
        /// <summary>
        /// 
        /// </summary>
        private float _axisLabelSizeQ = 12f;
        public float AxisLabelSizeQ
        {
            get { return _axisLabelSizeQ; }
            set { _axisLabelSizeQ = value; }
        }
 
        /// <summary>
        /// 
        /// </summary>
        private float _axisLabelSize = 12f;
        public float AxisLabelSizeH
        {
            get { return _axisLabelSize; }
            set { _axisLabelSize = value; }
        }
 
 
        protected float _axisTitleDistanceH = 55;//文字离X轴的距离
        protected float _axisTitleDistanceQ = 75;//文字离Y轴的距离
 
        protected float _axisLabelDistanceH = 10;//文字离X轴的距离
        protected float _axisLabelDistanceQ = 35;//文字离Y轴的距离
 
        private float _axisTitleTextSizeQ = 16f;
        private float _axisTitleTextSizeH = 16f;
 
        private Color _axisTitleTextColorQ = Color.Black;
        private Color _axisTitleTextColorH = Color.Black;
 
 
 
        #endregion
 
 
        protected void DrawDiagram()
        {
            DrawGridLineQ();
 
            DrawGridLineH();
 
            using (System.Drawing.Pen pen = new System.Drawing.Pen(_axisTitleLineColor, 1.5f))
                _graphics.DrawRectangle(pen, this._chartDiagramSize.X, _chartDiagramSize.Y, _chartDiagramSize.Width, _chartDiagramSize.Height);
        }
 
 
        /// <summary>
        /// 绘制流量曲线网格(竖直)
        /// </summary>
        protected void DrawGridLineQ()
        {
            using (var brush = new System.Drawing.SolidBrush(_axisLabelColor))
            using (var font = new System.Drawing.Font("Arial", _axisLabelSize, System.Drawing.FontStyle.Regular))
            using (var grid_pen = new System.Drawing.Pen(_gridLineColor, _gridLineWidth))
            using (var tick_pen = new System.Drawing.Pen(_axisTitleLineColor, 1.5f))
            {
                float[] dashValues = { 7, 3 };
                grid_pen.DashPattern = dashValues;
                for (int i = 0; i < _coordinateParas.AxisLabelQ.Count; i++)
                {
                    double Q = _coordinateParas.AxisLabelQ[i];
                    string content = Math.Round(Eventech.Common.UnitQHelper.fromM3H(_coordinateParas.UnitQ, Q), 2).ToString();
 
                    float px = MapRealToPictQ(Q);  
                    if (float.IsNaN(px)){ //do 
                        return;
                    } 
                    PointF pt0 = new PointF();
                    pt0.X = px;
                    pt0.Y = _chartDiagramSize.Bottom ;
 
                    PointF pt1 = new PointF();
                    pt1.X = px;
                    pt1.Y = _chartDiagramSize.Top;
 
                    PointF pt2 = new PointF();
                    pt2.X = px;
                    pt2.Y = _chartDiagramSize.Bottom + _axisMajorTickLength;
 
                    _graphics.DrawLine(grid_pen, pt0, pt1);
                    _graphics.DrawLine(tick_pen, pt0, pt2);
 
                    //刻度值       
                    PointF pt = new PointF();
                    pt.X = pt1.X;
                    pt.Y = _chartDiagramSize.Bottom + _axisLabelDistanceQ;
 
                    _graphics.DrawString(content, pt, font, _axisLabelColor, StringAlignment.Center, StringAlignment.Far, 0);
                }
            }
        }
 
 
        /// <summary>
        /// 绘制扬程曲线网格(水平)
        /// </summary>
        protected void DrawGridLineH()
        {
            using (var brush = new System.Drawing.SolidBrush(_axisLabelColor))
            using (var font = new System.Drawing.Font("Arial", _axisLabelSize, System.Drawing.FontStyle.Regular))
            using (var grid_pen = new System.Drawing.Pen(_gridLineColor, _gridLineWidth))
            using (var tick_pen = new System.Drawing.Pen(_axisTitleLineColor,1.5f))
            {
                float[] dashValues = { 7, 3 };
                grid_pen.DashPattern = dashValues;
 
                for (int i = 0; i < _coordinateParas.AxisLabelH.Count; i++)
                {
                    double h = _coordinateParas.AxisLabelH[i];
                    string content = Math.Round(Eventech.Common.UnitHHelper.fromM(_coordinateParas.UnitH, h), 2).ToString();
 
                    var py = MapRealToPictH(h);
 
                    PointF pt0 = new PointF();
                    pt0.X = _chartDiagramSize.Left  ;
                    pt0.Y = py;
 
                    PointF pt1 = new PointF();
                    pt1.X = _chartDiagramSize.Left - _axisMajorTickLength;
                    pt1.Y = py;
 
                    PointF pt2 = new PointF();
                    pt2.X = _chartDiagramSize.Right;
                    pt2.Y = py;
 
                    _graphics.DrawLine(grid_pen, pt0, pt2);
                    _graphics.DrawLine(tick_pen, pt0, pt1);
 
                    //刻度值       
                    PointF pt = new PointF();
                    pt.X = _chartDiagramSize.Left - _axisLabelDistanceH;
                    pt.Y = pt1.Y;
                    _graphics.DrawString(content, pt, font, _axisLabelColor, StringAlignment.Far, StringAlignment.Center, 0);
                }
            }
        }
 
 
        /// <summary>
        /// 画X坐标说明 
        /// </summary>
        protected void DrawAxisTitleQ()
        {
            string title = string.Format("{0}({1})", "Q", Eventech.Common.UnitQHelper.GetEnUnitName(this._coordinateParas.UnitQ));
            PointF pt = new PointF();
            pt.X = _chartDiagramSize.X + _chartDiagramSize.Width / 2 - 5;
            pt.Y = _chartDiagramSize.Bottom + _axisTitleDistanceQ;
 
            using (var font = new System.Drawing.Font("Arial", _axisTitleTextSizeQ, System.Drawing.FontStyle.Regular))
            {
                _graphics.DrawString(title, pt, font, _axisTitleTextColorQ, StringAlignment.Near, StringAlignment.Far, 0);
            }
        }
 
 
 
 
        /// <summary>
        /// /
        /// </summary>
        protected void DrawAxisTitleH()
        {
            string title = string.Format("{0}({1})", "H", Eventech.Common.UnitHHelper.GetEnUnitName(this._coordinateParas.UnitH));
            PointF pt = new PointF();
            pt.X = (float)(_chartDiagramSize.X - _axisTitleDistanceH);
            pt.Y = _chartDiagramSize.Y + _chartDiagramSize.Height / 2;
 
            using (var font = new Font("Arial", _axisTitleTextSizeH))
            {
                _graphics.DrawString(title, pt, font, _axisTitleTextColorQ, StringAlignment.Far, StringAlignment.Center, -90);
            }
            _graphics.ResetTransform();
        }
 
 
 
    }
}