Write info about the clipping rectangle to the console window : Clip « 2D Graphics « C# / C Sharp






Write info about the clipping rectangle to the console window

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form {

    protected override void OnPaint(PaintEventArgs e) {
    Graphics g = e.Graphics;
    g.FillRectangle(Brushes.White, this.ClientRectangle);

    String s = "text";
    Font f = new Font("Times New Roman", 12);
    SizeF sf = g.MeasureString(s, f, 400);
    RectangleF rf = new RectangleF(10, 10, sf.Width, sf.Height);

    g.DrawString(s, f, Brushes.Black, rf);
    f.Dispose();
    Console.WriteLine("Clipping region painted: " + e.ClipRectangle);
    }
    public static void Main() {
        Application.Run(new Form1());
    }
}

 








Related examples in the same category

1.draw something onto the drawing surface (with the clipping region applied)
2.Clipping Combinations
3.Clip DrawClip Draw
4.ClippingClipping