public static ctrl_TableList add_Jint_Stats_Row(this ctrl_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 void createGUI() { //this.add_LogViewer(); var columns = new List <string> { "ProcessName", "Id", "SessionId", "MainModule", "MainWindowTitle", "FileName", "WorkingDirectory", "Arguments" }; tableList = this.add_TableList("Processes"); Action refresh = () => { tableList.setDataTable(GetRunningProcesses()); }; tableList.afterSelect( (listViewItems) => { "Selected row(s) values:".debug(); foreach (var listViewItem in listViewItems) { listViewItem.values().showInLog(); } }); tableList.add_ContextMenu() .add_MenuItem("refresh", () => refresh()); tableList.insert_LogViewer(); refresh(); }
//TO MAP to groups above public static ctrl_TableList setWidthToContent(this ctrl_TableList tableList) { tableList.makeColumnWidthMatchCellWidth(); tableList.Resize += (e, s) => { tableList.makeColumnWidthMatchCellWidth(); }; tableList.getListViewControl().ColumnClick += (e, s) => { tableList.makeColumnWidthMatchCellWidth(); }; return(tableList); }
public static ctrl_TableList add_Column(this ctrl_TableList tableList, string columnName) { var listViewControl = tableList.getListViewControl(); listViewControl.invokeOnThread(() => listViewControl.Columns.Add(columnName)); return(tableList); }
public static ctrl_TableList add_Jint_Stats_Columns(this ctrl_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 ctrl_TableList clearRows(this ctrl_TableList tableList) { return((ctrl_TableList)tableList.invokeOnThread( () => { tableList.getListViewControl().Items.Clear(); return tableList; })); }
public static ctrl_TableList clearTable(this ctrl_TableList tableList) { var listViewControl = tableList.getListViewControl(); listViewControl.invokeOnThread(() => listViewControl.Clear()); return(tableList); }
public static ctrl_TableList resize(this ctrl_TableList tableList) { return((ctrl_TableList)tableList.invokeOnThread( () => { tableList.listView().AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); return tableList; })); }
public static ctrl_TableList sort(this ctrl_TableList tableList, SortOrder sortOrder) { return((ctrl_TableList)tableList.invokeOnThread( () => { tableList.listView().Sorting = sortOrder; return tableList; })); }
public static ctrl_TableList add_TableList(this Control control, string tableTitle) { return(control.invokeOnThread(() => { var tableList = new ctrl_TableList(); tableList._Title = tableTitle; tableList.Dock = DockStyle.Fill; control.Controls.Add(tableList); return tableList; })); }
public static ListViewItem row(this ctrl_TableList tableList, int rowIndex) { var rows = tableList.rows(); if (rowIndex < rows.size()) { return(rows[rowIndex]); } return(null); }
public static ctrl_TableList set_ColumnWidth(this ctrl_TableList tableList, int columnNumber, int width) { return((ctrl_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); //if (listView.Columns.size()>columnNumber) tableList.getListViewControl().Columns[columnNumber].Width = width; return tableList; })); }
public static ctrl_TableList selectFirst(this ctrl_TableList tableList) { return((ctrl_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); listView.SelectedIndices.Clear(); listView.SelectedIndices.Add(0); return tableList; })); }
public static T selected <T>(this ctrl_TableList tableList) { var tag = tableList.tag(); if (tag.notNull() && tag is T) { return((T)tag); } return(default(T)); }
public static ListViewItem selected(this ctrl_TableList tableList) { return((ListViewItem)tableList.invokeOnThread( () => { if (tableList.listView().SelectedItems.Count > 0) { return tableList.listView().SelectedItems[0]; } return null; })); }
public static ctrl_TableList afterSelect_get_RowIndex(this ctrl_TableList tableList, Action <int> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { O2Thread.mtaThread(() => callback(selectedRows[0].Index)); } }); return(tableList); }
public static ctrl_TableList set_ColumnAutoSizeForLastColumn(this ctrl_TableList tableList) { return((ctrl_TableList)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); if (listView.Columns.size() > 0) { listView.Columns[listView.Columns.size() - 1].Width = -2; } return tableList; })); }
public static object tag(this ctrl_TableList tableList) { return((object)tableList.invokeOnThread( () => { var selectedItem = tableList.selected(); if (selectedItem.notNull()) { return selectedItem.Tag; } return null; })); }
public static ListViewItem lastRow(this ctrl_TableList tableList) { return((ListViewItem)tableList.invokeOnThread( () => { var listView = tableList.listView(); if (listView.Items.size() > 0) { return listView.Items[listView.Items.size() - 1]; } return null; })); }
// ListViewItem public static List <ListViewItem> items(this ctrl_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 ctrl_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 ctrl_TableList show(this ctrl_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 ctrl_TableList onDoubleClick_get_Row(this ctrl_TableList tableList, Action <ListViewItem> callback) { tableList.invokeOnThread( () => { tableList.listView().DoubleClick += (sender, e) => { var selectedRow = tableList.selected(); if (selectedRow.notNull()) { O2Thread.mtaThread(() => callback(selectedRow)); } }; }); return(tableList); }
public static ctrl_TableList afterSelect <T>(this ctrl_TableList tableList, Action <T> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { var selectedRow = selectedRows[0]; if (selectedRow.Tag.notNull() && selectedRow.Tag is T) { O2Thread.mtaThread(() => callback((T)selectedRow.Tag)); } } }); return(tableList); }
public static ctrl_TableList afterSelect <T>(this ctrl_TableList tableList, List <T> items, Action <T> callback) { tableList.afterSelect( (selectedRows) => { if (selectedRows.size() == 1) { var index = selectedRows[0].Index; if (index < items.size()) { O2Thread.mtaThread(() => callback(items[index])); } } }); return(tableList); }
//Column(s) public static ctrl_TableList add_Columns(this ctrl_TableList tableList, List <string> columnNames) { return((ctrl_TableList)tableList.invokeOnThread( () => { ListView listView = tableList.getListViewControl(); listView.Columns.Clear(); listView.AllowColumnReorder = true; foreach (var columnName in columnNames) { listView.Columns.Add(columnName); } return tableList; })); }
public static ctrl_TableList set_ColumnsWidth(this ctrl_TableList tableList, bool lastColumnShouldAutoSize, params int[] widths) { return((ctrl_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 ctrl_TableList afterSelect_get_Cell(this ctrl_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) { O2Thread.mtaThread(() => callback(values[rowNumber])); } } }); return(tableList); }
public static ListViewItem add_ListViewItem(this ctrl_TableList tableList, List <string> rowData) { return((ListViewItem)tableList.invokeOnThread( () => { var listView = tableList.getListViewControl(); var listViewItem = new ListViewItem(); if (rowData.Count > 0) { 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); } return listViewItem; })); }
//events public static ctrl_TableList afterSelect(this ctrl_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); }