Wednesday 20 April 2011

Change Form Shape Using C#.net


Change Form Shape Using C#.net




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 WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        int i;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            GraphicsPath gp = new GraphicsPath();
            gp.AddEllipse(100,100,500,500);
           
            this.BackColor = Color.Brown;  

            Region reg = new Region(gp);
            this.Region=reg;

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            GraphicsPath gp = new GraphicsPath();
            if (i % 3 == 0)
            {
                gp.AddEllipse(100, 100, 500,500);
                this.BackColor = Color.Red;
            }
            else
            {
                gp.AddEllipse(100, 100, 500, 500);
                this.BackColor = Color.Blue;
            }
            i = i + 1;
            Region reg = new Region(gp);
            this.Region = reg; 
        }
    }
}

No comments:

Post a Comment