Example #1
0
        /// <summary>
        /// Attach the view
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The explorer</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model             = model as Model;
            this.genericView       = view as IMarkdownView;
            this.explorerPresenter = explorerPresenter;

            // Just how much documentation do we want to generate?
            // For now, let's just use the component name and a basic description.

            // It's slightly simpler to generate Markdown for this, but it
            // would be pretty easy to build this directly as HTML
            List <AutoDocumentation.ITag> tags = new List <AutoDocumentation.ITag>();

            AutoDocumentation.DocumentModel(this.model, tags, 1, 0, false, force: true);

            StringBuilder contents = new StringBuilder();

            foreach (AutoDocumentation.ITag tag in tags)
            {
                if (tag is AutoDocumentation.Heading heading)
                {
                    contents.AppendLine();
                    contents.Append($"### {heading.text}");
                }
                else if (tag is AutoDocumentation.Paragraph paragraph)
                {
                    contents.AppendLine();
                    contents.Append(paragraph.text);
                }
            }

            this.genericView.Text = contents.ToString();
        }
Example #2
0
 /// <summary>
 /// Attach the view
 /// </summary>
 /// <param name="model">The model</param>
 /// <param name="view">The view to attach</param>
 /// <param name="explorerPresenter">The explorer</param>
 public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
 {
     this.model             = model as Model;
     this.genericView       = view as IMarkdownView;
     this.explorerPresenter = explorerPresenter;
     System.IO.File.WriteAllText(Path.Combine(Path.GetDirectoryName(this.explorerPresenter.ApsimXFile.FileName), (model as ISpecificOutputFilename).HtmlOutputFilename), CreateHTML());
 }
Example #3
0
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.view      = view as IMarkdownView;
            this.model     = model as IModel;
            this.presenter = explorerPresenter;

            PopulateView();
        }
Example #4
0
        /// <summary>
        /// Attach the view
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The explorer</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model             = model as Model;
            this.genericView       = view as IMarkdownView;
            this.explorerPresenter = explorerPresenter;

            this.genericView.Text = CreateMarkdown();
        }
Example #5
0
        /// <summary>
        /// Attach the view
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The explorer</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model       = model as Model;
            this.genericView = view as IMarkdownView;
            explorer         = explorerPresenter;

            // save summary to disk when component is first pressed regardless of user slecting summary tab as now goes to html in browser
            System.IO.File.WriteAllText(Path.Combine(Path.GetDirectoryName(explorer.ApsimXFile.FileName), "CurrentDescriptiveSummary.html"), CreateHTML(this.model));
        }
