Exemplo n.º 1
0
 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);
        }
Exemplo n.º 3
0
        public static ascx_TableList add_Column(this ascx_TableList tableList, string columnName)
        {
            var listViewControl = tableList.getListViewControl();

            listViewControl.invokeOnThread(() => listViewControl.Columns.Add(columnName));

            return(tableList);
        }
Exemplo n.º 4
0
        public static ascx_TableList clearTable(this ascx_TableList tableList)
        {
            var listViewControl = tableList.getListViewControl();

            listViewControl.invokeOnThread(() => listViewControl.Clear());

            return(tableList);
        }
Exemplo n.º 5
0
 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);
        }
Exemplo n.º 7
0
 public static ascx_TableList resize(this ascx_TableList tableList)
 {
     return((ascx_TableList)tableList.invokeOnThread(
                () =>
     {
         tableList.listView().AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
         return tableList;
     }));
 }
Exemplo n.º 8
0
 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;
     }));
 }
Exemplo n.º 9
0
        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));
        }
Exemplo n.º 10
0
 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;
     }));
 }
Exemplo n.º 11
0
        public static ListViewItem row(this ascx_TableList tableList, int rowIndex)
        {
            var rows = tableList.rows();

            if (rowIndex < rows.size())
            {
                return(rows[rowIndex]);
            }
            return(null);
        }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 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;
     }));
 }
Exemplo n.º 15
0
 public static object tag(this ascx_TableList tableList)
 {
     return((object)tableList.invokeOnThread(
                () => {
         var selectedItem = tableList.selected();
         if (selectedItem.notNull())
         {
             return selectedItem.Tag;
         }
         return null;
     }));
 }
Exemplo n.º 16
0
 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;
     }));
 }
Exemplo n.º 17
0
 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;
     }));
 }
Exemplo n.º 18
0
 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;
     }));
 }
Exemplo n.º 19
0
 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;
     }));
 }
Exemplo n.º 20
0
 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;
     }));
 }
Exemplo n.º 21
0
 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);
         }
     });
 }
Exemplo n.º 22
0
 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);
 }
Exemplo n.º 23
0
 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);
 }
Exemplo n.º 24
0
 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);
 }
Exemplo n.º 25
0
 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);
 }
Exemplo n.º 26
0
 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);
         }
     });
 }
Exemplo n.º 27
0
 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();
     }));
 }
Exemplo n.º 28
0
 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);
 }
Exemplo n.º 29
0
 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);
 }
Exemplo n.º 30
0
 //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;
     }));
 }