11
11
using Microsoft . Win32 ;
12
12
using Windows . Win32 . System . Variant ;
13
13
using Windows . Win32 . UI . Accessibility ;
14
+ using static System . Windows . Forms . ControlPaint ;
14
15
15
16
namespace System . Windows . Forms . PropertyGridInternal ;
16
17
@@ -190,33 +191,44 @@ public bool CanUndo
190
191
/// the selected row's <see cref="GridEntry"/>.
191
192
/// </para>
192
193
/// </remarks>
194
+ #pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
193
195
internal DropDownButton DropDownButton
194
196
{
195
197
get
196
198
{
197
- if ( _dropDownButton is null )
199
+ if ( _dropDownButton is not null )
198
200
{
199
- OwnerGrid . CheckInCreate ( ) ;
201
+ return _dropDownButton ;
202
+ }
200
203
201
- _dropDownButton = new ( )
202
- {
203
- UseComboBoxTheme = true
204
- } ;
204
+ OwnerGrid . CheckInCreate ( ) ;
205
205
206
- Bitmap bitmap = CreateResizedBitmap ( "Arrow" , DownArrowIconWidth , DownArrowIconHeight ) ;
207
- _dropDownButton . Image = bitmap ;
208
- _dropDownButton . BackColor = SystemColors . Control ;
209
- _dropDownButton . ForeColor = SystemColors . ControlText ;
210
- _dropDownButton . Click += OnButtonClick ;
211
- _dropDownButton . GotFocus += OnDropDownButtonGotFocus ;
212
- _dropDownButton . LostFocus += OnChildLostFocus ;
213
- _dropDownButton . TabIndex = 2 ;
206
+ _dropDownButton = new ( )
207
+ {
208
+ UseComboBoxTheme = true ,
209
+ RequestDarkModeRendering = Application . IsDarkModeEnabled ,
210
+ ControlButtonStyle = ModernControlButtonStyle . OpenDropDown | ModernControlButtonStyle . RoundedBorder
211
+ } ;
214
212
215
- CommonEditorSetup ( _dropDownButton ) ;
216
- _dropDownButton . Size = ScaleHelper . IsScalingRequirementMet
217
- ? new ( SystemInformation . VerticalScrollBarArrowHeightForDpi ( DeviceDpiInternal ) , RowHeight )
218
- : new ( SystemInformation . VerticalScrollBarArrowHeight , RowHeight ) ;
219
- }
213
+ Bitmap bitmap = CreateResizedBitmap (
214
+ "Arrow" ,
215
+ DownArrowIconWidth ,
216
+ DownArrowIconHeight ) ;
217
+
218
+ // For classic mode/backwards compatibility.
219
+ _dropDownButton . Image = bitmap ;
220
+ _dropDownButton . BackColor = SystemColors . Control ;
221
+ _dropDownButton . ForeColor = SystemColors . ControlText ;
222
+ _dropDownButton . Click += OnButtonClick ;
223
+ _dropDownButton . GotFocus += OnDropDownButtonGotFocus ;
224
+ _dropDownButton . LostFocus += OnChildLostFocus ;
225
+ _dropDownButton . TabIndex = 2 ;
226
+
227
+ CommonEditorSetup ( _dropDownButton ) ;
228
+
229
+ _dropDownButton . Size = ScaleHelper . IsScalingRequirementMet
230
+ ? new ( SystemInformation . VerticalScrollBarArrowHeightForDpi ( DeviceDpiInternal ) , RowHeight )
231
+ : new ( SystemInformation . VerticalScrollBarArrowHeight , RowHeight ) ;
220
232
221
233
return _dropDownButton ;
222
234
}
@@ -235,32 +247,42 @@ internal Button DialogButton
235
247
{
236
248
get
237
249
{
238
- if ( _dialogButton is null )
250
+ if ( _dialogButton is not null )
239
251
{
240
- OwnerGrid . CheckInCreate ( ) ;
252
+ return _dialogButton ;
253
+ }
241
254
242
- _dialogButton = new DropDownButton
243
- {
244
- BackColor = SystemColors . Control ,
245
- ForeColor = SystemColors . ControlText ,
246
- TabIndex = 3 ,
247
- Image = CreateResizedBitmap ( "dotdotdot" , DotDotDotIconWidth , DotDotDotIconHeight )
248
- } ;
255
+ OwnerGrid . CheckInCreate ( ) ;
249
256
250
- _dialogButton . Click += OnButtonClick ;
251
- _dialogButton . KeyDown += OnButtonKeyDown ;
252
- _dialogButton . GotFocus += OnDropDownButtonGotFocus ;
253
- _dialogButton . LostFocus += OnChildLostFocus ;
254
- _dialogButton . Size = ScaleHelper . IsScalingRequirementMet
255
- ? new Size ( SystemInformation . VerticalScrollBarArrowHeightForDpi ( DeviceDpiInternal ) , RowHeight )
256
- : new Size ( SystemInformation . VerticalScrollBarArrowHeight , RowHeight ) ;
257
+ _dialogButton = new DropDownButton
258
+ {
259
+ RequestDarkModeRendering = Application . IsDarkModeEnabled ,
260
+ ControlButtonStyle = ModernControlButtonStyle . Ellipse | ModernControlButtonStyle . RoundedBorder ,
261
+ BackColor = SystemColors . Control ,
262
+ ForeColor = SystemColors . ControlText ,
263
+ TabIndex = 3 ,
257
264
258
- CommonEditorSetup ( _dialogButton ) ;
259
- }
265
+ // For classic mode/backwards compatibility.
266
+ Image = CreateResizedBitmap (
267
+ "dotdotdot" ,
268
+ DotDotDotIconWidth ,
269
+ DotDotDotIconHeight )
270
+ } ;
271
+
272
+ _dialogButton . Click += OnButtonClick ;
273
+ _dialogButton . KeyDown += OnButtonKeyDown ;
274
+ _dialogButton . GotFocus += OnDropDownButtonGotFocus ;
275
+ _dialogButton . LostFocus += OnChildLostFocus ;
276
+ _dialogButton . Size = ScaleHelper . IsScalingRequirementMet
277
+ ? new Size ( SystemInformation . VerticalScrollBarArrowHeightForDpi ( DeviceDpiInternal ) , RowHeight )
278
+ : new Size ( SystemInformation . VerticalScrollBarArrowHeight , RowHeight ) ;
279
+
280
+ CommonEditorSetup ( _dialogButton ) ;
260
281
261
282
return _dialogButton ;
262
283
}
263
284
}
285
+ #pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
264
286
265
287
/// <summary>
266
288
/// The common text box for editing values.
@@ -269,30 +291,32 @@ private GridViewTextBox EditTextBox
269
291
{
270
292
get
271
293
{
272
- if ( _editTextBox is null )
294
+ if ( _editTextBox is not null )
273
295
{
274
- OwnerGrid . CheckInCreate ( ) ;
296
+ return _editTextBox ;
297
+ }
275
298
276
- _editTextBox = new ( this )
277
- {
278
- BorderStyle = BorderStyle . None ,
279
- AutoSize = false ,
280
- TabStop = false ,
281
- AcceptsReturn = true ,
282
- BackColor = BackColor ,
283
- ForeColor = ForeColor
284
- } ;
299
+ OwnerGrid . CheckInCreate ( ) ;
285
300
286
- _editTextBox . KeyDown += OnEditKeyDown ;
287
- _editTextBox . KeyPress += OnEditKeyPress ;
288
- _editTextBox . GotFocus += OnEditGotFocus ;
289
- _editTextBox . LostFocus += OnEditLostFocus ;
290
- _editTextBox . MouseDown += OnEditMouseDown ;
291
- _editTextBox . TextChanged += OnEditChange ;
301
+ _editTextBox = new ( this )
302
+ {
303
+ BorderStyle = BorderStyle . None ,
304
+ AutoSize = false ,
305
+ TabStop = false ,
306
+ AcceptsReturn = true ,
307
+ BackColor = BackColor ,
308
+ ForeColor = ForeColor
309
+ } ;
292
310
293
- _editTextBox . TabIndex = 1 ;
294
- CommonEditorSetup ( _editTextBox ) ;
295
- }
311
+ _editTextBox . KeyDown += OnEditKeyDown ;
312
+ _editTextBox . KeyPress += OnEditKeyPress ;
313
+ _editTextBox . GotFocus += OnEditGotFocus ;
314
+ _editTextBox . LostFocus += OnEditLostFocus ;
315
+ _editTextBox . MouseDown += OnEditMouseDown ;
316
+ _editTextBox . TextChanged += OnEditChange ;
317
+
318
+ _editTextBox . TabIndex = 1 ;
319
+ CommonEditorSetup ( _editTextBox ) ;
296
320
297
321
return _editTextBox ;
298
322
}
@@ -2210,7 +2234,7 @@ protected override void OnGotFocus(EventArgs e)
2210
2234
if ( ( Size . Width > doubleOffset ) && ( Size . Height > doubleOffset ) )
2211
2235
{
2212
2236
using Graphics g = CreateGraphicsInternal ( ) ;
2213
- ControlPaint . DrawFocusRectangle ( g , new Rectangle ( _offset2Units , _offset2Units , Size . Width - doubleOffset , Size . Height - doubleOffset ) ) ;
2237
+ DrawFocusRectangle ( g , new Rectangle ( _offset2Units , _offset2Units , Size . Width - doubleOffset , Size . Height - doubleOffset ) ) ;
2214
2238
}
2215
2239
}
2216
2240
}
0 commit comments