c#在不同的图层上绘制

时间:2014-01-26 00:14:26

标签: c# charts draw layer

我想制作一张自定义的极地图表。因此,我需要绘制背景和要点。

我试图在不同的面板上绘制背景和点,但问题是,即使我使面板的背景颜色透明,我看不到背景(另一个面板)。

我可以在不同的透明层上绘制任何想法吗?

public Form1()
    {
        InitializeComponent();
        panel2.BackColor = Color.Transparent;
        panel1.Paint += new PaintEventHandler(panel1_Paint);
        panel2.Paint += new PaintEventHandler(panel2_Paint);
    }

    private void panel1_Paint(object sender, PaintEventArgs e)
    {
        var p = sender as Panel;
        var g = e.Graphics;

        g.FillRectangle(new SolidBrush(Color.FromArgb(0, Color.Black)), p.DisplayRectangle);

        Point[] points = new Point[4];

        points[0] = new Point(0, 0);
        points[1] = new Point(0, p.Height);
        points[2] = new Point(p.Width, p.Height);
        points[3] = new Point(p.Width, 0);

        Brush brush = new SolidBrush(Color.DarkGreen);

        g.FillPolygon(brush, points);
    }

    private void panel2_Paint(object sender, PaintEventArgs e)
    {
        var p = sender as Panel;
        var g = e.Graphics;


        g.FillEllipse(myBrush, 10,10,50,50);
    }

0 个答案:

没有答案