fgGradientButtons (Buttons with Gradient-Color)

D

Deleted member 103

Guest
Hi,

here is my new library. With this library you can create a button with a gradient and rounded corners.

The desktop version is just a dummy library, it generates only normal buttons with no gradient.

.NET Compact Framework 2.0 or higher is required.

The zip file also includes a examples and a Help-File.


Version 1.002 ;
  1. Property "WithPressedEffect" with Shadow effect.
  2. Button with AutoScale


Version 1.004 ;
  1. The desktop version is no longer a dummy library.
  2. Fixed errors on Shadow effect


Version 1.005 ;
  1. I changed the order of parameters in the method new2:
  2. from ...left,top,height,width,.. to ...left,top,width,height,..


Version 1.006 ;
  1. 2 new Property and 1 new method added:
  2. DockStyle
  3. AnchorStyles
  4. AddContextMenu


Version 1.007 ;
  1. Property ControlRef added:
  2. errors corrected in the Anchor property

Version 1.008 ;
  1. Property ImageMode added: cCenterImage, cStretchImage, cNormalImage
  2. Property TextAlignment added: alLeft, alCenter, alRight

Version 1.009 ;
  1. B4P-Autoscale added
  2. Property WithShadows added
  3. Property WithPressedEffect changed: 1.Clik=Button pressed, 2.Clik= Button released
  4. Events added: ButtonPressed, ButtonReleased


Ciao,
Filippo
 

Attachments

  • Example_v1.009.zip
    44.2 KB · Views: 181
  • capture001.jpg
    capture001.jpg
    12.5 KB · Views: 101
Last edited by a moderator:

ExcludeReality

Active Member
Licensed User
Very useful library!
Personally I like to design my own buttons with Paint.NET, but this is a terrific idea.
I'm sure it will come in handy

JOOC; Why is this library not available for desktop?
 
Last edited:

derez

Expert
Licensed User
Longtime User
Filippo
A very nice and usefull library, Thank you.

Can you please add a short description (instead of us playing with the example until all is clear ?).

Edit: I can see all through the menu !
 
Last edited:
D

Deleted member 103

Guest
Hi derez,

a short Help-File is included.

