예제 #1
0
        /// <summary>
        /// Attach the view to this presenter and begin populating the view.
        /// </summary>
        /// <param name="model">The simulation model</param>
        /// <param name="view">The view used for display</param>
        /// <param name="explorerPresenter">The presenter for this object</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.CommandHistory = new CommandHistory();
            this.ApsimXFile     = model as Simulations;
            this.view           = view as IExplorerView;
            this.mainMenu       = new MainMenu(this);
            this.ContextMenu    = new ContextMenu(this);
            ApsimXFile.Links.Resolve(ContextMenu);

            this.view.Tree.SelectedNodeChanged += this.OnNodeSelected;
            this.view.Tree.DragStarted         += this.OnDragStart;
            this.view.Tree.AllowDrop           += this.OnAllowDrop;
            this.view.Tree.Droped  += this.OnDrop;
            this.view.Tree.Renamed += this.OnRename;

            Refresh();

            ApsimFileMetadata file = Configuration.Settings.GetMruFile(ApsimXFile.FileName);

            if (file != null && file.ExpandedNodes != null)
            {
                this.view.Tree.ExpandNodes(file.ExpandedNodes);
            }

            this.PopulateMainMenu();
        }
예제 #2
0
        /// <summary>
        /// Attach the view to this presenter and begin populating the view.
        /// </summary>
        /// <param name="model">The simulation model</param>
        /// <param name="view">The view used for display</param>
        /// <param name="explorerPresenter">The presenter for this object</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            // When the user undoes/redoes something we want to select the affected
            // model. Therefore we can use the same callback for both events.
            this.ApsimXFile     = model as Simulations;
            this.view           = view as IExplorerView;
            this.CommandHistory = new CommandHistory(this.view.Tree);
            this.mainMenu       = new MainMenu(this);
            this.ContextMenu    = new ContextMenu(this);
            ApsimXFile.Links.Resolve(ContextMenu);

            this.view.Tree.SelectedNodeChanged += this.OnNodeSelected;
            this.view.Tree.DragStarted         += this.OnDragStart;
            this.view.Tree.AllowDrop           += this.OnAllowDrop;
            this.view.Tree.Droped  += this.OnDrop;
            this.view.Tree.Renamed += this.OnRename;

            Populate();

            ApsimFileMetadata file = Configuration.Settings.GetMruFile(ApsimXFile.FileName);

            if (file != null && file.ExpandedNodes != null)
            {
                this.view.Tree.ExpandNodes(file.ExpandedNodes);
            }

            this.PopulateMainMenu();
        }