Example #6
0
        /// <summary>Initializes a new instance of the <see cref="SummaryView"/> class.</summary>
        public SummaryView(ViewBase owner) : base(owner)
        {
            topBox = new HBox();
            SummaryCheckBox = new CheckBoxView(this);
            SummaryCheckBox.TextOfLabel = "Capture summary?";
            WarningCheckBox = new CheckBoxView(this);
            WarningCheckBox.TextOfLabel = "Capture warning messages?";
            ErrorCheckBox = new CheckBoxView(this);
            ErrorCheckBox.TextOfLabel = "Capture error messages?";
            topBox.PackStart(SummaryCheckBox.MainWidget, false, false, 10);
            topBox.PackStart(WarningCheckBox.MainWidget, false, false, 10);
            topBox.PackStart(ErrorCheckBox.MainWidget, false, false, 10);

            middleBox = new HBox();
            SimulationDropDown = new DropDownView(this);
            middleBox.PackStart(new Label("Simulation:"), false, false, 10);
            middleBox.PackStart(SimulationDropDown.MainWidget, true, true, 10);

            btnJumpToSimLog = new Button("Jump to simulation log");
            HBox buttonContainer = new HBox();
            buttonContainer.PackStart(btnJumpToSimLog, false, false, 0);
            btnJumpToSimLog.Clicked += OnJumpToSimulationLog;

            mainControl = new VBox();
            mainWidget = mainControl;
            mainControl.PackStart(topBox, false, false, 0);
            mainControl.PackStart(middleBox, false, false, 0);
            mainControl.PackStart(buttonContainer, false, false, 0);
            SummaryDisplay = new MarkdownView(this);
            Widget summaryWidget = ((ViewBase)SummaryDisplay).MainWidget as Widget;
            if (summaryWidget is Container container && container.Children != null && container.Children.Length == 1 && container.Children[0] is TextView editor)
            {
                // If possible, we want to generate a summary view which uses a single
                // TextView widget, which will allow for easy selection/searching/copying
                // of the entire text all at once. If we are using a single textview, we
                // want to add it directly to a ScrolledWindow; if we add it to another
                // container (e.g. Box) then add the Box to the container, some of the
                // TextView functionality (scroll_to_iter()) will not work.
                summaryWidget = new ScrolledWindow();
                editor.Reparent(summaryWidget);
                editor.WrapMode = WrapMode.None;
                (SummaryDisplay as MarkdownView).SetMainWidget(summaryWidget);
            }
            mainControl.PackEnd(summaryWidget, true, true, 0);

            mainWidget.Destroyed += MainWidgetDestroyed;
            mainWidget.ShowAll();
        }
        /// <summary>
        /// Attach the view
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="view">The view to attach</param>
        /// <param name="explorerPresenter">The explorer</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model       = model as Model;
            this.genericView = view as IMarkdownView;
            explorer         = explorerPresenter;

            // save summary to disk when component is first pressed regardless of user selecting summary tab as now goes to html in browser

            htmlFilePath   = "CurrentDescriptiveSummary.html";
            targetFilePath = "CurrentDescriptiveSummary.html";

            if (typeof(ISpecificOutputFilename).IsAssignableFrom(model.GetType()))
            {
                targetFilePath = (model as ISpecificOutputFilename).HtmlOutputFilename;
            }

            htmlFilePath   = Path.Combine(Path.GetDirectoryName(explorer.ApsimXFile.FileName), htmlFilePath);
            targetFilePath = Path.Combine(Path.GetDirectoryName(explorer.ApsimXFile.FileName), targetFilePath);
            System.IO.File.WriteAllText(htmlFilePath, CLEMModel.CreateDescriptiveSummaryHTML(this.model, Utility.Configuration.Settings.DarkTheme));
        }
Example #8
0
        /// <summary>Initializes a new instance of the <see cref="SummaryView"/> class.</summary>
        public SummaryView(ViewBase owner) : base(owner)
        {
            topBox                      = new HBox();
            SummaryCheckBox             = new CheckBoxView(this);
            SummaryCheckBox.TextOfLabel = "Capture summary?";
            WarningCheckBox             = new CheckBoxView(this);
            WarningCheckBox.TextOfLabel = "Capture warning messages?";
            ErrorCheckBox               = new CheckBoxView(this);
            ErrorCheckBox.TextOfLabel   = "Capture error messages?";
            topBox.PackStart(SummaryCheckBox.MainWidget, false, false, 10);
            topBox.PackStart(WarningCheckBox.MainWidget, false, false, 10);
            topBox.PackStart(ErrorCheckBox.MainWidget, false, false, 10);

            middleBox          = new HBox();
            SimulationDropDown = new DropDownView(this);
            middleBox.PackStart(new Label("Simulation:"), false, false, 10);
            middleBox.PackStart(SimulationDropDown.MainWidget, true, true, 10);

            btnJumpToSimLog = new Button("Jump to simulation log");
            HBox buttonContainer = new HBox();

            buttonContainer.PackStart(btnJumpToSimLog, false, false, 0);
            btnJumpToSimLog.Clicked += OnJumpToSimulationLog;

            mainControl = new VBox();
            mainWidget  = mainControl;
            mainControl.PackStart(topBox, false, false, 0);
            mainControl.PackStart(middleBox, false, false, 0);
            mainControl.PackStart(buttonContainer, false, false, 0);
            SummaryDisplay = new MarkdownView(this);
            ScrolledWindow scroller = new ScrolledWindow();

            scroller.Add(((ViewBase)SummaryDisplay).MainWidget);
            mainControl.PackEnd(scroller, true, true, 0);

            mainWidget.Destroyed += MainWidgetDestroyed;
            mainWidget.ShowAll();
        }
Example #9
0
 /// <summary>
 /// Attach the view
 /// </summary>
 /// <param name="model">The model</param>
 /// <param name="view">The view to attach</param>
 /// <param name="explorerPresenter">The explorer</param>
 public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
 {
     this.model       = model as Model;
     this.genericView = view as IMarkdownView;
 }