rendered paste bodyusing System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Clipper
{
public class MainForm : System.Windows.Forms.Form
{
public MainForm()
{
InitializeComponent();
TestControl tc = new TestControl();
tc.Dock = DockStyle.Fill;
Controls.Add(tc);
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
private void InitializeComponent() {
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(752, 493);
this.Name = "MainForm";
this.Text = "MainForm";
}
#endregion
}
public class TestControl : Control {
const int count = 180;
Rectangle[] rects = new Rectangle[count];
public TestControl ()
{
int x_pos = 10;
int y_pos = 10;
for (int i = 0; i < count; i++) {
rects[i] = new Rectangle(x_pos, y_pos, 30, 30);
y_pos += 40;
if (y_pos > 450) {
y_pos = 10;
x_pos += 40;
}
}
SetStyle (ControlStyles.DoubleBuffer, true);
}
protected override void OnPaint(PaintEventArgs e)
{
Console.WriteLine("ClipRectangle: " + e.ClipRectangle);
int counter = 0;
for (int i = 0; i < count; i++) {
if (e.ClipRectangle.IntersectsWith(rects[i])) {
counter ++;
LinearGradientBrush lgbr =
new LinearGradientBrush(new Point(rects[i].X, rects[i].Y),
new Point(rects[i].X, rects[i].Bottom),
Color.Blue, Color.Black);
e.Graphics.FillRectangle(lgbr, rects[i]);
}
}
Console.WriteLine("{0} gradients were drawn", counter);
}
}
}