Sunday, 1 May 2011

Solid Brush In Win Forms:-


Solid Brush In Win Forms:-



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

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            // Create brushes
            SolidBrush redBrush = new SolidBrush(Color.Red);
            SolidBrush blueBrush = new SolidBrush(Color.Blue);
            SolidBrush greenBrush = new SolidBrush(Color.Green);

            //Create a rectangle
            Rectangle rect = new Rectangle(80, 80, 50, 50);

            // Fill ellipses
            g.FillEllipse(redBrush , 40.0F, 40.0F, 130.0F, 130.0F);
            g.FillEllipse(greenBrush , 60, 60, 90, 90);
            g.FillEllipse(blueBrush, 80,80,50,50);

            // Dispose of objects
            blueBrush.Dispose();
            redBrush.Dispose();
            greenBrush.Dispose();
        }
    }
}