@@ -134,69 +134,71 @@ public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
134
134
135
135
private void InitializeAddIn ( )
136
136
{
137
- if ( _isInitialized )
138
- {
139
- // The add-in is already initialized. See:
140
- // The strange case of the add-in initialized twice
141
- // http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-strange-case-of-the-add-in-initialized-twice.aspx
142
- return ;
143
- }
144
-
145
- var configLoader = new XmlPersistanceService < GeneralSettings >
146
- {
147
- FilePath =
148
- Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,
149
- "Rubberduck" , "rubberduck.config" )
150
- } ;
151
- var configProvider = new GeneralConfigProvider ( configLoader ) ;
152
-
153
- _initialSettings = configProvider . Create ( ) ;
154
- if ( _initialSettings != null )
137
+ Splash splash = null ;
138
+ try
155
139
{
156
- try
140
+ if ( _isInitialized )
157
141
{
158
- var cultureInfo = CultureInfo . GetCultureInfo ( _initialSettings . Language . Code ) ;
159
- Dispatcher . CurrentDispatcher . Thread . CurrentUICulture = cultureInfo ;
142
+ // The add-in is already initialized. See:
143
+ // The strange case of the add-in initialized twice
144
+ // http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-strange-case-of-the-add-in-initialized-twice.aspx
145
+ return ;
160
146
}
161
- catch ( CultureNotFoundException )
147
+
148
+ var configLoader = new XmlPersistanceService < GeneralSettings >
162
149
{
163
- }
164
- try
150
+ FilePath =
151
+ Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,
152
+ "Rubberduck" , "rubberduck.config" )
153
+ } ;
154
+ var configProvider = new GeneralConfigProvider ( configLoader ) ;
155
+
156
+ _initialSettings = configProvider . Create ( ) ;
157
+ if ( _initialSettings != null )
165
158
{
166
- if ( _initialSettings . SetDpiUnaware )
159
+ try
167
160
{
168
- SHCore . SetProcessDpiAwareness ( PROCESS_DPI_AWARENESS . Process_DPI_Unaware ) ;
161
+ var cultureInfo = CultureInfo . GetCultureInfo ( _initialSettings . Language . Code ) ;
162
+ Dispatcher . CurrentDispatcher . Thread . CurrentUICulture = cultureInfo ;
163
+ }
164
+ catch ( CultureNotFoundException )
165
+ {
166
+ }
167
+
168
+ try
169
+ {
170
+ if ( _initialSettings . SetDpiUnaware )
171
+ {
172
+ SHCore . SetProcessDpiAwareness ( PROCESS_DPI_AWARENESS . Process_DPI_Unaware ) ;
173
+ }
174
+ }
175
+ catch ( Exception )
176
+ {
177
+ Debug . Assert ( false , "Could not set DPI awareness." ) ;
169
178
}
170
179
}
171
- catch ( Exception )
180
+ else
172
181
{
173
- Debug . Assert ( false , "Could not set DPI awareness ." ) ;
182
+ Debug . Assert ( false , "Settings could not be initialized ." ) ;
174
183
}
175
- }
176
- else
177
- {
178
- Debug . Assert ( false , "Settings could not be initialized." ) ;
179
- }
180
184
181
- Splash splash = null ;
182
- if ( _initialSettings . CanShowSplash )
183
- {
184
- splash = new Splash
185
+ if ( _initialSettings ? . CanShowSplash ?? false )
185
186
{
186
- // note: IVersionCheck.CurrentVersion could return this string.
187
- Version = $ "version { Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version } "
188
- } ;
189
- splash . Show ( ) ;
190
- splash . Refresh ( ) ;
191
- }
187
+ splash = new Splash
188
+ {
189
+ // note: IVersionCheck.CurrentVersion could return this string.
190
+ Version = $ "version { Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version } "
191
+ } ;
192
+ splash . Show ( ) ;
193
+ splash . Refresh ( ) ;
194
+ }
192
195
193
- try
194
- {
195
196
Startup ( ) ;
196
197
}
197
198
catch ( Win32Exception )
198
199
{
199
- System . Windows . Forms . MessageBox . Show ( Resources . RubberduckUI . RubberduckReloadFailure_Message , RubberduckUI . RubberduckReloadFailure_Title ,
200
+ System . Windows . Forms . MessageBox . Show ( Resources . RubberduckUI . RubberduckReloadFailure_Message ,
201
+ RubberduckUI . RubberduckReloadFailure_Title ,
200
202
MessageBoxButtons . OK , MessageBoxIcon . Exclamation ) ;
201
203
}
202
204
catch ( Exception exception )
@@ -211,8 +213,8 @@ private void InitializeAddIn()
211
213
RubberduckUI. RubberduckLoadFailure , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
212
214
}
213
215
finally
214
- {
215
- splash ? . Dispose ( ) ;
216
+ {
217
+ splash ? . Dispose ( ) ;
216
218
}
217
219
}
218
220
0 commit comments