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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
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
        }
    }
}