The AppearanceControl already has two properties for the ToolStripPanel: ToolStripAppearance.PanelGradientBegin and ToolStripAppearance.PanelGradientEnd.
You don't need to change anything in the AppearanceControl at all. All you need to do is add a new CustomizableToolStripPanel class. You can copy the code exactly from the CustomizableToolStrip class:
vb.net Code:
Public Class CustomizableToolStripPanel
Inherits ToolStripPanel
Public Event AppearanceControlChanged As EventHandler
Public Sub New()
MyBase.New()
Me.RoundedEdges = True
End Sub
Private _Appearance As AppearanceControl
Public Property Appearance() As AppearanceControl
Get
Return _Appearance
End Get
Set(ByVal value As AppearanceControl)
_Appearance = value
If value IsNot Nothing Then
Me.Renderer = value.Renderer
End If
Me.Invalidate()
Me.OnAppearanceControlChanged(EventArgs.Empty)
End Set
End Property
Private _RoundedEdges As Boolean
Public Property RoundedEdges() As Boolean
Get
Return _RoundedEdges
End Get
Set(ByVal value As Boolean)
If _RoundedEdges <> value Then
_RoundedEdges = value
CType(Me.Renderer, ToolStripProfessionalRenderer).RoundedEdges = _RoundedEdges
Me.Invalidate()
End If
End Set
End Property
Protected Overridable Sub OnAppearanceControlChanged(ByVal e As EventArgs)
If Me.Appearance IsNot Nothing Then
AddHandler Me.Appearance.AppearanceChanged, AddressOf AppearanceControl_AppearanceChanged
AddHandler Me.Appearance.Disposed, AddressOf AppearanceControl_Disposed
Me.Renderer = Me.Appearance.Renderer
Else
Me.Renderer = New ToolStripProfessionalRenderer()
End If
Me.Invalidate()
RaiseEvent AppearanceControlChanged(Me, e)
End Sub
Private Sub AppearanceControl_Disposed(ByVal sender As Object, ByVal e As EventArgs)
Me.Appearance = Nothing
Me.OnAppearanceControlChanged(EventArgs.Empty)
End Sub
Private Sub AppearanceControl_AppearanceChanged(ByVal sender As Object, ByVal e As EventArgs)
Me.Renderer = Me.Appearance.Renderer
CType(Me.Renderer, ToolStripProfessionalRenderer).RoundedEdges = _RoundedEdges
Me.Invalidate()
End Sub
End Class
(I don't think the RoundedEdges property does anything for a ToolStripPanel, but it can't hurt)
Now all you need to do is put your CustomizableToolStrip in this CustomizableToolStripPanel, set the Appearance property (of the panel as well!) to the AppearanceControl you want to use, and change its panel properties (the two I listed above).
This will give you a horizontal gradient in the ToolStripPanel (unless you chose the same color for begin and end obviously). If you want a vertical gradient, or some other shape, then you're out of luck, my control cannot help you with that. My control merely exposes the properties of the ProfessionalColorTable class (which is used by the ToolStripProfessionalRenderer to draw the toolstrips), allowing you to change them at will. You cannot change how the drawing is done, only the colors.
If you still want to change the shape (vertical gradient for example), then your only option is to create your own ToolStripProfessionalRenderer, override the methods you need, and let the ToolStripPanel use that instead of the default.
But thanks for bringing this to my attention, I did not realize that the two panel properties were absolutely useless until now, because there wasn't a CustomizableToolStripPanel yet. I will add it to the first post now.