private UserControl switchView(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval, ArcSWAT.SWATUnitType unitType) { UserControl view = getView(scenario, modelType, interval, unitType); splitContainer1.Panel2.Controls.Clear(); splitContainer1.Panel2.Controls.Add(view); if (view is SubbasinView) { Map = (view as SubbasinView).Map; } else { Map = null; } _scenario = scenario; _modelType = modelType; _unitType = unitType; //change status updateStatus(view); return(view); }
private void removeView(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval, ArcSWAT.SWATUnitType unitType) { string key = getViewName(scenario, modelType, interval, unitType); if (_views.ContainsKey(key)) { _views.Remove(key); } }
public void update(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType) { foreach (TreeNode node in this.Nodes[0].Nodes) { if (node.Text.Equals(scenario.Name)) { AddScenarioResult(node, scenario, modelType); } } }
private void removeView(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval) { removeView(scenario, modelType, interval, ArcSWAT.SWATUnitType.WSHD); removeView(scenario, modelType, interval, ArcSWAT.SWATUnitType.HRU); removeView(scenario, modelType, interval, ArcSWAT.SWATUnitType.SUB); removeView(scenario, modelType, interval, ArcSWAT.SWATUnitType.RCH); removeView(scenario, modelType, interval, ArcSWAT.SWATUnitType.RES); _performanceViews.Clear(); }
/// <summary> /// This method may be called in another thread. /// </summary> /// <param name="scenNode"></param> /// <param name="scenario"></param> /// <param name="modelType"></param> private void AddScenarioResult(TreeNode scenNode, ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType) { if (InvokeRequired) { BeginInvoke(new addScenarioResultDelegate(AddScenarioResult), scenNode, scenario, modelType); } else { foreach (TreeNode n in scenNode.Nodes) { if (n.Text.Equals(modelType.ToString())) { scenNode.Nodes.Remove(n); //remove the existing one and then add to update its status. break; } } TreeNode modelTypeNode = null; for (int j = Convert.ToInt32(ArcSWAT.SWATResultIntervalType.MONTHLY); j <= Convert.ToInt32(ArcSWAT.SWATResultIntervalType.YEARLY); j++) { ArcSWAT.SWATResultIntervalType interval = (ArcSWAT.SWATResultIntervalType)j; ArcSWAT.ScenarioResult result = scenario.getModelResult(modelType, interval); if (result == null) { continue; } if (result.Status != ArcSWAT.ScenarioResultStatus.NORMAL) { continue; } if (modelTypeNode == null) { modelTypeNode = scenNode.Nodes.Add(modelType.ToString()); modelTypeNode.Tag = modelType; } TreeNode resultNode = modelTypeNode.Nodes.Add(interval.ToString()); resultNode.Tag = modelType; resultNode.Nodes.Add("Watershed").Tag = result; resultNode.Nodes.Add("HRU").Tag = result; resultNode.Nodes.Add("Subbasin").Tag = result; resultNode.Nodes.Add("Reach").Tag = result; if (result.Reservoirs.Count > 0) { resultNode.Nodes.Add("Reservoir").Tag = result; } resultNode.Nodes.Add("Difference").Tag = result; resultNode.Nodes.Add("Performance").Tag = result; } scenNode.ExpandAll(); } }
private PerformanceView getPerformanceView(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval) { string key = string.Format("{0}_{1}_{2}", scenario.Name, modelType, interval); if (!_performanceViews.ContainsKey(key)) { PerformanceView performanceView = new PerformanceView(); performanceView.Result = scenario.getModelResult(modelType, interval); performanceView.Dock = DockStyle.Fill; _performanceViews.Add(key, performanceView); } return(_performanceViews[key]); }
private void addNodes(TreeNode projectNode, ArcSWAT.Scenario s) { TreeNode scenNode = projectNode.Nodes.Add(s.Name); scenNode.Tag = s; if (s.hasResults) { for (int i = Convert.ToInt32(ArcSWAT.SWATModelType.SWAT_488); i <= Convert.ToInt32(ArcSWAT.SWATModelType.CanSWAT); i++) { ArcSWAT.SWATModelType modelType = (ArcSWAT.SWATModelType)i; AddScenarioResult(scenNode, s, modelType); } } }
private UserControl getView(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval, ArcSWAT.SWATUnitType unitType) { string key = getViewName(scenario, modelType, interval, unitType); if (!_views.ContainsKey(key)) { if (unitType == ArcSWAT.SWATUnitType.WSHD) { WatershedView view = new WatershedView(); view.Dock = DockStyle.Fill; view.setProjectScenario(_prj, scenario.getModelResult(modelType, interval)); view.onDataStatisticsChanged += (ss, ee) => { onDataStatisticsChanged(view); }; _views.Add(key, view); } else { SubbasinView view = new SubbasinView(); view.Dock = DockStyle.Fill; view.onMapTimeChanged += (ss, ee) => { onMapTimeChanged(view); }; view.onMapSelectionChanged += (ss, ee) => { onMapSelectionChanged(view); }; view.onDataStatisticsChanged += (ss, ee) => { onDataStatisticsChanged(view); }; view.setProjectScenario(_prj, scenario.getModelResult(modelType, interval), unitType); if (unitType == ArcSWAT.SWATUnitType.SUB) { view.onSwitch2HRU += (hru) => { SubbasinView hruview = switchView(_scenario, _modelType, interval, ArcSWAT.SWATUnitType.HRU) as SubbasinView; hruview.HRU = hru; } } ; _views.Add(key, view); } } return(_views[key]); }
private void updateScenarioView(ArcSWAT.Scenario scenario) { if (scenario == null) { splitContainer1.Panel2.Controls.Clear(); return; } ScenarioView view = new ScenarioView(); view.Scenario = scenario; view.Dock = DockStyle.Fill; view.onSimulationFinished += (ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval) => { removeView(scenario, modelType, interval); scenario.reReadResults(modelType, interval); projectTree1.update(scenario, modelType); }; splitContainer1.Panel2.Controls.Clear(); splitContainer1.Panel2.Controls.Add(view); updateStatus(view); Map = null; }
private string getViewName(ArcSWAT.Scenario scenario, ArcSWAT.SWATModelType modelType, ArcSWAT.SWATResultIntervalType interval, ArcSWAT.SWATUnitType unitType) { return(string.Format("{0}_{1}_{2}_{3}", scenario.Name, modelType, interval, unitType)); }