/// <summary> /// Populate all controls on the view. /// </summary> private void PopulateView() { DisconnectViewEvents(); initialWaterView.PercentFull = Convert.ToInt32(initialWater.FractionFull * 100, CultureInfo.InvariantCulture); initialWaterView.PAW = (int)Math.Round(initialWater.PAW); if (double.IsNaN(initialWater.DepthWetSoil)) { initialWaterView.FilledByDepth = false; initialWaterView.DepthOfWetSoil = int.MinValue; } else { initialWaterView.FilledByDepth = true; initialWaterView.DepthOfWetSoil = (int)Math.Round(initialWater.DepthWetSoil / 10); // mm to cm } initialWaterView.FilledFromTop = initialWater.PercentMethod == InitialWater.PercentMethodEnum.FilledFromTop; initialWaterView.RelativeTo = initialWater.RelativeTo; if (initialWaterView.RelativeTo == string.Empty) { initialWaterView.RelativeTo = "LL15"; } ConnectViewEvents(); // Refresh the graph. if (graph != null) { graphPresenter.DrawGraph(); } }
/// <summary> /// Forces the equivalent graphs in each tab to use the same axes. /// ie. The LAI graphs in each simulation will have the same axes. /// </summary> private void StandardiseAxes() { // Loop over each graph. ie if each tab contains five // graphs, then loop over these five graphs. int graphsPerPage = panel.Cache.First().Value.Count; for (int i = 0; i < graphsPerPage; i++) { // Get all graph series for this graph from each simulation. // ie. get the data behind each lai graph in each simulation. List <SeriesDefinition> series = panel.Cache.Values.SelectMany(v => v[i]).ToList(); // Now draw all these series onto a single graph. GraphPresenter graphPresenter = new GraphPresenter(); GraphView graphView = new GraphView(view as ViewBase); presenter.ApsimXFile.Links.Resolve(graphPresenter); graphPresenter.Attach(graphs[0].Graphs[i].Graph, graphView, presenter); graphPresenter.DrawGraph(series); Axis[] axes = graphView.Axes.ToArray(); // This should always be length 2 foreach (GraphTab tab in graphs) { if (tab.Graphs[i].View != null) { FormatAxes(tab.Graphs[i].View, axes); } } } }