public void Render(ListView container, ConsoleDriver driver, bool selected, int item, int col, int line, int width) { List <DBRecord> records = new List <DBRecord>(currTable.records.Values); int hOffset = EditorProgram.columnHeaders.hOffset; if (hOffset > currTable.columns.Count) { hOffset = currTable.columns.Count - 1; } if (hOffset < 0) { hOffset = 0; } string dispStr = records[item].identifier.PadRight(ColumnHeaderControl.COLUMN_WIDTH); for (int i = hOffset; i < currTable.columns.Count; i++) { if (dispStr.Length + ColumnHeaderControl.COLUMN_WIDTH >= width) { break; } dispStr += StringHelper.LimitLength( RookDB.PrettyPrintFieldValue(records[item], i), ColumnHeaderControl.COLUMN_WIDTH, " .. ").PadRight(ColumnHeaderControl.COLUMN_WIDTH); } driver.AddStr(dispStr); }
public void Render(ListView container, ConsoleDriver driver, bool selected, int item, int col, int line, int width, int start = 0) { if (item >= notifyEventArgs.Count) { return; } var str = notifyEventArgs[item].ProgressEventType + " " + notifyEventArgs[item].Message; if (str.Length > width) { str = str.Substring(0, width); } else { str = str.PadRight(width, ' '); } _results.Move(col, line); driver.AddStr(str); }
public void Render(ListView container, ConsoleDriver driver, bool selected, int item, int col, int line, int width, int start = 0) { lock (lockList) { if (item >= consoleOutput.Count) { return; } var str = consoleOutput[item]; if (str.Length > width) { str = str.Substring(0, width); } else { str = str.PadRight(width, ' '); } _results.Move(col, line); driver.AddStr(str); } }
/// <summary> /// Renders the current <see cref="Model"/> on the specified line <paramref name="y"/> /// </summary> /// <param name="driver"></param> /// <param name="colorScheme"></param> /// <param name="y"></param> /// <param name="availableWidth"></param> public virtual void Draw(ConsoleDriver driver, ColorScheme colorScheme, int y, int availableWidth) { // true if the current line of the tree is the selected one and control has focus bool isSelected = tree.IsSelected(Model) && tree.HasFocus; Attribute lineColor = isSelected ? colorScheme.Focus : colorScheme.Normal; driver.SetAttribute(lineColor); // Everything on line before the expansion run and branch text Rune [] prefix = GetLinePrefix(driver).ToArray(); Rune expansion = GetExpandableSymbol(driver); string lineBody = tree.AspectGetter(Model) ?? ""; tree.Move(0, y); // if we have scrolled to the right then bits of the prefix will have dispeared off the screen int toSkip = tree.ScrollOffsetHorizontal; // Draw the line prefix (all paralell lanes or whitespace and an expand/collapse/leaf symbol) foreach (Rune r in prefix) { if (toSkip > 0) { toSkip--; } else { driver.AddRune(r); availableWidth -= Rune.ColumnWidth(r); } } // pick color for expanded symbol if (tree.Style.ColorExpandSymbol || tree.Style.InvertExpandSymbolColors) { Attribute color; if (tree.Style.ColorExpandSymbol) { color = isSelected ? tree.ColorScheme.HotFocus : tree.ColorScheme.HotNormal; } else { color = lineColor; } if (tree.Style.InvertExpandSymbolColors) { color = new Attribute(color.Background, color.Foreground); } driver.SetAttribute(color); } if (toSkip > 0) { toSkip--; } else { driver.AddRune(expansion); availableWidth -= Rune.ColumnWidth(expansion); } // horizontal scrolling has already skipped the prefix but now must also skip some of the line body if (toSkip > 0) { if (toSkip > lineBody.Length) { lineBody = ""; } else { lineBody = lineBody.Substring(toSkip); } } // If body of line is too long if (lineBody.Sum(l => Rune.ColumnWidth(l)) > availableWidth) { // remaining space is zero and truncate the line lineBody = new string (lineBody.TakeWhile(c => (availableWidth -= Rune.ColumnWidth(c)) >= 0).ToArray()); availableWidth = 0; } else { // line is short so remaining width will be whatever comes after the line body availableWidth -= lineBody.Length; } // default behaviour is for model to use the color scheme // of the tree view var modelColor = lineColor; // if custom color delegate invoke it if (tree.ColorGetter != null) { var modelScheme = tree.ColorGetter(Model); // if custom color scheme is defined for this Model if (modelScheme != null) { // use it modelColor = isSelected ? modelScheme.Focus : modelScheme.Normal; } } driver.SetAttribute(modelColor); driver.AddStr(lineBody); driver.SetAttribute(lineColor); if (availableWidth > 0) { driver.AddStr(new string (' ', availableWidth)); } driver.SetAttribute(colorScheme.Normal); }