![]() |
Desktop Development »
Miscellaneous »
General
Beginner
An Aqua Button Control Written in C# for .NetBy Rad1calI have written a number of applications and always been a little disappointed at how drab they look using the standard VS controls. I had been looking for an easy way for brightening up these apps and in the end resorted to writing my own button control. |
C# 1.0, C# 2.0.NET 1.0, .NET 1.1, .NET 2.0, Win2K, WinXP, Win2003, TabletPCVS.NET2003, VS2005, Dev
|
||||||||||
|
Advanced Search |
|
|
|
||||||||||||||||

I have written a number of applications and always been a little disappointed at how drab they look using the standard VS controls. I had been looking for an easy way for brightening up these apps and in the end resorted to writing my own button control based on the "The Aqualizer Strikes Back!" work found on the Code Project site.
Using this, control bitmaps are created "on the fly" according to the attributes of the control. Colour, Height, Width, Font Size and Text. The slow rendering speed of the graphics is negated by using cached bitmaps. For each button two Png files are produced. One is the colour of the button and the other which is clear and is used when the mouse hovers over the button and when the button is disabled. Using this control you gain the advantages of both options - flexible image generation and - speed.
ButtonText, ButtonColour, FontSize and TextColour to set the text and colours of the button.ButtonText, ButtonColour, FontSize and TextColour are used.[Description("The text visible on the control. Use \\n for line breaks")] [DefaultValue("Not Set") [Browsable()> public string ButtonText { set { base.Text="not set"; initialise(); m_text=value; redrawButton(); } get { return m_text; } }
CreateImage() method to produce alternative designs (e.g. diamonds, emeralds etc). The helper classes for the graphics are are provided for doing all of this. You may have to make some of them public.CreateImage() be sure to cache the images in the same way as the base class or performance will suffer. private void createBaseImages() { /* Call the overrideable CreateImage routines to get the bitmaps/images */ m_image=CreateImage( m_buttonColour ); m_nofocusImage=CreateImage( Color.White ); this.Image = m_image; }
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 18 Oct 2006 Editor: |
Copyright 2006 by Rad1cal Everything else Copyright © CodeProject, 1999-2009 Web16 | Advertise on the Code Project |