@@ -116,11 +116,10 @@ private void Application_Startup(object sender, StartupEventArgs e)
116
116
// Save session data and close application
117
117
OnClosed ( _appVM , _mainWindow ) ;
118
118
119
- var dispose = _appVM as IDisposable ;
120
- if ( dispose != null )
121
- dispose . Dispose ( ) ;
119
+ if ( _appVM is IDisposable dispose )
120
+ dispose . Dispose ( ) ;
122
121
123
- _mainWindow . DataContext = null ;
122
+ _mainWindow . DataContext = null ;
124
123
} ;
125
124
126
125
MainWindow . Show ( ) ;
@@ -165,14 +164,13 @@ private void ConstructMainWindowSession(AppViewModel workSpace,
165
164
Application . Current . MainWindow = _mainWindow ;
166
165
_mainWindow . DataContext = _appVM ;
167
166
168
- // Establish command binding to accept user input via commanding framework
169
- // workSpace.InitCommandBinding(win);
167
+ // Establish command binding to accept user input via commanding framework
168
+ // workSpace.InitCommandBinding(win);
170
169
171
- ViewPosSizeModel viewSz ;
172
- settings . SessionData . WindowPosSz . TryGetValue ( settings . SessionData . MainWindowName
173
- , out viewSz ) ;
170
+ settings . SessionData . WindowPosSz . TryGetValue ( settings . SessionData . MainWindowName
171
+ , out ViewPosSizeModel viewSz ) ;
174
172
175
- viewSz . SetWindowsState ( win ) ;
173
+ viewSz . SetWindowsState ( win ) ;
176
174
177
175
string lastActiveFile = settings . SessionData . LastActiveSolution ;
178
176
@@ -193,37 +191,33 @@ private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
193
191
{
194
192
try
195
193
{
196
- AppViewModel wsVM = base . MainWindow . DataContext as AppViewModel ;
197
-
198
- if ( wsVM != null )
199
- {
200
- var MainWindowCanClose = MainWindow as IMetroWindow ;
201
-
202
- if ( MainWindowCanClose != null )
203
- {
204
- if ( MainWindowCanClose . IsContentDialogVisible == true )
205
- {
206
- e . Cancel = true ; // Lets not close with open dialog
207
- return ;
208
- }
209
- }
210
-
211
- // Close all open files and check whether application is ready to close
212
- if ( wsVM . AppLifeCycle . Exit_CheckConditions ( wsVM ) == true )
213
- {
214
- // (other than exception and error handling)
215
- wsVM . AppLifeCycle . OnRequestClose ( true ) ;
216
-
217
- _mainWindow . OnSaveLayout ( ) ;
218
- e . Cancel = false ;
219
- }
220
- else
221
- {
222
- wsVM . AppLifeCycle . CancelShutDown ( ) ;
223
- e . Cancel = true ;
224
- }
225
- }
226
- }
194
+ if ( base . MainWindow . DataContext is AppViewModel wsVM )
195
+ {
196
+ if ( MainWindow is IMetroWindow MainWindowCanClose )
197
+ {
198
+ if ( MainWindowCanClose . IsContentDialogVisible == true )
199
+ {
200
+ e . Cancel = true ; // Lets not close with open dialog
201
+ return ;
202
+ }
203
+ }
204
+
205
+ // Close all open files and check whether application is ready to close
206
+ if ( wsVM . AppLifeCycle . Exit_CheckConditions ( wsVM ) == true )
207
+ {
208
+ // (other than exception and error handling)
209
+ wsVM . AppLifeCycle . OnRequestClose ( true ) ;
210
+
211
+ _mainWindow . OnSaveLayout ( ) ;
212
+ e . Cancel = false ;
213
+ }
214
+ else
215
+ {
216
+ wsVM . AppLifeCycle . CancelShutDown ( ) ;
217
+ e . Cancel = true ;
218
+ }
219
+ }
220
+ }
227
221
catch ( Exception exp )
228
222
{
229
223
Debug . WriteLine ( exp ) ;
@@ -241,10 +235,9 @@ private void OnClosed(AppViewModel appVM, IViewSize win)
241
235
{
242
236
var settings = GetService < ISettingsManager > ( ) ;
243
237
244
- ViewPosSizeModel viewSz ;
245
- settings . SessionData . WindowPosSz . TryGetValue ( settings . SessionData . MainWindowName
246
- , out viewSz ) ;
247
- viewSz . GetWindowsState ( win ) ;
238
+ settings . SessionData . WindowPosSz . TryGetValue ( settings . SessionData . MainWindowName
239
+ , out ViewPosSizeModel viewSz ) ;
240
+ viewSz . GetWindowsState ( win ) ;
248
241
249
242
_appVM . GetSessionData ( settings . SessionData ) ;
250
243
0 commit comments