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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Drawing2D;
using System.Drawing;
 
namespace TProduct.PumpGraph.Picture
{
    public partial class ZlpFeatChart1 : ZlpFeatChart 
    {
        public override Image CreateImage(int imageWidth, int imageHeight )
        {
            this._imageTotalWidth = imageWidth;
            this._imageTotalHeight = imageHeight;
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(imageWidth, imageHeight);
            _graphics = Graphics.FromImage(bitmap);//句柄
            _graphics.Clear(BackgroundColor);    //绘制背景色
 
            //计算面板位置和尺寸
            CalcDiagramSize(50,  100, 80,  50);
 
 
            DrawAxisX();
 
            DrawAxisY();
 
            DrawAllCurves();
 
            DrawSpecConstantLineH();
 
            //水印
            DrawWaterMark( );
 
            _graphics.Dispose();
 
            return bitmap;
        }
 
        protected override void CalcDiagramSize(int space_top = 20, int space_left = 100, int space_bottom = 60, int space_right = 100)
        {
            base.CalcDiagramSize(space_top, space_left, space_bottom, space_right);
 
            using (SolidBrush brush = new SolidBrush(Color.FromArgb(75, Color.WhiteSmoke)))
            {
                _diagram_Cell_Height = _chartDiagram.Height / (_coordinateParas.AxisLabelH.Count-1);
                var space_heigh = _diagram_Cell_Height;
                var space_width = _chartDiagram.Width / (_coordinateParas.AxisLabelQ.Count - 1);
 
                for (int x = 0; x < _coordinateParas.AxisLabelQ.Count-1; x = x + 1)
                {
                    for (int y = x % 2; y < _coordinateParas.AxisLabelH.Count-1; y = y + 2)
                    {
                        var rect = new RectangleF(_chartDiagram.Left + space_width * x, _chartDiagram.Top + space_heigh * y, space_width, space_heigh);
 
                        System.Drawing.Region region = new Region(rect);
                        _graphics.FillRegion(brush, region);
                    }
                }
            }
        }
    }
}