public void TogglePinColumnToLeft(int col) { int pinnedCount = GetPinnedColumns(); QueryColumnInfo info = query.columns[col]; info.pinned = !info.pinned; int pos = 0; for (int i = 0; i < Columns.Count - 1; i++) { if (query.columns[i].pinned) { Columns[i].DisplayIndex = pos++; } } for (int i = 0; i < Columns.Count - 1; i++) { if (!query.columns[i].pinned) { Columns[i].DisplayIndex = pos++; } } Invalidate(); Update(); }
private void resultsMenu_Opening(object sender, CancelEventArgs e) { resultsList.GetMousePosition(); bool fit = false; bool fitEnabled = false; pinToLeftToolStripMenuItem.Checked = false; pinToLeftToolStripMenuItem.Enabled = false; if (resultsList.colUnderMouse >= 0) { QueryColumnInfo columnInfo = selectedQuery.columns[resultsList.colUnderMouse]; fitEnabled = fit = columnInfo.fitData; if (columnInfo.pinned) { pinToLeftToolStripMenuItem.Checked = true; } pinToLeftToolStripMenuItem.Enabled = pinToLeftToolStripMenuItem.Checked || resultsList.GetPinnedColumns() > 0 || resultsList.colUnderMouse > 0; if (resultsList.ColumnDataTruncated(resultsList.colUnderMouse)) { fitEnabled = true; } } fitDataInColumnToolStripMenuItem.Checked = fit; fitDataInColumnToolStripMenuItem.Enabled = fitEnabled; copyRowsToolStripMenuItem.Enabled = resultsList.SelectedIndices.Count > 0; }
public void FitDataInColumn(int col, bool toggle = false) { if (query != null && col > 0 && col < query.columns.Count) { QueryColumnInfo columnInfo = query.columns[col]; columnInfo.fitData = (toggle && columnInfo.fitData) ? false : true; Columns[col].Width = columnInfo.fitData ? Math.Max(columnInfo.defaultWidth, FormsToolbox.GetTextWidth(Math.Min(100, columnInfo.maxLength), Font)) : columnInfo.width; Invalidate(true); } }
public void AddColumn(QueryColumnInfo i) { columns.Add(i); }
string RenderValue(string s, QueryColumnInfo info) { bool putInQuotes = false; if (includeNulls && s == null) { s = "null"; } else { if (s == null) { s = ""; } if (removeTime && info.dataType == typeof(DateTime)) { int at = s.IndexOf(" "); if (at > 0) { s = s.Substring(0, at); } } if (removeNonAscii) { s = Regex.Replace(s, @"[^\u0000-\u007F]+", string.Empty); } if (removeNewLines) { s = s.Replace("\r\n", " "); s = s.Replace("\n", " "); s = s.Replace("\r", " "); } if (removeManySpaces) { s = s.Replace(" ", " "); } if (escapeWhenNecessary) { // https://www.csvreader.com/csv_format.php s = s.Replace("\"", "\"\""); if (s.Contains(",")) { putInQuotes = true; } if (s.Contains("\n")) { putInQuotes = true; } } if (info.dataType == typeof(string)) { if (putStringColumnsInDoubleQuotes) { putInQuotes = true; } if (putStringColumnsInDoubleQuotes) { putInQuotes = true; } } if (padStrings) { s = s.PadRight(info.maxLength); } if (putInQuotes) { s = quoteChar + s + quoteChar; } } if (format.IsOneOf("JSON Array", "JSON Object")) { s = QObject.GetValueForJson(info.dataType, s); if (format == "JSON Object") { s = "\"" + info.label + "\":" + s; } } else if (format == "SQL Insert") { s = QObject.GetValueForSql(info.dataType, s); } else if (format == "C# Object" || format == "C# Array") { s = QObject.GetValueForCSharp(info.dataType, s); if (format == "C# Object") { s = info.label + " = " + s; } } if (columnTemplate != "") { Template t = new Template(columnTemplate); t.SetToken("COLUMN", s); s = t.Render(); } return(s); }