@@ -23,9 +23,7 @@ internal class FlatComboAdapter
2323 private const int OFFSET_2PIXELS = 2 ;
2424 protected static int s_offsetPixels = OFFSET_2PIXELS ;
2525
26- private bool ShouldRedrawAsSmallButton { get ; }
27-
28- public FlatComboAdapter ( ComboBox comboBox , bool shouldRedrawAsSmallButton )
26+ public FlatComboAdapter ( ComboBox comboBox , bool smallButton )
2927 {
3028 // adapter is re-created when combobox is resized, see IsValid method, thus we don't need to handle DPI changed explicitly
3129 s_offsetPixels = comboBox . LogicalToDeviceUnits ( OFFSET_2PIXELS ) ;
@@ -37,10 +35,8 @@ public FlatComboAdapter(ComboBox comboBox, bool shouldRedrawAsSmallButton)
3735 _innerInnerBorder = new Rectangle ( _innerBorder . X + 1 , _innerBorder . Y + 1 , _innerBorder . Width - 2 , _innerBorder . Height - 2 ) ;
3836 _dropDownRect = new Rectangle ( _innerBorder . Right + 1 , _innerBorder . Y , dropDownButtonWidth , _innerBorder . Height + 1 ) ;
3937
40- ShouldRedrawAsSmallButton = shouldRedrawAsSmallButton ;
41-
4238 // fill in several pixels of the dropdown rect with white so that it looks like the combo button is thinner.
43- if ( shouldRedrawAsSmallButton )
39+ if ( smallButton )
4440 {
4541 _whiteFillRect = _dropDownRect ;
4642 _whiteFillRect . Width = WhiteFillRectWidth ;
@@ -64,48 +60,6 @@ public bool IsValid(ComboBox combo)
6460 return ( combo . ClientRectangle == _clientRect && combo . RightToLeft == _origRightToLeft ) ;
6561 }
6662
67- public virtual void DrawPopUpCombo ( ComboBox comboBox , Graphics g )
68- {
69- if ( comboBox . DropDownStyle == ComboBoxStyle . Simple )
70- {
71- return ;
72- }
73-
74- if ( ShouldRedrawAsSmallButton )
75- {
76- DrawFlatCombo ( comboBox , g ) ;
77- }
78-
79- bool rightToLeft = comboBox . RightToLeft == RightToLeft . Yes ;
80-
81- // Draw a dark border around everything if we're in popup mode
82- if ( ( ! comboBox . Enabled ) || ( comboBox . FlatStyle == FlatStyle . Popup ) )
83- {
84- bool focused = comboBox . ContainsFocus || comboBox . MouseIsOver ;
85- Color borderPenColor = GetPopupOuterBorderColor ( comboBox , focused ) ;
86-
87- using var borderPen = borderPenColor . GetCachedPenScope ( ) ;
88- Pen innerPen = comboBox . Enabled ? borderPen : SystemPens . Control ;
89-
90- // Draw a border around the dropdown.
91- if ( rightToLeft )
92- {
93- g . DrawRectangle (
94- innerPen ,
95- new Rectangle ( _outerBorder . X , _outerBorder . Y , _dropDownRect . Width + 1 , _outerBorder . Height ) ) ;
96- }
97- else
98- {
99- g . DrawRectangle (
100- innerPen ,
101- new Rectangle ( _dropDownRect . X , _outerBorder . Y , _outerBorder . Right - _dropDownRect . X , _outerBorder . Height ) ) ;
102- }
103-
104- // Draw a border around the whole comboBox.
105- g . DrawRectangle ( borderPen , _outerBorder ) ;
106- }
107- }
108-
10963 /// <summary>
11064 /// Paints over the edges of the combo box to make it appear flat.
11165 /// </summary>
@@ -153,6 +107,33 @@ public virtual void DrawFlatCombo(ComboBox comboBox, Graphics g)
153107 using var innerBorderPen = innerBorderColor . GetCachedPenScope ( ) ;
154108 g . DrawRectangle ( innerBorderPen , _innerBorder ) ;
155109 g . DrawRectangle ( innerBorderPen , _innerInnerBorder ) ;
110+
111+ // Draw a dark border around everything if we're in popup mode
112+ if ( ( ! comboBox . Enabled ) || ( comboBox . FlatStyle == FlatStyle . Popup ) )
113+ {
114+ bool focused = comboBox . ContainsFocus || comboBox . MouseIsOver ;
115+ Color borderPenColor = GetPopupOuterBorderColor ( comboBox , focused ) ;
116+
117+ using var borderPen = borderPenColor . GetCachedPenScope ( ) ;
118+ Pen innerPen = comboBox . Enabled ? borderPen : SystemPens . Control ;
119+
120+ // Around the dropdown
121+ if ( rightToLeft )
122+ {
123+ g . DrawRectangle (
124+ innerPen ,
125+ new Rectangle ( _outerBorder . X , _outerBorder . Y , _dropDownRect . Width + 1 , _outerBorder . Height ) ) ;
126+ }
127+ else
128+ {
129+ g . DrawRectangle (
130+ innerPen ,
131+ new Rectangle ( _dropDownRect . X , _outerBorder . Y , _outerBorder . Right - _dropDownRect . X , _outerBorder . Height ) ) ;
132+ }
133+
134+ // Around the whole combobox.
135+ g . DrawRectangle ( borderPen , _outerBorder ) ;
136+ }
156137 }
157138
158139 /// <summary>
0 commit comments