Пример #1
0
        /// <summary>Create a new tab.</summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="simulations">The simulations object to add to tab.</param>
        /// <param name="onLeftTabControl">If true a tab will be added to the left hand tab control.</param>
        private ExplorerPresenter CreateNewTab(string name, Simulations simulations, bool onLeftTabControl)
        {
            this.view.ShowMessage(" ", Simulation.ErrorLevel.Information); // Clear the message window
            ExplorerView      explorerView = new ExplorerView(null);
            ExplorerPresenter presenter    = new ExplorerPresenter(this);

            if (onLeftTabControl)
            {
                presenters1.Add(presenter);
            }
            else
            {
                presenters2.Add(presenter);
            }

            XmlDocument doc = new XmlDocument();

            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, new Gtk.Image(null, "ApsimNG.Resources.apsim logo32.png"), explorerView.MainWidget, onLeftTabControl);

            // restore the simulation tree width on the form
            if (simulations.ExplorerWidth == 0)
            {
                presenter.TreeWidth = 250;
            }
            else
            {
                presenter.TreeWidth = simulations.ExplorerWidth;
            }

            return(presenter);
        }
Пример #2
0
        /// <summary>Create a new tab.</summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="simulations">The simulations object to add to tab.</param>
        /// <param name="onLeftTabControl">If true a tab will be added to the left hand tab control.</param>
        private ExplorerPresenter CreateNewTab(string name, Simulations simulations, bool onLeftTabControl)
        {
            ExplorerView      explorerView = new ExplorerView();
            ExplorerPresenter presenter    = new ExplorerPresenter(this);

            if (onLeftTabControl)
            {
                presenters1.Add(presenter);
            }
            else
            {
                presenters2.Add(presenter);
            }

            XmlDocument doc = new XmlDocument();

            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, Properties.Resources.apsim_logo32, explorerView, onLeftTabControl);

            // restore the simulation tree width on the form
            if (simulations.ExplorerWidth == 0)
            {
                presenter.TreeWidth = 250;
            }
            else
            {
                presenter.TreeWidth = simulations.ExplorerWidth;
            }

            return(presenter);
        }
Пример #3
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="contents">The xml content</param>
        public void OpenApsimXFromMemoryInTab(string name, string contents)
        {
            ExplorerView      explorerView = new ExplorerView();
            ExplorerPresenter presenter    = new ExplorerPresenter();

            this.Presenters.Add(presenter);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(contents);
            Simulations simulations = Simulations.Read(doc.DocumentElement);

            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, Properties.Resources.apsim_logo32, explorerView, true);
        }
Пример #4
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="fileName">The file to open</param>
        public void OpenApsimXFileInTab(string fileName)
        {
            if (fileName != null)
            {
                ExplorerView      explorerView = new ExplorerView(this.view as ViewBase);
                ExplorerPresenter presenter    = new ExplorerPresenter();
                this.Presenters.Add(presenter);
                try
                {
                    this.view.WaitCursor = true;
                    try
                    {
                        Simulations simulations = Simulations.Read(fileName);
                        presenter.Attach(simulations, explorerView, null);
                        this.view.AddTab(fileName, "ApsimNG.Resources.apsim logo32.png", explorerView.MainWidget, true);

                        // restore the simulation tree width on the form
                        if (simulations.ExplorerWidth == 0)
                        {
                            presenter.TreeWidth = 250;
                        }
                        else
                        {
                            presenter.TreeWidth = Math.Min(simulations.ExplorerWidth, this.view.TabWidth - 20); // ?
                        }
                        Utility.Configuration.Settings.AddMruFile(fileName);
                        List <string> validMrus = new List <string>();                           // make sure recently used files still exist before displaying them
                        foreach (string s in Utility.Configuration.Settings.MruList)
                        {
                            if (File.Exists(s))
                            {
                                validMrus.Add(s);
                            }
                        }
                        Utility.Configuration.Settings.MruList = validMrus;
                        //this.view.FillMruList(validMrus);
                    }
                    finally
                    {
                        this.view.WaitCursor = false;
                    }
                }
                catch (Exception err)
                {
                    this.view.ShowError(err.Message);
                }
            }
        }
