Click here to Skip to main content
Licence 
First Posted 31 Jul 2007
Views 16,363
Bookmarked 21 times

Professional Karub Button

By | 31 Jul 2007 | Article
This is a Karub Button,Normal - Highligted and Pressed States

Download KarubButtonDemo.zip - 45.5 KB

Download KarubButtonSourceAndLibrary.zip - 235.3 KB

Screenshot - Image.png

Introduction

This is my Karub Button.It has a few style feature.You can create your button style and you must test it.The button has several color property.These;normal state color,highlighted state color and pressed state color.For instance;

-Normal State Style:

Screenshot - Image4.png

-Highlighted State Style:

Screenshot - custom.png

-And Pressed State Style:

Screenshot - customDown.png

Background

This project language is C#.2005.It included of several property.For example;button icon,icon style,text style,text dimension,layer style,icon and text alignment and much more.But;you can see some property on an article.Look at my property window.

Screenshot - Property.png

-Icon Style:

Highlighted type:

Screenshot - Image4.png

Whitened type:

Screenshot - Image3.png

DarkColor type:

Screenshot - Image2.png

and much more style for this property.

-One sample text style:

Screenshot - Image1.png

you can change text style on this button.Only,you must do select your favourite text style at this project.

-Another Karub Button Style:

Screenshot - fox.png

if you want to change your icon or text location on the button,you must do select of connected with property.You can exchange a lot of special feature at this button control.

Using the code

protected virtual void DrawButton(Graphics g)

