コード例 #1
0
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

        Graphics g = e.Graphics;

        g.Clear(this.BackColor);

        GraphicsPath gp1 = new GraphicsPath();
        GraphicsPath gp2 = new GraphicsPath();

        gp1.AddPie(0, 0, this.Width, this.Height, 0, 90);
        gp2.AddPie(this.Width / 4f, this.Height / 4f, this.Width / 2f, this.Height / 2f, 0, 90);

        Region rg1 = new System.Drawing.Region(gp1);
        Region rg2 = new System.Drawing.Region(gp2);

        g.DrawPath(Pens.Transparent, gp1);
        g.DrawPath(Pens.Transparent, gp2);

        rg1.Xor(rg2);

        g.FillRegion(Brushes.Black, rg1);

        this.Region = rg1;
    }
コード例 #2
0
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

        Graphics g = e.Graphics;

        g.Clear(this.BackColor);

        GraphicsPath gp1 = new GraphicsPath();
        GraphicsPath gp2 = new GraphicsPath();

        float xInnerPos = -innerRadius / 2f + this.Width / 2f;
        float yInnerPos = -innerRadius / 2f + this.Height / 2f;
        float xOuterPos = -outerRadius / 2f + this.Width / 2f;
        float yOuterPos = -outerRadius / 2f + this.Height / 2f;

        if (innerRadius != 0.0)
        {
            gp1.AddPie(xInnerPos, yInnerPos, innerRadius, innerRadius, startAngle, sweepAngle);
        }
        gp2.AddPie(xOuterPos, yOuterPos, outerRadius, outerRadius, startAngle, sweepAngle);

        Region rg1 = new System.Drawing.Region(gp1);
        Region rg2 = new System.Drawing.Region(gp2);

        g.DrawPath(Pens.Transparent, gp1);
        g.DrawPath(Pens.Transparent, gp2);

        rg1.Xor(rg2);

        g.FillRegion(Brushes.Black, rg1);

        this.Region = rg1;
    }
コード例 #3
0
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Graphics g = e.Graphics;

        g.Clear(this.BackColor);
        Rectangle    rect1 = new Rectangle(20, 20, 200, 200);
        Rectangle    rect2 = new Rectangle(70, 70, 100, 100);
        GraphicsPath gp1   = new GraphicsPath();
        GraphicsPath gp2   = new GraphicsPath();

        gp1.AddPie(rect1, 0, 90);
        gp2.AddPie(rect2, 0, 90);
        Region rg1 = new System.Drawing.Region(gp1);
        Region rg2 = new System.Drawing.Region(gp2);

        g.DrawPath(Pens.Transparent, gp1);
        g.DrawPath(Pens.Transparent, gp2);
        rg1.Xor(rg2);
        g.FillRegion(Brushes.Black, rg1);
        this.Region = rg1;
    }