Click here to Skip to main content
15,885,435 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Heart shaped Form in C# 2.0

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
6 Apr 2011CPOL 15.8K   2   2
My alternate uses the AddBezier method, and the size of the heart adjusts to the size of the form.private void Form1_Load(object sender, EventArgs e){ using(System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath()) { path.AddBezier(...
My alternate uses the AddBezier method, and the size of the heart adjusts to the size of the form.

C#
private void Form1_Load(object sender, EventArgs e)
{
    using(System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
    {
        path.AddBezier( this.Width >> 1,  
                        this.Height >> 2, 
                        this.Width * 1.25f, 0f, 
                        this.Width, 
                        this.Height * 0.75f, 
                        this.Width >> 1, 
                        this.Height);
        path.AddBezier( this.Width >> 1, 
                        this.Height >> 2, 
                        - this.Width * .25f, 0f,
                        0f, 
                        this.Height * 0.75f, 
                        this.Width >> 1, 
                        this.Height);
        this.Region = new Region(path);
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer DevelopEx
Ukraine Ukraine
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThis also good. But cannot drag. Have 5 Pin
Toniyo Jackson6-Apr-11 21:36
Toniyo Jackson6-Apr-11 21:36 
GeneralRe: Drags are already here: <a href="http://www.codeproject.com/... Pin
intrueder7-Apr-11 14:34
intrueder7-Apr-11 14:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.