{

    Rectangle backRect = new Rectangle();

    Rectangle ShineRect = new Rectangle();

    if (_sinir == BorderLine.Up)//tamam

    {

        backRect = new Rectangle(1, this.Height / 2 - 1, this.Width - 2, this.Height / 2);

        ShineRect = new Rectangle(1, 1, this.Width - 2, this.Height / 2 - 2);//üstteki

    }

    else if (_sinir == BorderLine.Center)//tamam

    {

        backRect = new Rectangle(1, this.Height / 2, this.Width - 2, this.Height / 2 - 1);

        ShineRect = new Rectangle(1, 1, this.Width - 2, this.Height / 2 - 1);//üstteki

    }

    else if (_sinir == BorderLine.Down)//tamam

    {

        backRect = new Rectangle(1, this.Height / 2 + 1, this.Width - 2, this.Height / 2 - 2);

        ShineRect = new Rectangle(1, 1, this.Width - 2, this.Height / 2);//üstteki

    }

    LinearGradientBrush lgb;//dispose edilecek

    int k = (int)butonDurum;//butonun durumunu tutacak

    if (_buttonStyle == Style.CalmCyan)

    {

        lgb = new LinearGradientBrush(backRect, renkDizi[0][k, 1], renkDizi[0][k, 0], LinearGradientMode.Vertical);

        g.FillRectangle(lgb, backRect);

        lgb = new LinearGradientBrush(ShineRect, renkDizi[0][k, 2], renkDizi[0][k, 3], LinearGradientMode.Vertical);

        g.FillRectangle(lgb, ShineRect);

        //Top-Bottom Border draw

        g.DrawLine(new Pen(renkDizi[0][k, 6]), 1, 1, this.Width - 2, 1);

        g.DrawLine(new Pen(renkDizi[0][k, 7]), 1, this.Height - 2, this.Width - 2, this.Height - 2);

        //Left-Right Border draw

        g.DrawLine(new Pen(renkDizi[0][k, 4]), 1, 1, 1, this.Height - 2);

        g.DrawLine(new Pen(renkDizi[0][k, 5]), this.Width - 2, 1, this.Width - 2, this.Height - 3);

        if (uzeri)

            g.DrawRectangle(new Pen(renkCenter[0]), 0, 0, this.Width - 1, this.Height - 1);

    }

    else if (_buttonStyle == Style.DiamondRed)

    {

        lgb = new LinearGradientBrush(backRect, renkDizi[1][k, 1], renkDizi[1][k, 0], LinearGradientMode.Vertical);

        g.FillRectangle(lgb, backRect);

        lgb = new LinearGradientBrush(ShineRect, renkDizi[1][k, 2], renkDizi[1][k, 3], LinearGradientMode.Vertical);

        g.FillRectangle(lgb, ShineRect);

        g.DrawLine(new Pen(renkDizi[1][k, 6]), 1, 1, this.Width - 2, 1);

        g.DrawLine(new Pen(renkDizi[1][k, 7]), 1, this.Height - 2, this.Width - 2, this.Height - 2);

        g.DrawLine(new Pen(renkDizi[1][k, 4]), 1, 1, 1, this.Height - 2);

        g.DrawLine(new Pen(renkDizi[1][k, 5]), this.Width - 2, 1, this.Width - 2, this.Height - 3);

        if (uzeri)

            g.DrawRectangle(new Pen(renkCenter[1]), 0, 0, this.Width - 1, this.Height - 1);

    }

    else

    {

        lgb = new LinearGradientBrush(backRect, renkDizi[2][k, 1], renkDizi[2][k, 0], LinearGradientMode.Vertical);

        g.FillRectangle(lgb, backRect);

        lgb = new LinearGradientBrush(ShineRect, renkDizi[2][k, 2], renkDizi[2][k, 3], LinearGradientMode.Vertical);

        g.FillRectangle(lgb, ShineRect);

        g.DrawLine(new Pen(renkDizi[2][k, 6]), 1, 1, this.Width - 2, 1);

        g.DrawLine(new Pen(renkDizi[2][k, 7]), 1, this.Height - 2, this.Width - 2, this.Height - 2);

        g.DrawLine(new Pen(renkDizi[2][k, 4]), 1, 1, 1, this.Height - 2);

        g.DrawLine(new Pen(renkDizi[2][k, 5]), this.Width - 2, 1, this.Width - 2, this.Height - 3);

        if (uzeri)

            g.DrawRectangle(new Pen(renkCenter[2]), 0, 0, this.Width - 1, this.Height - 1);

    }

    if (_Layer != LayerStatus.None)

    {

        int x = 0, y = 0;

        switch (_Layer)

        {

             case LayerStatus.Bottom:

                y += Size.Height / 2 - 1;

                break;

            case LayerStatus.BottomLeft:

                x -= Size.Width / 2;

                y += Size.Height / 2 - 1;

                break;

            case LayerStatus.BottomRight:

                x += Size.Width / 2;

                y += Size.Height / 2 - 1;

                break;

            case LayerStatus.Left:

                x -= Size.Width / 2;

                break;

            case LayerStatus.Right:

                x += Size.Width / 2;

                break;

            case LayerStatus.Top:

                y -= Size.Height / 2 + 1;

                break;

            case LayerStatus.TopLeft:

                x -= Size.Width / 2;

                y -= Size.Height / 2 + 1;

                break;

            case LayerStatus.TopRight:

                x += Size.Width / 2;

                y -= Size.Height / 2 + 1;

                break;

        }

    Point startPoint = new Point(x - _GlowLength, y - _GlowLength);

    GraphicsPath pth = new GraphicsPath();

    pth.AddRectangle(new Rectangle(startPoint, new Size(Size.Width + _GlowLength * 2, Size.Height + _GlowLength * 2)));

    PathGradientBrush pgb = new PathGradientBrush(pth);

    pgb.CenterColor = _layerCenterColor;

    pgb.SurroundColors = new Color[] { Color.Transparent };

    pgb.FocusScales = new PointF(0.7F, 0.7F);

    ColorBlend cb = new ColorBlend(2);

    cb.Positions[0] = 0.0F;

    cb.Positions[1] = 1.0F;

    cb.Colors = new Color[] { Color.Transparent, Color.FromArgb(150, 93, 198, 242) };

    pgb.InterpolationColors = cb;

    pgb.FocusScales = new PointF(0.7F, 0.7F);

    g.FillPath(pgb, pth);//alan dolduruyoruz.

    lgb.Dispose();

    pgb.Dispose();

    pth.Dispose();

    }

}

Points of Interest

-Database application (SQL SERVER 2000 - 2005) and a little bit Oracle Database.

-Win32 application,use with c and c# programming language.

-Windows custom controls.

-Developing base of Intranet and Internet applications.

History - Burak Özdiken

I am .Net programmer.I have been developing software application and project since 1998.My first programming language is Visual Basic 4.0 - 5.0.At now,My programming language is c# and vb.net.Also,I am developing enterprise application for company.

You can send your message from your e-mail.

My e-mail adresses:

burakozdiken@mynet.com and burakozdiken@ttnet.net.tr

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

burak299

Software Developer (Senior)
Aselsan
Turkey Turkey

Member

Since 1998...
 
MCPD - Enterprise Application Developer
  • Windows
  • Web
  • Distributed


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberWilliam Winner6:14 12 Feb '10  
GeneralNice control, but... PinmemberStevie12:29 31 Jul '07  
GeneralRe: Nice control, but... Pinmemberburak29913:43 31 Jul '07  
GeneralRe: Nice control, but... Pinmemberp_a_k20:19 31 Jul '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 31 Jul 2007
Article Copyright 2007 by burak299
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid