public static ascx_TableList setWidthToContent(this ascx_TableList tableList) { tableList.makeColumnWidthMatchCellWidth(); tableList.Resize += (e, s) => { tableList.makeColumnWidthMatchCellWidth(); }; tableList.getListViewControl().ColumnClick += (e, s) => { tableList.makeColumnWidthMatchCellWidth(); }; return(tableList); }
public static ascx_TableList add_Jint_Stats_Row(this ascx_TableList tableList, int index, string url, string html, HtmlAgilityPack.HtmlDocument htmlDocument, List <KeyValuePair <string, string> > javaScripts) { var links = htmlDocument.select("//a"); var images = htmlDocument.select("//img"); var forms = htmlDocument.select("//form"); var allJavaScriptsCompileOk = javaScripts.allJavaScriptsCompileOk(); var allJavaScriptCompiledAst = javaScripts.jint_Compile(); var sizeOfJointJavaScripts = javaScripts.getStringWithJointJavascripts().size(); //var scripts = htmlDocument.select("//script"); tableList.add_Row( "{0:00}".format(index), //(mapped++).str(), url, "{0:000}".format(links.size()), "{0:000}".format(images.size()), "{0:000}".format(forms.size()), "{0:000}".format(javaScripts.size()), allJavaScriptsCompileOk.str(), "{0:0000}".format(allJavaScriptCompiledAst.functions().size()), "{0:0000}".format(allJavaScriptCompiledAst.values().size()), sizeOfJointJavaScripts.kBytesStr(), javaScripts.totalValueSize().kBytesStr(), html.size().kBytesStr() ); tableList.lastRow().textColor((allJavaScriptsCompileOk) ? Color.DarkGreen : Color.DarkRed); return(tableList); }
public static ascx_TableList add_Column(this ascx_TableList tableList, string columnName) { var listViewControl = tableList.getListViewControl(); listViewControl.invokeOnThread(() => listViewControl.Columns.Add(columnName)); return(tableList); }
public static ascx_TableList clearTable(this ascx_TableList tableList) { var listViewControl = tableList.getListViewControl(); listViewControl.invokeOnThread(() => listViewControl.Clear()); return(tableList); }
public static ascx_TableList clearRows(this ascx_TableList tableList) { return((ascx_TableList)tableList.invokeOnThread( () => { tableList.getListViewControl().Items.Clear(); return tableList; })); }
public static ascx_TableList add_Jint_Stats_Columns(this ascx_TableList tableList) { var columnsNames = new string[] { "pos", "url", "# links", "# images", "# forms", "# js", "# all js ok", "# js functions", "# js values", "analyzed js size", "original js size", "html size" }; tableList.add_Columns(columnsNames) .height(tableList.height() - 1); // this will reset the columns widths return(tableList); }
public static ascx_TableList resize(this ascx_TableList tableList) { return((ascx_TableList)tableList.invokeOnThread( () => { tableList.listView().AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); return tableList; })); }
public static ascx_TableList selectFirst(this ascx_TableList tableList) { return((ascx_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); listView.SelectedIndices.Clear(); listView.SelectedIndices.Add(0); return tableList; })); }
public static T selected <T>(this ascx_TableList tableList) { var tag = tableList.tag(); if (tag.notNull() && tag is T) { return((T)tag); } return(default(T)); }
public static ascx_TableList set_ColumnWidth(this ascx_TableList tableList, int columnNumber, int width) { return((ascx_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); //if (listView.Columns.size()>columnNumber) tableList.getListViewControl().Columns[columnNumber].Width = width; return tableList; })); }
public static ListViewItem row(this ascx_TableList tableList, int rowIndex) { var rows = tableList.rows(); if (rowIndex < rows.size()) { return(rows[rowIndex]); } return(null); }
public static ascx_TableList afterSelect_get_RowIndex(this ascx_TableList tableList, Action <int> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { callback(selectedRows[0].Index); } }); return(tableList); }
public static ascx_TableList afterSelect_get_Row(this ascx_TableList tableList, Action <ListViewItem> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { callback(selectedRows[0]); } }); return(tableList); }
public static ListViewItem selected(this ascx_TableList tableList) { return((ListViewItem)tableList.invokeOnThread( () => { if (tableList.listView().SelectedItems.Count > 0) { return tableList.listView().SelectedItems[0]; } return null; })); }
public static object tag(this ascx_TableList tableList) { return((object)tableList.invokeOnThread( () => { var selectedItem = tableList.selected(); if (selectedItem.notNull()) { return selectedItem.Tag; } return null; })); }
public static ascx_TableList set_ColumnAutoSizeForLastColumn(this ascx_TableList tableList) { return((ascx_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); if (listView.Columns.size() > 0) { listView.Columns[listView.Columns.size() - 1].Width = -2; } return tableList; })); }
public static ascx_TableList add_TableList(this Control control, string tableTitle) { return((ascx_TableList)control.invokeOnThread( () => { var tableList = new ascx_TableList(); tableList._Title = tableTitle; tableList.Dock = DockStyle.Fill; control.Controls.Add(tableList); return tableList; })); }
public static ListViewItem lastRow(this ascx_TableList tableList) { return((ListViewItem)tableList.invokeOnThread( () => { var listView = tableList.listView(); if (listView.Items.size() > 0) { return listView.Items[listView.Items.size() - 1]; } return null; })); }
public static List <ListViewItem> items(this ascx_TableList tableList) { return((List <ListViewItem>)tableList.invokeOnThread( () => { var items = new List <ListViewItem>(); foreach (ListViewItem item in tableList.getListViewControl().Items) { items.Add(item); } return items; })); }
public static List <List <String> > values(this ascx_TableList tableList) { return((List <List <String> >)tableList.invokeOnThread( () => { var values = new List <List <String> >(); foreach (var row in tableList.rows()) { values.Add(row.values()); } return values; })); }
public static void add_Columns(this ascx_TableList tableList, List <string> columnNames) { tableList.invokeOnThread( () => { ListView listView = tableList.getListViewControl(); listView.Columns.Clear(); listView.AllowColumnReorder = true; foreach (var columnName in columnNames) { listView.Columns.Add(columnName); } }); }
public static ascx_TableList afterSelect <T>(this ascx_TableList tableList, Action <T> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { var selectedRow = selectedRows[0]; if (selectedRow.Tag.notNull() && selectedRow.Tag is T) { callback((T)selectedRow.Tag); } } }); return(tableList); }
public static ascx_TableList onDoubleClick_get_Row(this ascx_TableList tableList, Action <ListViewItem> callback) { tableList.invokeOnThread( () => { tableList.listView().DoubleClick += (sender, e) => { var selectedRow = tableList.selected(); if (selectedRow.notNull()) { callback(selectedRow); } }; }); return(tableList); }
public static ascx_TableList show(this ascx_TableList tableList, object targetObject) { if (tableList.notNull() && targetObject.notNull()) { tableList.clearTable(); tableList.title("{0}".format(targetObject.typeFullName())); tableList.add_Columns("name", "value"); foreach (var property in PublicDI.reflection.getProperties(targetObject)) { tableList.add_Row(property.Name, targetObject.prop(property.Name).str()); } tableList.makeColumnWidthMatchCellWidth(); } return(tableList); }
public static ascx_TableList afterSelect <T>(this ascx_TableList tableList, List <T> items, Action <T> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { var index = selectedRows[0].Index; if (index < items.size()) { callback(items[index]); } } }); return(tableList); }
public static void add_Row(this ascx_TableList tableList, List <string> rowData) { tableList.invokeOnThread( () => { if (rowData.Count > 0) { var listView = tableList.getListViewControl(); var listViewItem = new ListViewItem(); listViewItem.Text = rowData[0]; // hack because SubItems starts adding on the 2nd Column :( rowData.RemoveAt(0); listViewItem.SubItems.AddRange(rowData.ToArray()); listView.Items.Add(listViewItem); } }); }
public static ascx_TableList set_ColumnsWidth(this ascx_TableList tableList, bool lastColumnShouldAutoSize, params int[] widths) { return((ascx_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); for (var i = 0; i < widths.Length; i++) { listView.Columns[i].Width = widths[i]; } if (lastColumnShouldAutoSize) { tableList.set_ColumnAutoSizeForLastColumn(); } return tableList.set_ColumnAutoSizeForLastColumn(); })); }
public static ascx_TableList afterSelect_get_Cell(this ascx_TableList tableList, int rowNumber, Action <string> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { var selectedRow = selectedRows[0]; var values = selectedRow.values(); if (values.size() > rowNumber) { callback(values[rowNumber]); } } }); return(tableList); }
public static ascx_TableList afterSelect(this ascx_TableList tableList, Action <List <ListViewItem> > callback) { tableList.getListViewControl().SelectedIndexChanged += (sender, e) => { if (callback.notNull()) { var selectedItems = new List <ListViewItem>(); foreach (ListViewItem item in tableList.getListViewControl().SelectedItems) { selectedItems.Add(item); } callback(selectedItems); } }; return(tableList); }
//very similar to the code in add_Row (prob with that one is that it doens't return the new ListViewItem object public static ascx_TableList add_Row <T>(this ascx_TableList tableList, T _objectToAdd, Func <List <string> > getRowData) { return((ascx_TableList)tableList.invokeOnThread( () => { var rowData = getRowData(); if (rowData.Count > 0) { var listView = tableList.getListViewControl(); var listViewItem = new ListViewItem(); listViewItem.Text = rowData[0]; // hack because SubItems starts adding on the 2nd Column :( rowData.RemoveAt(0); listViewItem.SubItems.AddRange(rowData.ToArray()); listView.Items.Add(listViewItem); listViewItem.Tag = _objectToAdd; // only difference with main add_Row } return tableList; })); }