The ProjectPresenter handles presentation of the project as a set of properties, which the ProjectView is expected to display.
Esempio n. 1
0
        public MainPresenter(IProjectDocument doc, IMainView view)
        {
            this.doc  = doc;
            this.view = view;

            // Set up property editor triad
            ProjectModel  project      = new ProjectModel(doc);
            IPropertyView propertyView = view.PropertyView;

            this.propertyPresenter = new PropertyPresenter(project, propertyView);

            // Set up XML editor triad
            IXmlView xmlView = view.XmlView;

            this.xmlPresenter = new XmlPresenter(doc, xmlView);

            // Enable and disable menu items
            view.NewProjectCommand.Enabled    = true;
            view.OpenProjectCommand.Enabled   = true;
            view.CloseProjectCommand.Enabled  = false;
            view.SaveProjectCommand.Enabled   = false;
            view.SaveProjectAsCommand.Enabled = false;

            // Set up handlers for view events
            view.FormClosing += OnFormClosing;

            view.NewProjectCommand.Execute    += CreateNewProject;
            view.OpenProjectCommand.Execute   += OpenProject;
            view.SaveProjectCommand.Execute   += SaveProject;
            view.SaveProjectAsCommand.Execute += SaveProjectAs;
            view.CloseProjectCommand.Execute  += CloseProject;
            view.ActiveViewChanging           += this.ValidateActiveViewChange;
            view.ActiveViewChanged            += this.ActiveViewChanged;

            // Set up handlers for model events
            doc.ProjectCreated += OnProjectCreated;
            doc.ProjectClosed  += OnProjectClosed;
        }
        public MainPresenter(IProjectDocument doc, IMainView view)
        {
            this.doc = doc;
            this.view = view;

            // Set up property editor triad
            ProjectModel project = new ProjectModel(doc);
            IPropertyView propertyView = view.PropertyView;
            this.propertyPresenter = new PropertyPresenter(project, propertyView);

            // Set up XML editor triad
            IXmlView xmlView = view.XmlView;
            this.xmlPresenter = new XmlPresenter(doc, xmlView);

            // Enable and disable menu items
            view.NewProjectCommand.Enabled = true;
            view.OpenProjectCommand.Enabled = true;
            view.CloseProjectCommand.Enabled = false;
            view.SaveProjectCommand.Enabled = false;
            view.SaveProjectAsCommand.Enabled = false;

            // Set up handlers for view events
            view.FormClosing += OnFormClosing;

            view.NewProjectCommand.Execute += CreateNewProject;
            view.OpenProjectCommand.Execute += OpenProject;
            view.SaveProjectCommand.Execute += SaveProject;
            view.SaveProjectAsCommand.Execute += SaveProjectAs;
            view.CloseProjectCommand.Execute += CloseProject;
            view.ActiveViewChanging += this.ValidateActiveViewChange;
            view.ActiveViewChanged += this.ActiveViewChanged;

            // Set up handlers for model events
            doc.ProjectCreated += OnProjectCreated;
            doc.ProjectClosed += OnProjectClosed;
        }