22using System . Drawing ;
33using System . Drawing . Drawing2D ;
44using System . Windows . Forms ;
5-
6- // --- Part 1: Define the color palette for our dark theme ---
75public class DarkColorTable : ProfessionalColorTable
86{
97 private Color backColor = Color . FromArgb ( 38 , 38 , 38 ) ;
@@ -26,38 +24,31 @@ public class DarkColorTable : ProfessionalColorTable
2624 public override Color MenuItemSelectedGradientEnd => selectedColor ;
2725}
2826
29- // --- Part 2: Create the renderer that uses the dark palette and fixes checkboxes ---
3027public class DarkMenuRenderer : ToolStripProfessionalRenderer
3128{
3229 public DarkMenuRenderer ( ) : base ( new DarkColorTable ( ) ) { }
3330
34- // Fix text color
3531 protected override void OnRenderItemText ( ToolStripItemTextRenderEventArgs e )
3632 {
3733 e . TextColor = Color . White ;
3834 base . OnRenderItemText ( e ) ;
3935 }
4036
41- // --- THIS IS THE NEW, FINAL VERSION ---
42- // It draws a bigger, sharper, and correctly scaled checkmark.
4337 protected override void OnRenderItemCheck ( ToolStripItemImageRenderEventArgs e )
4438 {
45- // We only want to draw if the item is actually checked.
4639 if ( e . Item is ToolStripMenuItem tsmi && tsmi . Checked )
4740 {
4841 var g = e . Graphics ;
4942 g . SmoothingMode = System . Drawing . Drawing2D . SmoothingMode . AntiAlias ;
5043
51- // Get the area available for the checkmark and add some padding
5244 var rect = e . ImageRectangle ;
5345 rect . Inflate ( - 4 , - 4 ) ; // 4px padding looks clean
5446
55- // Define the 3 points for a sharp "V" shape, relative to the padded area
5647 var p1 = new Point ( rect . Left , rect . Top + rect . Height / 2 ) ;
5748 var p2 = new Point ( rect . Left + rect . Width / 3 , rect . Bottom ) ;
5849 var p3 = new Point ( rect . Right , rect . Top ) ;
5950
60- // Draw the checkmark with a 2px thick, rounded pen
51+ // draw the checkmark with a 2px thick, rounded pen
6152 using ( var pen = new Pen ( Color . WhiteSmoke , 2f ) )
6253 {
6354 pen . StartCap = LineCap . Round ;
0 commit comments