question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a new virtual property `StatusStripBorder` to `ToolStripProfessionalRenderer`

See original GitHub issue

Summary

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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Lydia-Shicommented, Aug 27, 2021

Verified the issue with 6.0.100-rc.1.21424.1 build, this issue is fixed. image

0reactions
merriemcgawcommented, Apr 6, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found