Sunday 1 May 2011

Path Gradient Brush in Win Forms:-



Path Gradient 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 WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

       
        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            this.Refresh();

            Graphics g;
            g = this.CreateGraphics();

            Point[] pt = { new Point(0, 0), new Point(0, 60), new Point(80, 60), new Point(80, 0), new Point(0, 40) };

            Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);

            PathGradientBrush pgb = new PathGradientBrush(pt);

            pgb.WrapMode = WrapMode.TileFlipXY;
            pgb.CenterColor = Color.Red;
            pgb.SurroundColors = new Color[] { Color.Red, Color.Blue, Color.Chocolate, Color.Crimson, Color.Purple };
            this.Text = "Path Gradient Brush Examples";
            g.FillRectangle(pgb, rect);

            g.Dispose();
            pgb.Dispose();
        }
    }
}

No comments:

Post a Comment