Пример #5
0
        /// <summary>Create a new tab.</summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="simulations">The simulations object to add to tab.</param>
        /// <param name="onLeftTabControl">If true a tab will be added to the left hand tab control.</param>
        private ExplorerPresenter CreateNewTab(string name, Simulations simulations, bool onLeftTabControl)
        {
            ExplorerView explorerView = new ExplorerView(null);
            ExplorerPresenter presenter = new ExplorerPresenter(this);
            if (onLeftTabControl)
                presenters1.Add(presenter);
            else
                presenters2.Add(presenter);

            XmlDocument doc = new XmlDocument();
            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, new Gtk.Image(null, "ApsimNG.Resources.apsim logo32.png"), explorerView.MainWidget, onLeftTabControl);

            // restore the simulation tree width on the form
            if (simulations.ExplorerWidth == 0)
                presenter.TreeWidth = 250;
            else
                presenter.TreeWidth = simulations.ExplorerWidth;

            return presenter;
        }
Пример #6
0
        public void MoveUpDown()
        {
            IExplorerView explorerView = new ExplorerView();
            ExplorerPresenter explorerPresenter = new ExplorerPresenter(null);
            CommandHistory commandHistory = new CommandHistory();

            explorerPresenter.Attach(simulations, explorerView, null);

            Model modelToMove = Apsim.Get(simulations, "APS14.Factors.NRate") as Model;

            MoveModelUpDownCommand moveCommand = new MoveModelUpDownCommand(modelToMove, true, explorerView);
            moveCommand.Do(commandHistory);

            Model modelToMove2 = Apsim.Get(simulations, "APS14.Factors.NRate") as Model;

            Assert.AreEqual(simulations.Children[2].Children[0].Children[0].Name, "NRate");
            Assert.AreEqual(simulations.Children[2].Children[0].Children[0].Children.Count, 4);
        }
Пример #7
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="name">Name of the simulation</param>
        /// <param name="contents">The xml content</param>
        public void OpenApsimXFromMemoryInTab(string name, string contents)
        {
            ExplorerView explorerView = new ExplorerView(this.view as ViewBase);
            ExplorerPresenter presenter = new ExplorerPresenter();
            this.Presenters.Add(presenter);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(contents);
            Simulations simulations = Simulations.Read(doc.DocumentElement);
            presenter.Attach(simulations, explorerView, null);

            this.view.AddTab(name, "ApsimNG.Resources.apsim logo32.png", explorerView.MainWidget, true);
        }
Пример #8
0
        /// <summary>
        /// Open an .apsimx file into the current tab.
        /// </summary>
        /// <param name="fileName">The file to open</param>
        public void OpenApsimXFileInTab(string fileName)
        {
            if (fileName != null)
            {
                ExplorerView explorerView = new ExplorerView(this.view as ViewBase);
                ExplorerPresenter presenter = new ExplorerPresenter();
                this.Presenters.Add(presenter);
                try
                {
                    this.view.WaitCursor = true;
                    try
                    {
                        Simulations simulations = Simulations.Read(fileName);
                        presenter.Attach(simulations, explorerView, null);
                        this.view.AddTab(fileName, "ApsimNG.Resources.apsim logo32.png", explorerView.MainWidget, true);

                        // restore the simulation tree width on the form
                        if (simulations.ExplorerWidth == 0)
                            presenter.TreeWidth = 250;
                        else
                            presenter.TreeWidth = Math.Min(simulations.ExplorerWidth, this.view.TabWidth - 20); // ?
                        Utility.Configuration.Settings.AddMruFile(fileName);
                        List<string> validMrus = new List<string>();                           // make sure recently used files still exist before displaying them
                        foreach (string s in Utility.Configuration.Settings.MruList)
                            if (File.Exists(s))
                                validMrus.Add(s);
                        Utility.Configuration.Settings.MruList = validMrus;
                        //this.view.FillMruList(validMrus);
                    }
                    finally
                    {
                        this.view.WaitCursor = false;
                    }
                }
                catch (Exception err)
                {
                    this.view.ShowError(err.Message);
                }
            }
        }