11
11
using System ;
12
12
using System . Globalization ;
13
13
using System . Windows . Forms ;
14
- using Rubberduck . VBEditor . SafeComWrappers . VBA ;
14
+ using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
15
15
16
16
namespace Rubberduck
17
17
{
18
18
public sealed class App : IDisposable
19
19
{
20
- private readonly VBE _vbe ;
20
+ private readonly IVBE _vbe ;
21
21
private readonly IMessageBox _messageBox ;
22
22
private readonly IRubberduckParser _parser ;
23
- private AutoSave . AutoSave _autoSave ;
24
- private IGeneralConfigService _configService ;
23
+ private readonly AutoSave . AutoSave _autoSave ;
24
+ private readonly IGeneralConfigService _configService ;
25
25
private readonly IAppMenu _appMenus ;
26
- private RubberduckCommandBar _stateBar ;
27
- private IRubberduckHooks _hooks ;
26
+ private readonly RubberduckCommandBar _stateBar ;
27
+ private readonly IRubberduckHooks _hooks ;
28
28
private readonly UI . Settings . Settings _settings ;
29
29
30
30
private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
31
31
32
32
private Configuration _config ;
33
33
34
- public App ( VBE vbe , IMessageBox messageBox ,
34
+ public App ( IVBE vbe ,
35
+ IMessageBox messageBox ,
35
36
UI . Settings . Settings settings ,
36
37
IRubberduckParser parser ,
37
38
IGeneralConfigService configService ,
@@ -145,14 +146,10 @@ public void Startup()
145
146
EnsureDirectoriesExist ( ) ;
146
147
LoadConfig ( ) ;
147
148
_appMenus . Initialize ( ) ;
149
+ _stateBar . Initialize ( ) ;
148
150
_hooks . HookHotkeys ( ) ; // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
149
151
_appMenus . Localize ( ) ;
150
152
UpdateLoggingLevel ( ) ;
151
-
152
- //if (_vbe.VBProjects.Count != 0)
153
- //{
154
- // _parser.State.OnParseRequested(this);
155
- //}
156
153
}
157
154
158
155
public void Shutdown ( )
@@ -177,12 +174,12 @@ private void Parser_StateChanged(object sender, EventArgs e)
177
174
{
178
175
Logger . Debug ( "App handles StateChanged ({0}), evaluating menu states..." , _parser . State . Status ) ;
179
176
_appMenus . EvaluateCanExecute ( _parser . State ) ;
177
+ _stateBar . SetSelectionText ( ) ;
180
178
}
181
179
182
180
private void LoadConfig ( )
183
181
{
184
182
_config = _configService . LoadConfiguration ( ) ;
185
-
186
183
_autoSave . ConfigServiceSettingsChanged ( this , EventArgs . Empty ) ;
187
184
188
185
var currentCulture = RubberduckUI . Culture ;
@@ -214,14 +211,12 @@ public void Dispose()
214
211
_parser . State . StatusMessageUpdate -= State_StatusMessageUpdate ;
215
212
_parser . State . Dispose ( ) ;
216
213
_parser . Dispose ( ) ;
217
- // I won't set this to null because other components may try to release things
218
214
}
219
215
220
216
if ( _hooks != null )
221
217
{
222
218
_hooks . MessageReceived -= _hooks_MessageReceived ;
223
219
_hooks . Dispose ( ) ;
224
- _hooks = null ;
225
220
}
226
221
227
222
if ( _settings != null )
@@ -232,20 +227,17 @@ public void Dispose()
232
227
if ( _configService != null )
233
228
{
234
229
_configService . SettingsChanged -= _configService_SettingsChanged ;
235
- _configService = null ;
236
230
}
237
231
238
232
if ( _stateBar != null )
239
233
{
240
234
_stateBar . Refresh -= _stateBar_Refresh ;
241
235
_stateBar . Dispose ( ) ;
242
- _stateBar = null ;
243
236
}
244
237
245
238
if ( _autoSave != null )
246
239
{
247
240
_autoSave . Dispose ( ) ;
248
- _autoSave = null ;
249
241
}
250
242
251
243
UiDispatcher . Shutdown ( ) ;
0 commit comments