void updateParamSummary() { TextParamList textList = controlParams.getText(); TextBlock textBlock = new TextBlock(); string s; double rowHeight = 1.2 * textBlock.FontSize; double colWidth = 10 * rowHeight; int ncols = 2; int nlines = textList.getNLines(); int nrows = (int)Math.Ceiling((float)nlines / ncols); int coli = 0; int linei = 0; paramGrid.Children.Clear(); foreach (TextParam param in textList) { if (param.isHeader && linei > 0) { linei++; if (linei >= nrows) { coli++; linei = 0; } } s = param.name; if (param.value != "" || param.units != "") { s += "\t"; if (param.value != "") { s += param.value; } if (param.units != "") { s += " " + param.units; } } addParamText(s, coli * colWidth, linei * rowHeight, param.isHeader); linei++; if (linei >= nrows) { coli++; linei = 0; } } }
public void createReport(TextParamList inparams, string outparams) { double avgsize = Math.Sqrt(Width * Height); bool bold = false; bool boldEnded = false; int nlines = 0; int ncols = 3; int nrows = 0; double x, y; fontSize = 0.015 * avgsize; double rowSize = 1.6 * fontSize; double colSize = 8 * fontSize; if (inparams != null) { nlines = inparams.getNLines(); nrows = (int)Math.Ceiling((float)nlines / ncols); int coli = 0; int linei = 0; double colWidth = Width / ncols; foreach (TextParam param in inparams) { if (param.isHeader && linei > 0) { linei++; if (linei >= nrows) { coli++; linei = 0; } } x = coli * colWidth; y = linei * rowSize; addText(param.name, x, y, param.isHeader); x += colSize; addText(param.value, x, y); x += colSize; addText(param.units, x, y); linei++; if (linei >= nrows) { coli++; linei = 0; } } for (x = 1; x < ncols; x++) { addLine(x * colWidth, 0, x * colWidth, nrows * rowSize); } addLine(0, 0, Width, 0); addLine(0, nrows * rowSize, Width, nrows * rowSize); } if (outparams != "") { int row = nrows; int col = 0; string[] lines; string[] parts; string part; addText("Output parameters", 0, row * rowSize, true); row++; lines = outparams.Split('\n'); if (lines.Length > 0) { // set columns size by dividing total width over number of columns ncols = lines[0].Split('\t').Length; colSize = Width / ncols; } foreach (string line in lines) { parts = line.Split('\t'); foreach (string part0 in parts) { part = part0; if (part.StartsWith("<b>")) { bold = true; } else if (part.StartsWith("</b>")) { bold = false; } else if (part.EndsWith("</b>")) { boldEnded = true; } part = part.Replace("<b>", ""); part = part.Replace("</b>", ""); addText(part, col * colSize, row * rowSize, bold); if (boldEnded) { boldEnded = false; bold = false; } col++; } row++; col = 0; } } }