public void DetachFromEnvironment(IWorkingEnvironment environment) { Verify.Argument.IsNotNull(environment, "environment"); Verify.Argument.AreNotEqual(_environment, environment, "environment", string.Empty); foreach (var factory in _viewFactories) { factory.CloseAllViews(); environment.ViewDockService.UnregisterFactory(factory); } environment.RemoveRepositoryExplorerItem(_explorer.RootItem); environment.RemoveToolbar(_mainToolbar); for (int i = 0; i < _statusbar.LeftAlignedItems.Length; ++i) { environment.RemoveStatusBarObject(_statusbar.LeftAlignedItems[i]); } for (int i = 0; i < _statusbar.RightAlignedItems.Length; ++i) { environment.RemoveStatusBarObject(_statusbar.RightAlignedItems[i]); } foreach (var menu in _menus.Menus) { environment.RemoveMainMenuItem(menu); } foreach (var item in _menus.ViewMenuItems) { environment.RemoveViewMenuItem(item); } _explorer = null; _environment = null; }
public void AttachToEnvironment(IWorkingEnvironment environment) { Verify.Argument.IsNotNull(environment, "environment"); Verify.State.IsTrue(_environment == null); _environment = environment; _explorer = new RepositoryExplorer(this); foreach (var factory in _viewFactories) { environment.ViewDockService.RegisterFactory(factory); } environment.ProvideRepositoryExplorerItem(_explorer.RootItem); environment.ProvideToolbar(_mainToolbar); for (int i = 0; i < _statusbar.LeftAlignedItems.Length; ++i) { environment.ProvideStatusBarObject(_statusbar.LeftAlignedItems[i], true); } for (int i = 0; i < _statusbar.RightAlignedItems.Length; ++i) { environment.ProvideStatusBarObject(_statusbar.RightAlignedItems[i], false); } foreach (var menu in _menus.Menus) { environment.ProvideMainMenuItem(menu); } foreach (var item in _menus.ViewMenuItems) { environment.ProvideViewMenuItem(item); } ActivateDefaultView(); }