private void loadTableData(Dictionary<int, IXPathNavigable> xmlData, int displayFormat) { if (xmlData == null) return; //no data, dont try to populate the form //Clean up all panels this.flowLayoutPanel.Controls.Clear(); this.expandedGraphTab.Controls.Clear(); DataTable tempTable = null; foreach (int key in xmlData.Keys) { tempTable = new DataTable(); //Get data in DataTable format bool isColumnBuilt = false; List<String> attrValues = null; XPathNavigator firstDataSet = xmlData[key].CreateNavigator(); XPathNodeIterator dataNodes = firstDataSet.Select("//DataSet"); foreach (XPathNavigator dataNav in dataNodes) { attrValues = new List<String>(); XPathNodeIterator parameterNodes = dataNav.SelectDescendants(XPathNodeType.Element, false); foreach (XPathNavigator parameter in parameterNodes) { if (parameter.Name.CompareTo("Data") != 0) continue; if (!isColumnBuilt) { String name = parameter.GetAttribute("Name", parameter.NamespaceURI); if (!tempTable.Columns.Contains(name)) tempTable.Columns.Add(name); } String value = parameter.GetAttribute("Value", parameter.NamespaceURI); attrValues.Add(value); } isColumnBuilt = true; tempTable.Rows.Add(attrValues.ToArray()); } this.tData.Add(key, tempTable); } if (displayFormat == AssessmentToolbar.SHOWTABLE) { if (this.tData.Count == 1) { foreach (DataTable t in this.tData.Values) this.runRawData.DataSource = t; //there will be only one this.graphDataButton.Enabled = true; this.lowestTabSelected = RAWDATAPANEL; } else { String message = "Attempt to display data in the table form for multiple SimRuns"; MessageBox.Show(message, "Aptima Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.Error(message); } } else if (displayFormat == AssessmentToolbar.SHOWGRAPH) { AssessmentGraphSetupForm form = new AssessmentGraphSetupForm(this.tData); form.GraphViewDataCallback = new GME.Views.Forms.AssessmentGraphSetupForm.GraphViewDataDelegate(this.GraphViewDataCallbackFn); form.Show(); if (form.AcceptButton.DialogResult == DialogResult.OK) { if (this.tData.Count == 1) { foreach (DataTable t in this.tData.Values) this.runRawData.DataSource = t; //there will be only one this.backButton.Enabled = true; this.lowestTabSelected = RAWDATAPANEL; } else { this.runRawData.DataSource = null; this.backButton.Enabled = false; this.lowestTabSelected = SMALLGRAPHPANEL; } this.resultsTabControl.SelectTab(SMALLGRAPHPANEL); } } else { logger.Error("'displayFormat' parameter of AssessmentResultsPanel.loadTableData(...) " + "method is neither AssessmentToolbar.SHOWTABLE nor AssessmentToolbar.SHOWTABLE"); } }
private void graphDataButton_Click(object sender, EventArgs e) { AssessmentGraphSetupForm form = new AssessmentGraphSetupForm(this.tData); form.GraphViewDataCallback = new GME.Views.Forms.AssessmentGraphSetupForm.GraphViewDataDelegate(this.GraphViewDataCallbackFn); form.Show(); }