"Gradient Form Header" question


Author
Message
Ben Hayat
Ben Hayat
Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
I see this control uses Label and PictureBox to show "Title" and Image. The Title and Image show as transparent on Gradient background.



I also need to put label and Picture box on this control, but if they take the "BackColor" of the form and not the Gradient color of the control. How can I do it like the way Title and image shows?



Thanks!

..ßen
Ben Hayat
Ben Hayat
Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Never mind! Figured it out Smile



You can do really cool things with Gradation...


..ßen
Ben Hayat
Ben Hayat
Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
I think I spoke too soon. I tried to use ThemedPanel, but causes me other issues.

For one, the base color throws everything off, even with opacity set 100.



I still would like to use the gradient header, but need to find out how to make label and picture transparent.

Thanks!

..ßen
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I see this control uses Label and PictureBox to show "Title" and Image. The Title and Image show as transparent on Gradient background.

Actually it does not use an image or label.  These are rendered onto the control in the OnPaint of the control.

I still would like to use the gradient header, but need to find out how to make label and picture transparent.

Whenever you set a label or any other controls background to "Transparent" it will take the are on which is resides in its parent as the background....however, the GradientFormHeader control is not a parent control which means that no child object actually resides within the control itself.  So the labels parent is the form or container it resides within.

You have a couple of options.  First, just render your text on the gradient form header.  Handle the Paint event of the GradientFormHeader and just add your logic to render on top of it.  Second option would be to handle the Paint event of the label and capture the background of the rendered GradientFormHeader using the DrawToBitmap or the ScreenCapture classes...either way will work.  And then create your own transparency....this is ultimately what happens natively anyway.

The example above may be the approach you want to take.  I just created a new class, inherited from GradientFormHeader, overwrote the OnPaint method and added my logic.  You could create property that you set that adds this text to your header.  Below is the OnPaint code for the above example:

Public Class CustomHeader
    Inherits MicroFour.StrataFrame.UI.Windows.Forms.GradientFormHeader
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
        e.Graphics.DrawString("My Custom Text", Me.Font, Drawing.Brushes.Red, 200, 10)
    End Sub
End Class

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Oh, your other question:

For one, the base color throws everything off, even with opacity set 100.

The valid values are 0-255, and this is the opacity for the gradient colors to show thorugh to the base color....not the transparency of the control itself.

Ben Hayat
Ben Hayat
Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Good morning Trent; Thanks for detailed answer.



I understood your points very clearly, but due to the nature of my usage (I need to put lots of stuff on the form), it makes it hard to align everything via code rather using the designer. Here is a layout for my form using gradient background to start putting controls on them.



The valid values are 0-255, and this is the opacity for the gradient colors to show thorugh to the base color....not the transparency of the control itself.


The info on 255 solved my problem if I go with ThemedPanel.



Trent, if I don't have a way to host an image, is there a way to upload an image to the forum to show on the screen? I tried the "Insert Image", but it asks for URL, so I just attached it for you to look at my direction.



Thanks again!


..ßen
Attachments
sample.jpg (105 views, 31.00 KB)
Ben Hayat
Ben Hayat
Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
The valid values are 0-255, and this is the opacity for the gradient colors to show thorugh to the base color.




That's an interesting data. Can this be considered more like an 'alpha' channel? By combining the base into gradient, you can create new colors....Smile

..ßen
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Can this be considered more like an 'alpha' channel?

That is what it is....the alpha.

By combining the base into gradient, you can create new colors

That was its purpose.  It allows the themed colors to be toned down/up based on your needs if you use the ColorsONly ThemeSupport option.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I tried the "Insert Image", but it asks for URL, so I just attached it for you to look at my direction.

Use Internet Explorer to get a more detailed set of options to upload the image.  FireFox shows a different screen for some reason.

Ben Hayat
Ben Hayat
Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)Advanced StrataFrame User (518 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K

It works in IE. Thanks Trent!

..ßen

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search