@@ -78,10 +78,7 @@ public string? Text
7878 _text = value ;
7979 if ( NativeDialogShowing )
8080 {
81- if ( _nativeDialog != null )
82- {
83- _nativeDialog . UpdateText ( _text ) ;
84- }
81+ _nativeDialog ? . UpdateText ( _text ) ;
8582 }
8683 }
8784 }
@@ -99,10 +96,7 @@ public string? InstructionText
9996 _instructionText = value ;
10097 if ( NativeDialogShowing )
10198 {
102- if ( _nativeDialog != null )
103- {
104- _nativeDialog . UpdateInstruction ( _instructionText ) ;
105- }
99+ _nativeDialog ? . UpdateInstruction ( _instructionText ) ;
106100 }
107101 }
108102 }
@@ -134,10 +128,7 @@ public string? FooterText
134128 _footerText = value ;
135129 if ( NativeDialogShowing )
136130 {
137- if ( _nativeDialog != null )
138- {
139- _nativeDialog . UpdateFooterText ( _footerText ) ;
140- }
131+ _nativeDialog ? . UpdateFooterText ( _footerText ) ;
141132 }
142133 }
143134 }
@@ -169,10 +160,7 @@ public string? DetailsExpandedText
169160 _detailsExpandedText = value ;
170161 if ( NativeDialogShowing )
171162 {
172- if ( _nativeDialog != null )
173- {
174- _nativeDialog . UpdateExpandedText ( _detailsExpandedText ) ;
175- }
163+ _nativeDialog ? . UpdateExpandedText ( _detailsExpandedText ) ;
176164 }
177165 }
178166 }
@@ -246,10 +234,7 @@ public TaskDialogStandardIcon Icon
246234 _icon = value ;
247235 if ( NativeDialogShowing )
248236 {
249- if ( _nativeDialog != null )
250- {
251- _nativeDialog . UpdateMainIcon ( _icon ) ;
252- }
237+ _nativeDialog ? . UpdateMainIcon ( _icon ) ;
253238 }
254239 }
255240 }
@@ -267,10 +252,7 @@ public TaskDialogStandardIcon FooterIcon
267252 _footerIcon = value ;
268253 if ( NativeDialogShowing )
269254 {
270- if ( _nativeDialog != null )
271- {
272- _nativeDialog . UpdateFooterIcon ( _footerIcon ) ;
273- }
255+ _nativeDialog ? . UpdateFooterIcon ( _footerIcon ) ;
274256 }
275257 }
276258 }
@@ -646,10 +628,7 @@ public void Close()
646628 throw new InvalidOperationException ( LocalizedMessages . TaskDialogCloseNonShowing ) ;
647629 }
648630
649- if ( _nativeDialog != null )
650- {
651- _nativeDialog . NativeClose ( TaskDialogResult . Cancel ) ;
652- }
631+ _nativeDialog ? . NativeClose ( TaskDialogResult . Cancel ) ;
653632 // TaskDialog's own cleanup code -
654633 // which runs post show - will handle disposal of native dialog.
655634 }
@@ -666,10 +645,7 @@ public void Close(TaskDialogResult closingResult)
666645 throw new InvalidOperationException ( LocalizedMessages . TaskDialogCloseNonShowing ) ;
667646 }
668647
669- if ( _nativeDialog != null )
670- {
671- _nativeDialog . NativeClose ( closingResult ) ;
672- }
648+ _nativeDialog ? . NativeClose ( closingResult ) ;
673649 // TaskDialog's own cleanup code -
674650 // which runs post show - will handle disposal of native dialog.
675651 }
@@ -1085,29 +1061,20 @@ void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogCo
10851061 case "State" :
10861062 if ( _progressBar != null )
10871063 {
1088- if ( _nativeDialog != null )
1089- {
1090- _nativeDialog . UpdateProgressBarState ( _progressBar . State ) ;
1091- }
1064+ _nativeDialog ? . UpdateProgressBarState ( _progressBar . State ) ;
10921065 }
10931066 break ;
10941067 case "Value" :
10951068 if ( _progressBar != null )
10961069 {
1097- if ( _nativeDialog != null )
1098- {
1099- _nativeDialog . UpdateProgressBarValue ( _progressBar . Value ) ;
1100- }
1070+ _nativeDialog ? . UpdateProgressBarValue ( _progressBar . Value ) ;
11011071 }
11021072 break ;
11031073 case "Minimum" :
11041074 case "Maximum" :
11051075 if ( _progressBar != null )
11061076 {
1107- if ( _nativeDialog != null )
1108- {
1109- _nativeDialog . UpdateProgressBarRange ( _progressBar . Minimum , _progressBar . Maximum ) ;
1110- }
1077+ _nativeDialog ? . UpdateProgressBarRange ( _progressBar . Minimum , _progressBar . Maximum ) ;
11111078 }
11121079 break ;
11131080 default :
@@ -1120,16 +1087,10 @@ void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogCo
11201087 switch ( propertyName )
11211088 {
11221089 case "ShowElevationIcon" :
1123- if ( _nativeDialog != null )
1124- {
1125- _nativeDialog . UpdateElevationIcon ( button . Id , button . UseElevationIcon ) ;
1126- }
1090+ _nativeDialog ? . UpdateElevationIcon ( button . Id , button . UseElevationIcon ) ;
11271091 break ;
11281092 case "Enabled" :
1129- if ( _nativeDialog != null )
1130- {
1131- _nativeDialog . UpdateButtonEnabled ( button . Id , button . Enabled ) ;
1132- }
1093+ _nativeDialog ? . UpdateButtonEnabled ( button . Id , button . Enabled ) ;
11331094 break ;
11341095 default :
11351096 Debug . Assert ( true , "Unknown property being set" ) ;
@@ -1173,7 +1134,7 @@ internal void RaiseButtonClickEvent(int id)
11731134 // If a custom button was found,
11741135 // raise the event - if not, it's a standard button, and
11751136 // we don't support custom event handling for the standard buttons
1176- if ( button != null ) { button . RaiseClickEvent ( ) ; }
1137+ button ? . RaiseClickEvent ( ) ;
11771138 }
11781139
11791140 internal void RaiseHyperlinkClickEvent ( string link )
@@ -1255,25 +1216,19 @@ private void CleanUp()
12551216 {
12561217 // Reset values that would be considered
12571218 // 'volatile' in a given instance.
1258- if ( _progressBar != null )
1259- {
1260- _progressBar . Reset ( ) ;
1261- }
1219+ _progressBar ? . Reset ( ) ;
12621220
12631221 // Clean out sorted control lists -
12641222 // though we don't of course clear the main controls collection,
12651223 // so the controls are still around; we'll
12661224 // resort on next show, since the collection may have changed.
1267- if ( _buttons != null ) { _buttons . Clear ( ) ; }
1268- if ( _commandLinks != null ) { _commandLinks . Clear ( ) ; }
1269- if ( _radioButtons != null ) { _radioButtons . Clear ( ) ; }
1225+ _buttons ? . Clear ( ) ;
1226+ _commandLinks ? . Clear ( ) ;
1227+ _radioButtons ? . Clear ( ) ;
12701228 _progressBar = null ;
12711229
12721230 // Have the native dialog clean up the rest.
1273- if ( _nativeDialog != null )
1274- {
1275- _nativeDialog . Dispose ( ) ;
1276- }
1231+ _nativeDialog ? . Dispose ( ) ;
12771232 }
12781233
12791234
@@ -1324,17 +1279,10 @@ public void Dispose(bool disposing)
13241279
13251280 // Clean up unmanaged resources SECOND, NTD counts on
13261281 // being closed before being disposed.
1327- if ( _nativeDialog != null )
1328- {
1329- _nativeDialog . Dispose ( ) ;
1330- _nativeDialog = null ;
1331- }
1332-
1333- if ( _staticDialog != null )
1334- {
1335- _staticDialog . Dispose ( ) ;
1336- _staticDialog = null ;
1337- }
1282+ _nativeDialog ? . Dispose ( ) ;
1283+ _nativeDialog = null ;
1284+ _staticDialog ? . Dispose ( ) ;
1285+ _staticDialog = null ;
13381286
13391287
13401288 }
0 commit comments