public ComponentVE(ApsimFile.Component c) { name = c.Name; type = c.Type.ToLower(); XmlDocument doc = new XmlDocument(); doc.LoadXml(c.FullXMLNoShortCuts()); manager2script = XmlHelper.Value(doc.FirstChild, "text"); }
/// <summary> /// Refresh this report. This method will create a worker thread to animate the graphs. /// </summary> public override void OnRefresh() { // Refresh the base report. base.OnRefresh(); // Make sure play is selected by default. OnPlayClick(null, null); Quit = false; Forward = true; // Find our ApsimFile.Component class. We'll need this to get the XML we're // working with and to find all DateFilter components underneath this report. OurComponent = Controller.ApsimData.Find(NodePath); // Go create a DataProcessor object. We'll need this to find some data later. Doc = new XmlDocument(); Doc.LoadXml(OurComponent.FullXMLNoShortCuts()); DataProcessor Processor = new DataProcessor(); List <string> DefaultFileNames = new List <string>(); UIUtility.OutputFileUtility.GetOutputFiles(Controller, Controller.Selection, DefaultFileNames); Processor.DefaultOutputFileNames = DefaultFileNames; // Now go and try to find some data. We need data so that we can determine the // start and end period for the animation. DataTable PlotData = null; foreach (XmlNode Child in Doc.DocumentElement.ChildNodes) { PlotData = Processor.Go(Child, ""); if (PlotData != null) { break; } } // If some data was found then work out the start and end date periods, locate // all child DataFilter nodes, and create a worker thread for the animation. if (PlotData != null && PlotData.Rows.Count > 0) { StartDate = DataTableUtility.GetDateFromRow(PlotData.Rows[0]); EndDate = DataTableUtility.GetDateFromRow(PlotData.Rows[PlotData.Rows.Count - 1]); Period = EndDate - StartDate; CurrentDate = StartDate; // Go find all DateFilter components - we'll need them later. DateFilterNodes = new List <ApsimFile.Component>(); FindAllRecursively(OurComponent, "DateFilter", ref DateFilterNodes); WorkerThread = new Thread(DoAnimation); WorkerThread.Start(); } }
/// <summary> /// First time the UI is created - find our parent soil. /// </summary> protected override void OnLoad() { // We need not just the XML for this profile node but the whole soil XML. OurComponent = Controller.ApsimData.Find(NodePath); ApsimFile.Component SoilComponent = OurComponent; panel1.Visible = SoilComponent.Type.ToLower() == "soil"; while (SoilComponent.Type.ToLower() != "soil" && SoilComponent.Parent != null) { SoilComponent = SoilComponent.Parent; } if (SoilComponent.Type != "Soil") { throw new Exception("Cannot find soil object"); } Soil = Soil.Create(SoilComponent.FullXMLNoShortCuts()); CalledFromProfileUI = false; }