public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Open test.apsimx in a tab tabbedExplorerPresenter.OpenApsimXFileInTab(@"..\Tests\Test.apsimx"); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; // Select the field model. presenter.SelectNode(".Simulations.Test"); // Copy the simulation model. ContextMenu menu = new ContextMenu(presenter); menu.OnCopyClick(null, null); // Select the top model presenter.SelectNode(".Simulations"); // Paste the model. menu.OnPasteClick(null, null); // Make sure the paste has worked by clicking on a child. presenter.SelectNode(".Simulations.Test1.Clock"); // Make sure the parenting of children has worked correctly. Clock clock = Apsim.Get(presenter.ApsimXFile, ".Simulations.Test1.Clock") as Clock; if (clock.Parent == null) throw new Exception("Parenting of models after copy/paste hasn't worked"); // Close the user interface. tabbedExplorerPresenter.Close(false); }
public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Set the current working directory to the bin folder. string binFolder = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location); Directory.SetCurrentDirectory(binFolder); // Get the environment variable 'ModelName' string modelName = System.Environment.GetEnvironmentVariable("ModelName"); // Open wheat validation in a tab string fileName = Path.Combine(binFolder, @"..\Tests\" + modelName + @"\" + modelName + "Validation.apsimx"); tabbedExplorerPresenter.OpenApsimXFileInTab(fileName); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; presenter.SelectNode(".Simulations"); // Export the model to HTML string folderName = Path.Combine(binFolder, @"..\Documentation\PDF"); Directory.CreateDirectory(folderName); ExportNodeCommand command = new ExportNodeCommand(presenter, presenter.CurrentNodePath); command.Do(null); // Copy the file into the PDF directory. File.Copy(command.FileNameWritten, @"..\Documentation\PDF\" + modelName + ".pdf"); // Close the user interface. tabbedExplorerPresenter.Close(false); }
public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Open the standard toolbox in a tab tabbedExplorerPresenter.OnStandardToolboxClick(null, null); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; // Loop through all nodes in the standard toolbox and select each in turn. while (presenter.SelectNextNode()); // Close the user interface. tabbedExplorerPresenter.Close(); }