public void CreateDocumentation(object sender, EventArgs e) { if (this.explorerPresenter.Save()) { string destinationFolder = Path.Combine(Path.GetDirectoryName(this.explorerPresenter.ApsimXFile.FileName), "Doc"); if (destinationFolder != null) { explorerPresenter.MainPresenter.ShowMessage("Creating documentation...", Simulation.MessageType.Information); explorerPresenter.MainPresenter.ShowWaitCursor(true); try { ExportNodeCommand command = new ExportNodeCommand(this.explorerPresenter, this.explorerPresenter.CurrentNodePath); this.explorerPresenter.CommandHistory.Add(command, true); explorerPresenter.MainPresenter.ShowMessage("Finished creating documentation", Simulation.MessageType.Information); Process.Start(command.FileNameWritten); } catch (Exception err) { explorerPresenter.MainPresenter.ShowError(err); } finally { explorerPresenter.MainPresenter.ShowWaitCursor(false); } } } }
public void Execute(MainPresenter mainPresenter) { // 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\Validation\" + modelName + @"\" + modelName + ".apsimx"); if (File.Exists(fileName)) { mainPresenter.OpenApsimXFileInTab(fileName, true); // Get the presenter for this tab. ExplorerPresenter presenter = mainPresenter.presenters1[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. mainPresenter.Close(false); }
/// <summary>Exports the currently selected model to HTML.</summary> /// <param name="destinationFolder">The destination folder.</param> public void ExportToHTML(string destinationFolder) { Model modelClicked = Apsim.Get(this.explorerPresenter.ApsimXFile, this.explorerPresenter.CurrentNodePath) as Model; if (modelClicked != null) { if (modelClicked is Simulations) { ExportNodeCommand command = new ExportNodeCommand(this.explorerPresenter, this.explorerPresenter.CurrentNodePath, destinationFolder); this.explorerPresenter.CommandHistory.Add(command, true); } else { string fileName = Path.Combine(destinationFolder, modelClicked.Name + ".html"); Classes.PMFDocumentation.Go(fileName, modelClicked); } } }
public void CreateDocumentation(object sender, EventArgs e) { string destinationFolder = Path.Combine(Path.GetDirectoryName(this.explorerPresenter.ApsimXFile.FileName), "Doc"); if (destinationFolder != null) { explorerPresenter.ShowMessage("Creating documentation...", DataStore.ErrorLevel.Information); Cursor.Current = Cursors.WaitCursor; try { ExportNodeCommand command = new ExportNodeCommand(this.explorerPresenter, this.explorerPresenter.CurrentNodePath); this.explorerPresenter.CommandHistory.Add(command, true); explorerPresenter.ShowMessage("Finished creating documentation", DataStore.ErrorLevel.Information); Process.Start(command.FileNameWritten); } catch (Exception err) { explorerPresenter.ShowMessage(err.Message, DataStore.ErrorLevel.Error); } Cursor.Current = Cursors.Default; } }
private void Document(string fileName) { try { if (File.Exists(fileName)) { masterPresenter.OpenApsimXFileInTab(fileName, true); // Get the presenter for this tab. ExplorerPresenter presenter = masterPresenter.presenters1[0] as ExplorerPresenter; if (presenter != null) { presenter.SelectNode(".Simulations"); // Export the file to PDF 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. string outputFileName = Path.ChangeExtension(Path.Combine(folderName, Path.GetFileNameWithoutExtension(fileName)), ".pdf"); File.Move(command.FileNameWritten, outputFileName); } } else { throw new Exception(string.Format("Attempted to document file {0} but this file does not exist.", fileName)); } } finally { // Close the user interface. masterPresenter.Close(false); } }
public void CreateDocumentation(object sender, EventArgs e) { string destinationFolder = Path.Combine(Path.GetDirectoryName(this.explorerPresenter.ApsimXFile.FileName), "Doc"); if (destinationFolder != null) { explorerPresenter.MainPresenter.ShowMessage("Creating documentation...", DataStore.ErrorLevel.Information); explorerPresenter.MainPresenter.ShowWaitCursor(true); try { ExportNodeCommand command = new ExportNodeCommand(this.explorerPresenter, this.explorerPresenter.CurrentNodePath); this.explorerPresenter.CommandHistory.Add(command, true); explorerPresenter.MainPresenter.ShowMessage("Finished creating documentation", DataStore.ErrorLevel.Information); Process.Start(command.FileNameWritten); } catch (Exception err) { explorerPresenter.MainPresenter.ShowMessage(err.Message, DataStore.ErrorLevel.Error); } finally { explorerPresenter.MainPresenter.ShowWaitCursor(false); } } }