@ExcludeReality
JOOC; Why is this library not available for desktop?
I do not knows why but it will not just work.:(
But I don't care about. It's important for me that it works on the pocketpc.

Ciao,
Filippo
 

Cableguy

Expert
Licensed User
Longtime User
Hi filippo,

I am porting some of my code into a dll, hoping that doing so will make it work faster and smoother.. It uses 1 of your FgGradiantButtons, and I would like to keep them..So I ask if you could share the .cs file, for merging, and if I can have your permition to merge it into my dll, with given credits.
 

agraham

Expert
Licensed User
Longtime User
I do not knows why but it will not just work.:(
It needs visual styles enabling for the application on the desktop but the gradient still doesn't show :confused:
.
B4X:
   obj1.New1(False)
   obj1.CreateNew("System.Windows.Forms.Application" & obj1.System_Windows_Forms)
   obj1.RunMethod("EnableVisualStyles")
   obj1.SetProperty("VisualStyleState", "ClientAndNonClientAreasEnabled")

EDIT:- Forget visual styles, I was wrongly assuming it was an override of a standard Button. After poking around a bit I see that the desktop library does not actually try to implement the gradient filled button but is just an ordinary one. Filippo must have found some difficulty in getting the code to work on the desktop :(.
 
Last edited:
D

Deleted member 103

Guest
Hi Cableguy,

my DLL is written in vb.net, so there is none. cs-file.

@agraham
Filippo must have found some difficulty in getting the code to work on the desktop .
:sign0013:
 

Cableguy

Expert
Licensed User
Longtime User
Could you please share the source so that we/I can try to port to c#?
 

Byak@

Active Member
Licensed User
good work!
 

derez

Expert
Licensed User
Longtime User
Filippo

I am replacing the buttons of several application with your new buttons.
After replacement of a button there is some additional work to find all the places where the button color or fontcolor is changed, and to replace them with your definitions:
button.color ---> button.backcolor
button.fontcolor ---> button.forecolor

It would be nice if you can change the properties names to be the same as in a regular button.:)

One more thing:
The order of the parameters in the new2 method is:
New2 (FormName As String, Text As String, ForeColor As Color, FontSize As Integer, Left As Integer, Top As Integer, Height As Integer, Width As Integer, StartColor As Color, EndColor As Color, IsGradientVertical As Boolean, RoundedCorner As Boolean )

It would be more logical to put it like this:
....left,top,width,height,...


I know it is not really a big issue but since I like the new button I am going to do a lot of replacements and it will save me some errors.

Thank you !:)
 
Last edited:
D

Deleted member 103

Guest
Hallo derez,

It would be more logical to put it like this:
....left,top,width,height,...
thanks for the advice, I will change it in the next version.

After replacement of a button there is some additional work to find all the places where the button color or fontcolor is changed, and to replace them with your definitions:
button.color ---> button.backcolor
button.fontcolor ---> button.forecolor
The property "button.color" and "button.fontcolor" are not vb.Net concurring, check out the 2 images.


Ciao,
Filippo
 

Attachments

  • Button-BackColor.jpg
    Button-BackColor.jpg
    20.2 KB · Views: 33
  • Button-ForeColor.jpg
    Button-ForeColor.jpg
    17.3 KB · Views: 30

derez

Expert
Licensed User
Longtime User
Thanks filippo, that was quick...

I attach a tool that I wrote for transforming existing application to have fggradientbuttons instead of the regular buttons.

To use it you need to open the application source code in notepad and copy the "sub designer" part to a new txt file named src.txt. Do not try to change or save the file from notepad - you can loose your application.

Then run fgfile and open dst.txt which is created by the program. The file includes the new lines with the fgbuttons object definitions, for all the regular buttons in the application. You delete those that you dont want to change from the text, and delete those that you do want to change from the forms using the visual designer.

The start color is fixed in the program but of course it can be changed easily.

Remember also to find all places in the application where reference to button color is done and change it to endcolor or backcolor or forecolor etc. accordingly.

The comments with "vga" are for cases of changing an application for desktop which is based on a device application and use vga parameter to increase its size. by the way - GetControls does not catch fggradientbutton !:confused:

When thinking about it - the tool can be used for design of new applications as well - you design with the visual designer, putting regular buttons as you find fit and then change them to fg buttons by this tool.

Have fun :)
 

Attachments

  • fgfile.sbp
    2 KB · Views: 15
Last edited:

Zaam

Member
Licensed User
The buttons look awesome, I look forward to include them in my current app and most likely all future apps I'll make. Thanks a lot for your work :)
 
D

Deleted member 103

Guest
Hi derez,

Your Procedure is really good!

The Library fgGradientButtons does not need a VGA parameters when the buttons with the method New2 created. Look at the 2 pictures.

The comments with "vga" are for cases of changing an application for desktop which is based on a device application and use vga parameter to increase its size. by the way - GetControls does not catch fggradientbutton !

Example with GetControls:
For i = 0 To ArrayLen(Controls()) - 1
Crttype=ControlType(Controls(i))
If Crttype = "fgButtons.fgButtons.fgGradientButtons" Then
...


Ciao,
Filippo
 

Attachments

  • ScreenShot-fgGradientButtons-Device.jpg
    ScreenShot-fgGradientButtons-Device.jpg
    23.2 KB · Views: 22
  • ScreenShot-fgGradientButtons-Device-AutoScale.jpg
    ScreenShot-fgGradientButtons-Device-AutoScale.jpg
    24.5 KB · Views: 20

derez

Expert
Licensed User
Longtime User
Filippo

I use vga parameter to convert applications written for device, to the desktop. I do it with the sub used in the past, before there was optimized compilation for VGA.

Now that you showed me that Getcontrols works when the type is defined as "fgButtons.fgButtons.fgGradientButtons" (instead of just "fgGradientButtons" ) I don't need the commented part in the fgfile any more - the position stays as for the device, and the VGA sub multiply it by the vga factor.

I was thinking about elaboration of the tool - to enable the user to control each new line and decide if it has to be one color or two, or replaced at all.
It can be done easily but I already converted all my programs...maybe I'll do it anyway.

Thanks.
 
D

Deleted member 103

Guest
Hi derez,

I added the control "ImageButton" in your procedur .
 

Attachments

  • fgfile.sbp
    2.5 KB · Views: 15
Top