Add a new virtual property `StatusStripBorder` to `ToolStripProfessionalRenderer`
See original GitHub issueSummary
Currently, if you want to theme your application with a ToolStripProfessionalRenderer
, there is an issue with the StatusStrip
border, as the drawing routine uses a hardcoded value for the border color. A new virtual property should be added to the ProfessionalColorTable
to customize that color. I have create a draft pull request here #4739.
Proposed API
public static class ProfessionalColors
{
[SRDescription(nameof(SR.ProfessionalColorsSeparatorLightDescr))]
public static Color SeparatorLight => ColorTable.SeparatorLight;
+ [SRDescription(nameof(SR.ProfessionalColorsStatusStripBorderDescr))]
+ public static Color StatusStripBorder => ColorTable.StatusStripBorder;
[SRDescription(nameof(SR.ProfessionalColorsStatusStripGradientBeginDescr))]
public static Color StatusStripGradientBegin => ColorTable.StatusStripGradientBegin;
}
public class ProfessionalColorTable
{
[SRDescription(nameof(SR.ProfessionalColorsSeparatorLightDescr))]
public virtual Color SeparatorLight => FromKnownColor(KnownColors.msocbvcrCBSplitterLineLight);
+ [SRDescription(nameof(SR.ProfessionalColorsStatusStripBorderDescr))]
+ public virtual Color StatusStripBorder => FromKnownColor(KnownColors.msocbvcrCBShadow);
[SRDescription(nameof(SR.ProfessionalColorsStatusStripGradientBeginDescr))]
public virtual Color StatusStripGradientBegin => FromKnownColor(KnownColors.msocbvcrCBGradMainMenuHorzBegin);
}
Implementations
public class ToolStripProfessionalRenderer : ToolStripRenderer
{
private void RenderStatusStripBorder(ToolStripRenderEventArgs e)
{
- e.Graphics.DrawLine(SystemPens.ButtonHighlight, 0, 0, e.ToolStrip.Width, 0);
+ e.Graphics.DrawLine(ColorTable.StatusStripBorder, 0, 0, e.ToolStrip.Width, 0);
}
}
Example
Create a custom color table deriving from ‘ProfessionalColorTable’ and overwrite the new virtual property ‘StatusStripBorder’ with the desired color:
public sealed class MyColorTable : ProfessionalColorTable
{
public override Color StatusStripBorder => Color.FromArgb(50, 50, 50);
}
Create a custom renderer deriving from ‘ToolStripProfessionalRenderer’ feeding the base constructor an instance of the custom color table created earlier:
public sealed class MyRenderer : ToolStripProfessionalRenderer
{
public MyRenderer() : base(new MyColorTable())
{
}
}
Now just set the created renderer to be the renderer of the ‘StatusStrip’ where desired:
StatusStrip statusStrip = new StatusStrip();
statusStrip.Renderer = new MyRenderer();
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to: Set the ToolStrip Renderer at Run Time
Create a new ToolStripProfessionalRenderer with a CustomProfessionalColors class, and assign it to the ToolStripManager.Renderer property. C#
Read more >ToolStripProfessionalRenderer Class (System.Windows. ...
Initializes a new instance of the ToolStripProfessionalRenderer class. Properties. ColorTable. Gets the color palette used for painting. RoundedEdges.
Read more >How can I make all properties virtual on entities generated ...
I found the method that make the properties in .cs file in the T4 template (.tt file in EF Model Design). public string...
Read more >Virtual properties
With this menu, you can create a new virtual property that will be created on every element (nodes, relationships, or merged relationships). With...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Verified the issue with 6.0.100-rc.1.21424.1 build, this issue is fixed.
During implementation we will want to make sure that High Contrast themes are honored and we’re able to adjust when a user needs to have High Contrast. Obviously a user can override to something that doesn’t work in high contrast, but our defaults need to be accessible.
Other than validating that, I have no personal objections.