Ejemplo n.º 1
0
        public void BindController(ProjectExplorerPresenter controller)
        {
            if (_controller == controller)
            {
                return;
            }

            if (_controller != null)
            {
                _controller.ProjectReset          -= ProjectResetHandler;
                _controller.DefaultLibraryChanged -= DefaultLibraryChangedHandler;

                _controller.LibraryAdded    -= LibraryAddedHandler;
                _controller.LibraryRemoved  -= LibraryRemovedHandler;
                _controller.LibraryModified -= LibraryModifiedHandler;

                foreach (var component in ComponentManager.RegisteredInstances)
                {
                    BindingHelper.TryBindAny(component, _controller.Components.Select(c => new KeyValuePair <Type, object>(c.Key, null)));
                }
            }

            _controller = controller;

            if (_controller != null)
            {
                _commandController.BindCommandManager(_controller.CommandManager);

                _controller.ProjectReset          += ProjectResetHandler;
                _controller.DefaultLibraryChanged += DefaultLibraryChangedHandler;

                _controller.LibraryAdded    += LibraryAddedHandler;
                _controller.LibraryRemoved  += LibraryRemovedHandler;
                _controller.LibraryModified += LibraryModifiedHandler;

                _rootNode.Tag    = _controller.ProjectManagerTag;
                _libraryRoot.Tag = _controller.LibraryManagerTag;

                foreach (var component in ComponentManager.RegisteredInstances)
                {
                    BindingHelper.TryBindAny(component, _controller.Components.Select(c => new KeyValuePair <Type, object>(c.Key, c.Value)));
                }

                SyncAll();
            }
            else
            {
                _commandController.BindCommandManager(null);

                ResetComponent();
            }
        }
Ejemplo n.º 2
0
        public PresenterManager InitializePresenterManager()
        {
            PresenterManager pm = new PresenterManager();

            foreach (var presenter in _presenters)
            {
                pm.Register(presenter.Value.Initialize(pm));
            }

            // Populate project explorer components
            ProjectExplorerPresenter projectExplorer = pm.Lookup <ProjectExplorerPresenter>();

            if (projectExplorer != null)
            {
                foreach (var component in _projectExplorerComponents)
                {
                    BindingHelper.TryBindAny(component.Value, pm.Select(c => new KeyValuePair <Type, object>(c.Key, c.Value)));
                    projectExplorer.Components.Register(component.Value);
                }
            }

            return(pm);
        }