Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Existing Project Development (http://www.programmingforums.org/forum51.html)
-   -   Vista Elements Button (http://www.programmingforums.org/showthread.php?t=14380)

Alias Nov 9th, 2007 8:27 AM

Vista Elements Button
 
2 Attachment(s)
I posted this at another forum I frequent, well, two others all-in-all throughout development, it is at a stage that I am happy to let it go a little more public and thought somone may appreciate it here...

Vista Elements Button

Here we have a shaped button, modelled originally to allow developers applications to look and feel like they were written for Vista, particularly in the circumstance of user account handling where an interface is needed, hence the name. There were a few members of different forums I visit that took part in a small testing phase in order for me to gain feedback in a number of areas when the control and its whole concept were still in this state – thank you for that, btw – but the control has had a few updates, amendments and additions since then.

The first major mentionable improvement is memory consumption. I must admit it was not the first thing on my mind while writing the control and it went unnoticed by any of the testers if I can recall without reference – but it was an issue, as when I did turn to looking at the memory I found I was using a little too much for a button, not being able to recall the odds. With a little perseverance however, I cut it down so that when hosted on a form there is an average working set of 6,176 KB, considering the window consumes a chunk of this averaging at 5,308 KB I am now a little more relieved.

Secondly, and also legitimately concerning, was an issue involved when resizing the control. The controls design is essentially only effective when the layout has an equal ratio, for this reason the decision was made to impose it.

Thirdly, more shapes have been added, meaning you can now select from the following shapes:

* VSquare
* Circle
* Half Oval
* Star*

*The star shape still has some more noticeable room for improvement than other shapes, though still usable in many scenarios.

Lastly, for now, the overlay/shine effect has been improved in terms of the way it is drawn for most shapes, the star being the odd one out and this aspect being one of the above referenced issues. Another note relevant here is that there is now a property to indicate which way the overlay/shine should be drawn, with either a curved or straight centre line.

Platform of the button

As you have probably gathered from above, the control utilises the .NET Framework 2.0 and was written in 100% managed C# using GDI+.

Use of the button

The button control is contained within the VistaElements.dll and must be referenced; here’s how to go about referencing it in a .NET application, note there are two ways:

At compile time:
When about to compile add the following line to the command...
:

/reference:VistaElements.dll

At design time when using an IDE, Visual Studio in particular:

1. Open your project/solution.
2. In the Solution Explorer right click the project and choose Add Reference from the menu displayed.
3. Select the Browse tab then locate the VistaElements.dll, select it and click Ok.
4. In order for the control to show up in the toolbox you may need to take the additional steps of right-clicking it (the toolbox that is) and selecting Choose Items from the menu, locating the control from the list and checking it for availability.

Now that it is referenced, or will be at time of compilation, you can proceed to expose it from within Visual Studio using the designer, all properties can be set from there; on the other hand you can expose it in the following manner using code:

Note: I was going to remove this section for PFO in particluar, in an attempt to not seem patronising but I figured to aim at the lowest denominator.

C#
:

    //import namespace
    using VistaElements.VButton;
    //declare a reference in relevant scope
    private VButton vButton1;
    //or, without the using statement
    private VistaElements.VButton.VButton vButton1;
    //create a new instance
    vButton1 = new VButton();
    //add it to a control (ie Form)
    Controls.Add(vButton1);



VB.NET
:

    ‘import namespace
    Imports VistaElements.VButton;
    ‘declare a reference in relevant scope
    Private vButton1 As VButton
    ‘or without the using statement
    Private vButton1 As VistaElements.VButton.VButton
    ‘create a new instance
    vButton1 = New VButton()
    ‘add it to a control (ie Form)
    Controls.Add(vButton1)


Properties of the button

The button is quite customisable; using properties to indicate how the button should look allows this. The following are some of the properties available, mostly colours:

.NET Type: Color
BorderFill0
BorderFill1
ContentFill0
ContentFill1
FocusBorder
FocusInnerBorder
HoverFill
InnerInnerBorder
OuterBorder
OuterInnerBorder
Overlay0
Overlay1
Shadow

.NET Type: LinearGradientMode
GradientBorderMode
GradientContentMode
GradientOverlayMode

.NET Type: Image
Image

.NET Type: String
Text

.NET Type: ContentAlignment
TextAlign – only top, middle and bottom centre supported

.NET Type: Shape
Shape

Enjoy the control, and feel free to make suggestions for improvements, error fix requests etc and as time allows I will certainly take heed.

Alias

InfiNate Nov 9th, 2007 8:35 AM

Re: Vista Elements Button
 
Those look awesome, well done. Will try them out later and let you know what I think.

Alias Nov 9th, 2007 5:25 PM

Re: Vista Elements Button
 
Thank you, and, look forward to hearing from you.


All times are GMT -5. The time now is 12:52 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC