public App(VBE vbe, IMessageBox messageBox, UI.Settings.Settings settings, IRubberduckParser parser, IGeneralConfigService configService, IAppMenu appMenus, RubberduckCommandBar stateBar, IRubberduckHooks hooks) { _vbe = vbe; _messageBox = messageBox; _settings = settings; _parser = parser; _configService = configService; _autoSave = new AutoSave.AutoSave(_vbe, _configService); _appMenus = appMenus; _stateBar = stateBar; _hooks = hooks; _hooks.MessageReceived += _hooks_MessageReceived; _configService.SettingsChanged += _configService_SettingsChanged; _parser.State.StateChanged += Parser_StateChanged; _parser.State.StatusMessageUpdate += State_StatusMessageUpdate; _stateBar.Refresh += _stateBar_Refresh; UiDispatcher.Initialize(); }
public void Dispose() { if (_disposed) { return; } if (_parser != null && _parser.State != null) { _parser.State.StateChanged -= Parser_StateChanged; _parser.State.StatusMessageUpdate -= State_StatusMessageUpdate; _parser.State.Dispose(); _parser.Dispose(); // I won't set this to null because other components may try to release things } if (_hooks != null) { _hooks.MessageReceived -= _hooks_MessageReceived; _hooks.Dispose(); _hooks = null; } if (_settings != null) { _settings.Dispose(); } if (_configService != null) { _configService.SettingsChanged -= _configService_SettingsChanged; _configService = null; } if (_stateBar != null) { _stateBar.Refresh -= _stateBar_Refresh; _stateBar.Dispose(); _stateBar = null; } if (_autoSave != null) { _autoSave.Dispose(); _autoSave = null; } UiDispatcher.Shutdown(); _disposed = true; }
public App(VBE vbe, IMessageBox messageBox, IRubberduckParser parser, IGeneralConfigService configService, IAppMenu appMenus, RubberduckCommandBar stateBar, IRubberduckHooks hooks, SourceControlDockablePresenter sourceControlPresenter) { _vbe = vbe; _messageBox = messageBox; _parser = parser; _configService = configService; _autoSave = new AutoSave.AutoSave(_vbe, _configService); _appMenus = appMenus; _stateBar = stateBar; _hooks = hooks; _logger = LogManager.GetCurrentClassLogger(); var sourceControlPanel = (SourceControlPanel)sourceControlPresenter.Window(); _sourceControlPanelVM = (SourceControlViewViewModel)sourceControlPanel.ViewModel; _branchesVM = (BranchesViewViewModel)_sourceControlPanelVM.TabItems.Single(t => t.ViewModel.Tab == SourceControlTab.Branches).ViewModel; _sourceControlPanelVM.OpenRepoStarted += DisableSinkEventHandlers; _sourceControlPanelVM.OpenRepoCompleted += EnableSinkEventHandlersAndUpdateCache; _branchesVM.LoadingComponentsStarted += DisableSinkEventHandlers; _branchesVM.LoadingComponentsCompleted += EnableSinkEventHandlersAndUpdateCache; _hooks.MessageReceived += _hooks_MessageReceived; _configService.SettingsChanged += _configService_SettingsChanged; _configService.LanguageChanged += ConfigServiceLanguageChanged; _parser.State.StateChanged += Parser_StateChanged; _parser.State.StatusMessageUpdate += State_StatusMessageUpdate; _stateBar.Refresh += _stateBar_Refresh; _sink = new VBProjectsEventsSink(); var connectionPointContainer = (IConnectionPointContainer)_vbe.VBProjects; var interfaceId = typeof(_dispVBProjectsEvents).GUID; connectionPointContainer.FindConnectionPoint(ref interfaceId, out _projectsEventsConnectionPoint); _sink.ProjectAdded += sink_ProjectAdded; _sink.ProjectRemoved += sink_ProjectRemoved; _sink.ProjectActivated += sink_ProjectActivated; _sink.ProjectRenamed += sink_ProjectRenamed; _projectsEventsConnectionPoint.Advise(_sink, out _projectsEventsCookie); UiDispatcher.Initialize(); }
public App(IVBE vbe, IMessageBox messageBox, IGeneralConfigService configService, IAppMenu appMenus, IRubberduckHooks hooks, IVersionCheck version, CommandBase checkVersionCommand) { _messageBox = messageBox; _configService = configService; _autoSave = new AutoSave.AutoSave(vbe, _configService); _appMenus = appMenus; _hooks = hooks; _version = version; _checkVersionCommand = checkVersionCommand; _configService.SettingsChanged += _configService_SettingsChanged; UiDispatcher.Initialize(); }
public App(VBE vbe, IMessageBox messageBox, IRubberduckParser parser, IGeneralConfigService configService, IAppMenu appMenus, RubberduckCommandBar stateBar, IIndenter indenter, IRubberduckHooks hooks) { _vbe = vbe; _messageBox = messageBox; _parser = parser; _configService = configService; _autoSave = new AutoSave.AutoSave(_vbe, _configService); _appMenus = appMenus; _stateBar = stateBar; _indenter = indenter; _hooks = hooks; _logger = LogManager.GetCurrentClassLogger(); _hooks.MessageReceived += _hooks_MessageReceived; _configService.SettingsChanged += _configService_SettingsChanged; _configService.LanguageChanged += ConfigServiceLanguageChanged; _parser.State.StateChanged += Parser_StateChanged; _parser.State.StatusMessageUpdate += State_StatusMessageUpdate; _stateBar.Refresh += _stateBar_Refresh; var sink = new VBProjectsEventsSink(); var connectionPointContainer = (IConnectionPointContainer)_vbe.VBProjects; var interfaceId = typeof(_dispVBProjectsEvents).GUID; connectionPointContainer.FindConnectionPoint(ref interfaceId, out _projectsEventsConnectionPoint); sink.ProjectAdded += sink_ProjectAdded; sink.ProjectRemoved += sink_ProjectRemoved; sink.ProjectActivated += sink_ProjectActivated; sink.ProjectRenamed += sink_ProjectRenamed; _projectsEventsConnectionPoint.Advise(sink, out _projectsEventsCookie); UiDispatcher.Initialize(); }
public void Dispose() { if (_disposed) { return; } if (_sourceControlPanelVM != null) { _sourceControlPanelVM.OpenRepoStarted -= DisableSinkEventHandlers; _sourceControlPanelVM.OpenRepoCompleted -= EnableSinkEventHandlersAndUpdateCache; } if (_branchesVM != null) { _branchesVM.LoadingComponentsStarted -= DisableSinkEventHandlers; _branchesVM.LoadingComponentsCompleted -= EnableSinkEventHandlersAndUpdateCache; } _handleSinkEvents = false; if (_parser != null && _parser.State != null) { _parser.State.StateChanged -= Parser_StateChanged; _parser.State.StatusMessageUpdate -= State_StatusMessageUpdate; _parser.Dispose(); // I won't set this to null because other components may try to release things } if (_hooks != null) { _hooks.MessageReceived -= _hooks_MessageReceived; _hooks.Dispose(); _hooks = null; } if (_configService != null) { _configService.SettingsChanged -= _configService_SettingsChanged; _configService.LanguageChanged -= ConfigServiceLanguageChanged; _configService = null; } if (_stateBar != null) { _stateBar.Refresh -= _stateBar_Refresh; _stateBar.Dispose(); _stateBar = null; } if (_sink != null) { _sink.ProjectAdded -= sink_ProjectAdded; _sink.ProjectRemoved -= sink_ProjectRemoved; _sink.ProjectActivated -= sink_ProjectActivated; _sink.ProjectRenamed -= sink_ProjectRenamed; _sink = null; } foreach (var item in _componentsEventsSinks) { item.Value.ComponentActivated -= sink_ComponentActivated; item.Value.ComponentAdded -= sink_ComponentAdded; item.Value.ComponentReloaded -= sink_ComponentReloaded; item.Value.ComponentRemoved -= sink_ComponentRemoved; item.Value.ComponentRenamed -= sink_ComponentRenamed; item.Value.ComponentSelected -= sink_ComponentSelected; } if (_autoSave != null) { _autoSave.Dispose(); _autoSave = null; } _projectsEventsConnectionPoint.Unadvise(_projectsEventsCookie); foreach (var item in _componentsEventsConnectionPoints) { item.Value.Item1.Unadvise(item.Value.Item2); } foreach (var item in _referencesEventsConnectionPoints) { item.Value.Item1.Unadvise(item.Value.Item2); } UiDispatcher.Shutdown(); _disposed = true; }