public static IHTMLTableRow AddTableRowsAfterRow( IHTMLTable table, int afterRowIndex, int count) { var columnCount = CountTableColumns(table); IHTMLTableRow lastRow = null; // Add rows. for (var j = 0; j < count; ++j) { var row = (IHTMLTableRow)table.insertRow(afterRowIndex); lastRow = row; // Add columns in the newly added row. while (row.cells.length < columnCount) { var cell = (IHTMLTableCell)row.insertCell(); var element = (IHTMLElement)cell; element.innerHTML = @" "; } } return(lastRow); }
public override bool Compare(IAttributeBag attributeBag) { ElementAttributeBag elementAttributeBag = (ElementAttributeBag)attributeBag; IHTMLElement element = elementAttributeBag.IHTMLElement; if (IsTextContainedIn(element.innerText)) { // Get all elements and filter this for TableCells IHTMLTableRow tableRowElement = (IHTMLTableRow)element; IHTMLElementCollection tableCellElements = tableRowElement.cells; if (tableCellElements.length - 1 >= columnIndex) { IHTMLTableCell tableCell = (IHTMLTableCell)tableCellElements.item(columnIndex, null); ICompareElement elementComparer = comparer as ICompareElement; if (elementComparer != null) { return(elementComparer.Compare(new TableCell(elementAttributeBag.DomContainer, tableCell))); } return(base.Compare(new ElementAttributeBag(elementAttributeBag.DomContainer, (IHTMLElement)tableCell))); } } return(false); }
public static PixelPercent GetTableLogicalEditingWidth(IHTMLTable table) { // If percentage, then just keep that var width = GetTableWidth(table); if (width.Units == PixelPercentUnits.Percentage || width.Units == PixelPercentUnits.Undefined) { return(width); } // value to return (default to zero) int logicalWidth = 0; // calculate the "logical" width of the table if (table.rows.length > 0) { // save value of cellSpacing int cellSpacing = GetAttributeAsInteger(table.cellSpacing); // use the first row as a proxy for the width of the table IHTMLTableRow firstRow = table.rows.item(0, 0) as IHTMLTableRow; foreach (IHTMLTableCell cell in firstRow.cells) { logicalWidth += GetCellWidth(cell) + cellSpacing; } // total width + extra cellspacing @ end + size of borders return(logicalWidth + cellSpacing + GetTableBorderEditingOffset(table)); } // return width return(logicalWidth); }
/// <summary> /// Deletes the cell that the user has selected in the designer /// </summary> public void DeleteSelectedCell() { if (this.GetSelectedTableCell() != null) { IHTMLTableCell selectedCell = this.GetSelectedTableCellElement(); IHTMLTableRow selectedRow = (selectedCell as IHTMLElement).parentElement as IHTMLTableRow; selectedRow.deleteCell(selectedCell.cellIndex); } }
public IHTMLElement Row_InsertCell(IHTMLTableRow row, int index) { IHTMLElement elem = row.insertCell(index) as IHTMLElement; if (elem != null) { elem.innerHTML = HtmlSpace; } return(elem); }
// zero based public int GetRowIndex(IHTMLElement cellelem) { IHTMLTableRow row = GetParentRow(cellelem); if (row != null) { return(row.rowIndex); } return(0); }
/// <summary> /// Inserts a new cell in the selected table /// </summary> public void InsertCell() { IHTMLTableCell selectedCell = this.GetSelectedTableCellElement(); if (selectedCell != null) { IHTMLTableRow row = (selectedCell as IHTMLElement).parentElement as IHTMLTableRow; row.insertCell().innerHTML = " "; } }
public IHTMLTableCell Row_GetCell(IHTMLTableRow row, int index) { IHTMLElementCollection cells = row.cells; if (cells == null) { return(null); } object obj = index; return(cells.item(obj, obj) as IHTMLTableCell); }
public IHTMLElement Row_InsertCol(IHTMLTableRow row, int index) { int col = 0; int span = 0; object obj = 0; IHTMLElementCollection cells = row.cells; IHTMLElement retelem = null; for (int i = 0; true; i++) { obj = i; IHTMLTableCell cell = cells.item(obj, obj) as IHTMLTableCell; if (cell == null) // insert behind the rightmost cell { retelem = Row_InsertCell(row, i); break; } span = cell.colSpan; if (span == col) // insert at the left of the specified cell { retelem = Row_InsertCell(row, i); break; } if ((index > col) && (index < (col + span))) { cell.colSpan = span + 1; // increase cellspan of multi column cell retelem = cell as IHTMLElement; break; } col += span; retelem = null; } //Set width as evenly as possible CalculateCellWidths(cells.length); for (int i = 0; i < cells.length; i++) { obj = i; IHTMLTableCell cell = cells.item(obj, obj) as IHTMLTableCell; if (cell != null) { if ((i + 1) == cells.length) { cell.width = m_lastcellwidth; } else { cell.width = m_cellwidth; } } } return(retelem); }
public void Row_DeleteCol(IHTMLTableRow row, int index) { int col = 0; int span = 0; IHTMLTableCell cell = Row_GetCell(row, 0); IHTMLElement elem = null; while (true) { if (cell == null) { return; } span = cell.colSpan; //cell.cellIndex if (span == 1) { if (col == index) { RemoveNode(cell as IHTMLElement, true); if (Row_GetCellCount(row) == 0) { IHTMLTable table = GetParentTable(row as IHTMLElement) as IHTMLTable; if (table != null) { RemoveNode(table as IHTMLElement, true); } break; } } } else if (span > 1)// cell spans about multiple columns { if (index >= col && index < col + span) { cell.colSpan = span - 1; // reduce cellspan break; } } col += span; //Get next sibiling elem = NextSibiling(cell as IHTMLDOMNode); if (elem != null) { cell = elem as IHTMLTableCell; } else { cell = null; } } }
private void FillTable(IHTMLTable table) { foreach (var r in table.rows) { IHTMLTableRow row = r as IHTMLTableRow; foreach (var c in row.cells) { IHTMLTableCell cell = c as IHTMLTableCell; IHTMLElement elem = c as IHTMLElement; elem.innerText = "r" + row.rowIndex + "c" + cell.cellIndex; } } }
private static int CountTableRowColumns( IHTMLTableRow row) { var count = 0; for (var i = 0; i < row.cells.length; ++i) { var cell = (IHTMLTableCell)row.cells.item(i, i); count += Math.Max(1, cell.colSpan); } return(count); }
public int Row_GetCellCount(IHTMLTableRow row) { if (row == null) { return(0); } IHTMLElementCollection cells = row.cells; if (cells != null) { return(cells.length); } return(0); }
public void InsertCol(IHTMLTable table, int index) { for (int j = 0; true; j++) { IHTMLTableRow row = GetRow(table, j); if (row == null) { return; } if (Row_InsertCol(row, index) == null) { return; } } }
public void Initialize( IHTMLTableRow row) { Text = Resources.Str_UIHtml_RowProperties; IHTMLElementCollection cells = row.cells; if (cells != null) { for (int i = 0; i < cells.length; ++i) { _cells.Add(cells.item(i, i) as IHTMLTableCell); } } }
public void DeleteCol(IHTMLTable table, int colindex) { for (int i = 0; true; i++) { IHTMLTableRow row = GetRow(table, i); if (row == null) { break; } IHTMLTableCell cell = Row_GetCell(row, colindex); if (cell == null) { continue; } RemoveNode(cell as IHTMLElement, true); if (Row_GetCellCount(row) == 0) { RemoveNode(table as IHTMLElement, true); break; } //Accounts for colspan //Row_DeleteCol(row, colindex); IHTMLElementCollection cells = row.cells; CalculateCellWidths(cells.length); for (int j = 0; j < cells.length; j++) { object obj = j; IHTMLTableCell cella = cells.item(obj, obj) as IHTMLTableCell; if (cella != null) { if ((j + 1) == cells.length) { cella.width = m_lastcellwidth; } else { cella.width = m_cellwidth; } } } } }
public static void deleteRow(IHTMLElement m_oHTMLCtxMenu) { HTMLEditHelper htmledit = new HTMLEditHelper(); IHTMLTableRow row = htmledit.GetParentRow(m_oHTMLCtxMenu); int index = 0; if (row != null) { index = row.rowIndex; } IHTMLTable table = htmledit.GetParentTable(m_oHTMLCtxMenu); if (table == null) { return; } htmledit.DeleteRow(table, index); }
public IHTMLElement Row_InsertCell(IHTMLTableRow row, int index, string cellwidth) { IHTMLElement elem = row.insertCell(index) as IHTMLElement; if (elem != null) { elem.innerHTML = HtmlSpace; if (!string.IsNullOrEmpty(cellwidth)) { IHTMLTableCell tcell = elem as IHTMLTableCell; if (tcell != null) { tcell.width = cellwidth; } } } return(elem); }
public static void insertRow(IHTMLElement m_oHTMLCtxMenu) { HTMLEditHelper htmledit = new HTMLEditHelper(); IHTMLTableCell cell = m_oHTMLCtxMenu as IHTMLTableCell; IHTMLTableRow row = htmledit.GetParentRow(m_oHTMLCtxMenu); int index = 0; if (row != null) { index = row.rowIndex; } IHTMLTable table = htmledit.GetParentTable(m_oHTMLCtxMenu); if (table == null) { return; } htmledit.InsertRow(table, index, htmledit.Row_GetCellCount(row)); }
public static int GetRowHeight(IHTMLTableRow row) { IHTMLTableRow2 row2 = row as IHTMLTableRow2; if (row2.height != null) { try { return(int.Parse(row2.height.ToString(), CultureInfo.InvariantCulture)); } catch { return(0); } } else { return(0); } }
public void InsertRow(IHTMLTable table, int index, int numberofcells) { IHTMLTableRow row = table.insertRow(index) as IHTMLTableRow; if (row == null) { return; } CalculateCellWidths(numberofcells); for (int j = 0; j < numberofcells; j++) { if ((j + 1) == numberofcells) { Row_InsertCell(row, -1, m_lastcellwidth); } else { Row_InsertCell(row, -1, m_cellwidth); } } }
} //ProcessTable /// <summary> /// Method to determine if the current selection is a table /// If found will return the table element /// </summary> private void GetTableElement(out IHTMLTable table, out IHTMLTableRow row) { row = null; var range = ContentUtils.GetTextSelectionObject(); try { // first see if the table element is selected table = GetFirstControl() as IHTMLTable; // if table not selected then parse up the selection tree if (table.IsNull() && !range.IsNull()) { var element = range.parentElement(); // parse up the tree until the table element is found while (!element.IsNull() && table.IsNull()) { element = element.parentElement; // extract the Table properties var htmlTable = element as IHTMLTable; if (!htmlTable.IsNull()) { table = htmlTable; } // extract the Row properties var htmlTableRow = element as IHTMLTableRow; if (!htmlTableRow.IsNull()) { row = htmlTableRow; } } } } catch (Exception) { // have unknown error so set return to null table = null; row = null; } } //GetTableElement
/// <summary> /// Gets the column count of row(rowindex) /// Accounts for colSpan property /// </summary> /// <param name="table"></param> /// <param name="colindex"></param> /// <returns></returns> public int GetColCount(IHTMLTable table, int rowindex) { IHTMLTableRow row = GetRow(table, rowindex); if (row == null) { return(0); } int counter = 0; int cols = 0; while (true) { IHTMLTableCell cell = Row_GetCell(row, counter); if (cell == null) { break; } cols += cell.colSpan; counter++; } return(cols); }
private void InitializeSizingContext(IHTMLTableCell targetCell) { IHTMLTableRow row = TableHelper.GetContainingRowElement(targetCell as IHTMLTableCell); IHTMLTableCell leftCell = row.cells.item(_pendingLeftColumnIndex, _pendingLeftColumnIndex) as IHTMLTableCell; _leftColumn = new HTMLTableColumn(_table, leftCell); if (_pendingRightColumnIndex != -1) { IHTMLTableCell rightCell = row.cells.item(_pendingRightColumnIndex, _pendingRightColumnIndex) as IHTMLTableCell; _rightColumn = new HTMLTableColumn(_table, rightCell); } else { _rightColumn = null; } // force a fixup of cell widths on the next call to ContinueSizing // (we do this during ContinueSizing so that table column borders don't // visible "jump" on MouseDown) _cellWidthsFixed = false; }
public static bool FHasCorrectBinInTableRowOnPage(IHTMLDocument2 oDoc2, string sBin) { IHTMLElementCollection ihec; ihec = oDoc2.all.tags("table"); foreach (IHTMLElement ihe in ihec) { IHTMLTable ihet = ihe as IHTMLTable; if (ihe.className == "editList") { // we have the table, now see if we have a row that matches us. if (ihet.rows.length < 2) { return(false); // need to have at least 2 children } IHTMLTableRow iheRow = ihet.rows.item(1) as IHTMLTableRow; if (iheRow.cells.length < 8) { return(false); // has to have at least 2 children } IHTMLElement iheCell = iheRow.cells.item(7); if (iheCell.innerText == sBin) { return(true); } return(false); } } return(false); }
public IHTMLTableCell Row_GetCell(IHTMLTableRow row, int index) { IHTMLElementCollection cells = row.cells; if (cells == null) return null; object obj = index; return cells.item(obj, obj) as IHTMLTableCell; }
public void Row_DeleteCol(IHTMLTableRow row, int index) { int col = 0; int span = 0; IHTMLTableCell cell = Row_GetCell(row, 0); IHTMLElement elem = null; while (true) { if (cell == null) return; span = cell.colSpan; //cell.cellIndex if (span == 1) { if (col == index) { RemoveNode(cell as IHTMLElement, true); if (Row_GetCellCount(row) == 0) { IHTMLTable table = GetParentTable(row as IHTMLElement) as IHTMLTable; if (table != null) RemoveNode(table as IHTMLElement, true); break; } } } else if (span > 1)// cell spans about multiple columns { if (index >= col && index < col + span) { cell.colSpan = span - 1; // reduce cellspan break; } } col += span; //Get next sibiling elem = NextSibiling(cell as IHTMLDOMNode); if (elem != null) cell = elem as IHTMLTableCell; else cell = null; } }
private static int CountTableRowColumns( IHTMLTableRow row) { var count = 0; for (var i = 0; i < row.cells.length; ++i) { var cell = (IHTMLTableCell)row.cells.item(i, i); count += Math.Max(1, cell.colSpan); } return count; }
private HorizontalAlignment GetAlignmentForRow(IHTMLTableRow row) { HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left; bool firstCellProcessed = false; foreach (IHTMLTableCell cell in row.cells) { // for the first cell processed, note its alignment if (!firstCellProcessed) { horizontalAlignment = TableHelper.GetAlignmentForHtmlAlignment(cell.align); firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the alignment is mixed else { if (horizontalAlignment != TableHelper.GetAlignmentForHtmlAlignment(cell.align)) { horizontalAlignment = HorizontalAlignment.Mixed; break; } } } return horizontalAlignment; }
public static int GetRowHeight(IHTMLTableRow row) { IHTMLTableRow2 row2 = row as IHTMLTableRow2; if (row2.height != null) { try { return int.Parse(row2.height.ToString(), CultureInfo.InvariantCulture); } catch { return 0; } } else { return 0; } }
private void HandleMouseMove(TableColumnMouseEventArgs ea) { // cell element we are over IHTMLElement targetCell = GetTargetCell(ea.ClientPoint); // if there is no element then we are done if (targetCell == null) { // reset state _sizingOperation.EndSizing(); return; } // get the cell and row IHTMLTableCell cell = targetCell as IHTMLTableCell; IHTMLTableRow row = TableHelper.GetContainingRowElement(cell); // convert the client point to cell-local coordinates & calcualte our comparison x values TableCellEditingElementBehavior cellBehavior = _tableEditingContext.GetCellBehavior(targetCell); if (cellBehavior == null) { _sizingOperation.ClearPending(); return; } Point cellLocalMousePt = cellBehavior.TransformGlobalToLocal(ea.ClientPoint); int cellSpacing = TableHelper.GetAttributeAsInteger(_table.cellSpacing); int cellSpacingOffset = cellSpacing / 2; int compareX = cellLocalMousePt.X; int cellStartX = 0 - cellSpacingOffset; int cellEndX = targetCell.offsetWidth + cellSpacingOffset; // if the mouse is near the edge of the cell then update the pending sizing action // (unless the mouse is near the edge of the first cell where no sizing is supported) if (MouseNearCellEdge(compareX, cellStartX, cellSpacing) || MouseNearCellEdge(compareX, cellEndX, cellSpacing)) { if (MouseNearCellEdge(compareX, cellStartX, cellSpacing)) { if (cell.cellIndex > 0) { int leftIndex = cell.cellIndex - 1; int rightIndex = cell.cellIndex; _sizingOperation.TrackPending(ea.ClientPoint.X, leftIndex, rightIndex); ea.Handled = true; } else { _sizingOperation.ClearPending(); } } else if (MouseNearCellEdge(compareX, cellEndX, cellSpacing)) { int leftIndex = cell.cellIndex; int rightIndex = cell.cellIndex < (row.cells.length - 1) ? cell.cellIndex + 1 : -1; _sizingOperation.TrackPending(ea.ClientPoint.X, leftIndex, rightIndex); ea.Handled = true; } } else // mouse is not near the edge of the cell, reset pending action { _sizingOperation.ClearPending(); } }
private void InternalSetDataSource(object value, object CurrentDataSourceSync = null) { // 16241ms event: dataGridView1 set DataSource { ColumnIndex = 30, SourceRowIndex = 8, ElapsedMilliseconds = 1575, a = 175 } //Console.WriteLine( // "event: " // + this.Name // + " set DataSource enter " // + new // { // } // ); InternalDataSourceBusy = true; var stopwatch = Stopwatch.StartNew(); //Console.WriteLine( // new { Name, stopwatch.ElapsedMilliseconds } // + " enter InternalSetDataSource" // ); // this cost 6h of work to fix the sync timing issue if (CurrentDataSourceSync == null) { CurrentDataSourceSync = new object(); } InternalDataSourceSync = CurrentDataSourceSync; this.InternalDataSource = value; this.InternalRows.Clear(); if (value == null) { // x:\jsc.svn\examples\javascript\forms\test\testsqljoin\testsqljoin\applicationcontrol.cs if (AutoGenerateColumns) { while (this.Columns.Count > 0) { this.Columns.RemoveAt(this.Columns.Count - 1); } } else { // !! do not clear. we are likely to be rebound to same data } return; } var SourceDataTable = value as DataTable; #region InternalDataMember // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2013/201311/20131107/assetslibrary var SourceDataSet = value as DataSet; if (SourceDataSet != null) { foreach (DataTable item in SourceDataSet.Tables) { if (item.TableName == this.InternalDataMember) { SourceDataTable = item; } } } #endregion // 26:154ms InternalSetDataSource not implemented for <Namespace>.BindingSource // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201404/20140409 #region BindingSource var SourceBindingSource = value as __BindingSource; if (SourceBindingSource != null) { // x:\jsc.svn\examples\javascript\forms\test\testsqljoin\testsqljoin\applicationcontrol.cs //26:199ms InternalSetDataSource BindingSource { DataSource = } view-source:37729 //26:200ms InternalSetDataSource not implemented for <Namespace>.BindingSource view-source:37770 //26:202ms __BindingSource EndInit // we are being called first and then the designer sets the type. //this.myOtherDataSourceBindingSource.DataSource = typeof(FormsAutoSumGridSelection.Data.MyOtherDataSource); //this.myOtherDataSourceBindingSource.Position = 0; #region AtSourceBindingSourceDataSource Action AtSourceBindingSourceDataSource = delegate { // X:\jsc.svn\examples\javascript\forms\FormsDualDataSource\FormsDualDataSource\ApplicationControl.cs // once only? //26:156ms designer is still setting things up? view-source:37729 //26:158ms InternalSetDataSource BindingSource { Type = <Namespace>.BindingSource, DataSource = <Namespace>.MyOtherDataSource } view-source:37770 //26:161ms __BindingSource EndInit // X:\jsc.svn\examples\javascript\forms\FormsAutoSumGridSelection\FormsAutoSumGridSelection\Data\MyOtherDataSource.cs //var isBindingSource = SourceBindingSource.DataSource; //27:131ms designer is still setting things up? //27:132ms designer is still setting things up? DataSourceChanged //27:142ms InternalSetDataSource BindingSource { DataSource = <Namespace>.NavigationOrdersNavigateBindingSource } //Console.WriteLine("InternalSetDataSource BindingSource " + new //{ // //Type = SourceBindingSource.DataSource.GetType(), // SourceBindingSource.DataSource //}); object SourceBindingSource_DataSource_asDataTable = SourceBindingSource.ActivatedDataSource as DataTable; //Console.WriteLine( // new { SourceBindingSource_DataSource_asDataTable } // ); // X:\jsc.svn\examples\javascript\forms\FormsDualDataSource\FormsDualDataSource\ApplicationControl.cs if (SourceBindingSource_DataSource_asDataTable == null) { // not set by the designer? // #region asType // // tested by? // var asType = SourceBindingSource.DataSource as Type; // if (asType != null) // { // // 26:152ms InternalSetDataSource BindingSource { Type = <Namespace>.Type, DataSource = <Namespace>.MyDataSource } // // GenericObjectDataSource! // // are we calling the ctor? // var newT = Activator.CreateInstance(asType); // Console.WriteLine(new { newT }); // // 26:149ms { newT = <Namespace>.MyDataSource } var asBindingSource = SourceBindingSource.ActivatedDataSource as __BindingSource; if (asBindingSource != null) { SourceBindingSource_DataSource_asDataTable = asBindingSource.ActivatedDataSource as DataTable; } //} //#endregion } //Console.WriteLine(new { MyDataSource_DataSource = SourceBindingSource_DataSource_asDataTable }); if (SourceBindingSource_DataSource_asDataTable == null) { return; } #region DoSyncPosition Action DoSyncPosition = delegate { //Console.WriteLine(" we can sync the selection!"); // should the grid be destroying the selection on blur or keep it actually? this.SelectionChanged += delegate { // this methods is defined too early? var __SourceBindingSource_DataSource_asDataTable = SourceBindingSource_DataSource_asDataTable as DataTable; var isCurrentDataSourceSync = CurrentDataSourceSync == InternalDataSourceSync; // 30:49422ms SelectionChanged { isCurrentDataSourceSync = true, InternalPosition = 3, Count = 4 } // message: "Cannot read property 'hRIABq5zDzqOgooWgQkAYQ' of null" Console.WriteLine("SelectionChanged " + new { isCurrentDataSourceSync, this.InternalPosition, VisibleRowsCount = this.Rows.Count, DataRowsCount = __SourceBindingSource_DataSource_asDataTable.Rows.Count }); // some other datasource? if (!isCurrentDataSourceSync) { return; } // grid is letting bindingsource know what was selected! // is the new row ready yet? if (this.InternalPosition >= __SourceBindingSource_DataSource_asDataTable.Rows.Count) { // selection should wait for data sync? return; } SourceBindingSource.Position = this.InternalPosition; }; }; #endregion DoSyncPosition(); // 26:180ms { MyDataSource_DataSource = <Namespace>.MyOtherDataSource } #region MyDataSource_DataSource_as_DataTable var MyDataSource_DataSource_as_DataTable = SourceBindingSource_DataSource_asDataTable as DataTable; if (MyDataSource_DataSource_as_DataTable != null) { // X:\jsc.svn\examples\javascript\forms\Test\TestDynamicBindingSourceForDataTable\TestDynamicBindingSourceForDataTable\ApplicationControl.Designer.cs // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201404/20140409 // yay. we found the source. // we should learn to talk to IListSource // keep sync object! InternalSetDataSource(MyDataSource_DataSource_as_DataTable, CurrentDataSourceSync); return; } #endregion if (SourceBindingSource_DataSource_asDataTable is IListSource) { // X:\jsc.svn\examples\javascript\forms\FormsAutoSumGridSelection\FormsAutoSumGridSelection\Data\MyDataSource.cs //26:3237ms InternalSetDataSource does not yet support IListSource Console.WriteLine("InternalSetDataSource does not yet support IListSource"); return; } // 26:140ms { MyDataSource_DataSource = [object Object] } view-source:37388 //26:140ms InternalSetDataSource does not yet support ? //Console.WriteLine("InternalSetDataSource activated " + new //{ // Type = asBindingSource.DataSource.GetType(), // asBindingSource.DataSource //}); Console.WriteLine("InternalSetDataSource does not yet support ?"); //26:182ms InternalSetDataSource BindingSource { Type = <Namespace>.Type, DataSource = <Namespace>.MyDataSource } view-source:37770 //26:185ms __BindingSource EndInit // continue data binding? }; #endregion // X:\jsc.svn\examples\javascript\forms\Test\TestSQLJoin\TestSQLJoin\Library\TheView.cs SourceBindingSource.DataSourceChanged += delegate { //Console.WriteLine(" designer is still setting things up? DataSourceChanged"); if (SourceBindingSource.ActivatedDataSource == null) { return; } AtSourceBindingSourceDataSource(); }; if (SourceBindingSource.ActivatedDataSource == null) { //Console.WriteLine(" designer is still setting things up?"); return; } AtSourceBindingSourceDataSource(); return; } #endregion if (SourceDataTable == null) { Console.WriteLine("InternalSetDataSource not implemented for " + value.GetType()); return; } //Console.WriteLine( // "event: " // + this.Name // + " set DataSource clear done " // + new // { // } // ); // now what? // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableToJavascript\TestDataTableToJavascript\ApplicationControl.cs // http://stackoverflow.com/questions/6902269/moving-data-from-datatable-to-datagridview-in-c-sharp //Console.WriteLine( // new { Name, stopwatch.ElapsedMilliseconds } // + " before Columns" // ); // X:\jsc.svn\examples\javascript\forms\FormsHistoricBindingSourcePosition\FormsHistoricBindingSourcePosition\ApplicationControl.cs if (this.AutoGenerateColumns) { InternalAutoGenerateColumns(SourceDataTable); } // show the columns and continue in a moment Native.window.requestAnimationFrame += delegate { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } //return; #region PrerenderStopwatch var PrerenderStopwatch = Stopwatch.StartNew(); // X:\jsc.svn\examples\javascript\Test\TestManyTableRows\TestManyTableRows\Application.cs var SourceDataTableRowCount = SourceDataTable.Rows.Count; #if FPRERENDER for (int i = 0; i < SourceDataTableRowCount; i++) { var DataBoundItem = SourceDataTable.Rows[i]; // what the hell. safari and chrome show ok. // ie and ff show empty cells. why? #region prerender // 2096ms event: dataGridView1 set DataSource { ColumnIndex = 6, SourceRowIndex = 998, ElapsedMilliseconds = 1793, a = 1.7947947947947949 } // add a placeholder // http://stackoverflow.com/questions/3076708/can-we-have-multiple-tbody-in-same-table // http://www.w3.org/TR/html401/struct/tables.html#h-11.3.1 //if (NewTBody == null) //{ // NewTBody = this.__ContentTable.AddBody(); // //NewTBody.css[IHTMLElement.HTMLElementEnum.tr].children.style.backgroundColor = "cyan"; //} //var tr = NewTBody.AddRow(); //var tr = __ContentTableBody.AddRow(); var __tr = new IHTMLTableRow { }; __RowsTableBody.insertBefore(__tr, InternalNewRow.InternalZeroColumnTableRow); var InternalTableColumn = __tr.AddColumn(); var tr = new IHTMLTableRow { }; __ContentTableBody.insertBefore(tr, InternalNewRow.InternalTableRow); InternalPrerenderZeroRows.Enqueue(__tr); InternalPrerenderRows.Enqueue(tr); // http://www.w3.org/TR/html5/tabular-data.html#the-table-element var PrerenderData = (PrerenderStopwatch.ElapsedMilliseconds < 50); //for (int ic = 0; ic < SourceDataTableColumnCount; ic++) // visible columns? for (int ic = 0; ic < this.Columns.Count; ic++) { var data = DataBoundItem[ic]; var td = tr.AddColumn(); // http://www.w3schools.com/cssref/css3_pr_column-span.asp // 4760ms event: dataGridView1 set DataSource { ColumnIndex = 6, SourceRowIndex = 9999, ElapsedMilliseconds = 4092, a = 0.4092 } if (PrerenderData) { // X:\jsc.svn\examples\javascript\Test\TestManyTableRows\TestManyTableRows\Application.cs // we need a special div to play relative var td_div = new IHTMLDiv { }.AttachTo(td); td_div.setAttribute("data", data); } else { //td.colSpan = SourceDataTableColumnCount; // visible columns? td.colSpan = this.Columns.Count; break; } } #endregion // 6881ms event: dataGridView1 set DataSource { ColumnIndex = 6, SourceRowIndex = 998, ElapsedMilliseconds = 6590, a = 6.596596596596597 } } #endif PrerenderStopwatch.Stop(); if (PrerenderStopwatch.ElapsedMilliseconds > 30) { Console.WriteLine( "event: " + this.Name + " set DataSource prerender " + new { //SourceDataTableColumnCount, SourceDataTableRowCount, PrerenderStopwatch.ElapsedMilliseconds, } ); } #endregion var AddRowsStopwatch = Stopwatch.StartNew(); #region Rows var AddRowAction = Enumerable.Range(0, SourceDataTableRowCount).Select( i => new Action( delegate { var RowStopwatch = Stopwatch.StartNew(); var DataBoundItem = SourceDataTable.Rows[i]; var r = new __DataGridViewRow { DataBoundItem = new __DataRowView { Row = DataBoundItem } }; // script: error JSC1000: No implementation found for this native method, please implement [System.Windows.Forms.BaseCollection.GetEnumerator()] // columns reordered? for (int ColumnIndex = 0; ColumnIndex < this.Columns.Count; ColumnIndex++) { DataGridViewColumn c = this.Columns[ColumnIndex]; Console.WriteLine( new { ColumnIndex, c.DataPropertyName, c.Name } ); //X:\jsc.svn\examples\javascript\svg\SVGNavigationTiming\SVGNavigationTiming\ApplicationWebService.cs var DataPropertyName = c.DataPropertyName; if (string.IsNullOrEmpty(DataPropertyName)) { // regular datatables dont seem to have DataPropertyName? DataPropertyName = c.Name; } var cc = new DataGridViewTextBoxCell { // two way binding? //ReadOnly = true, Value = DataBoundItem[DataPropertyName] // Timestamp / datetime thingis need special attention? }; r.Cells.Add(cc); } // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/04-monese/2014/201401/20140130-build-server/trace this.Rows.Add(r); if (RowStopwatch.ElapsedMilliseconds > 30) { // report slowdowns only. Console.WriteLine( new { Name } +" InternalSetDataSource add row " + new { i, RowStopwatch.ElapsedMilliseconds } ); } } ) ).GetEnumerator(); while (AddRowAction.MoveNext()) { AddRowAction.Current(); // 3145ms { Name = dataGridView1 } InternalSetDataSource add row { i = 7, ElapsedMilliseconds = 13 } view-source:35829 if (AddRowsStopwatch.ElapsedMilliseconds > 100) { // continue later? break; } } #endregion AddRowsStopwatch.Stop(); if (AddRowsStopwatch.ElapsedMilliseconds > 30) { Console.WriteLine( "event: " + this.Name + " set DataSource add rows " + new { //SourceDataTableColumnCount, SourceDataTableRowCount, AddRowsStopwatch.ElapsedMilliseconds, } ); } //stopwatch.Restart(); #if FBINDING var NewRow = default(DataRow); #region Value SourceDataTable.ColumnChanged += (sender, x) => { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } // data source is changing under us! // keep up! var xColumnIndex = SourceDataTable.Columns.IndexOf(x.Column); if (xColumnIndex >= this.Columns.Count) { // we are not showing that data column! bail! return; } //29:16660ms DataSource UserAddedRow{ Count = 3 } view-source:37895 //29:16661ms SourceDataTable.ColumnChanged { RowIndex = 3, xColumnIndex = 0 } view-source:37895 //29:16662ms SourceDataTable.ColumnChanged { RowIndex = 3, xColumnIndex = 1 } var RowIndex = SourceDataTable.Rows.IndexOf(x.Row); Console.WriteLine("SourceDataTable.ColumnChanged " + new { RowIndex, xColumnIndex }); var c = this[xColumnIndex, RowIndex]; if (c == null) { Debugger.Break(); } if (c.Value == x.ProposedValue) { return; } c.Value = x.ProposedValue; }; #region CellValueChanged this.CellValueChanged += (_s, _e) => { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } // who changed it? Console.WriteLine( "DataSource at CellValueChanged " + new { _e.RowIndex, NewRow, SourceDataTable.Rows.Count } ); // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableNewRow\TestDataTableNewRow\ApplicationWebService.cs //InternalRaiseCellBeginEdit { ColumnIndex = 1, Index = 32 } // view-source:28036 //TableNewRow { RowIndexOf = -1 } // view-source:28036 //at CellValueChanged var CurrentRow = NewRow; if (_e.RowIndex >= 0) { if (_e.RowIndex < SourceDataTable.Rows.Count) { CurrentRow = SourceDataTable.Rows[_e.RowIndex]; } } // script: error JSC1000: No implementation found for this native method, please implement [System.Data.DataRow.set_Item(System.Int32, System.Object)] //script: warning JSC1000: Did you reference ScriptCoreLib via IAssemblyReferenceToken? //script: error JSC1000: error at ScriptCoreLib.JavaScript.BCLImplementation.System.Windows.Forms.__DataGridView+<>c__DisplayClass3.<set_DataSource>b__1, // assembly: X:\jsc.svn\examples\javascript\forms\Test\TestDataTableNewRow\TestDataTableNewRow\bin\Release\ScriptCoreLib.Windows.Forms.dll if (CurrentRow == null) { // not data bound?? return; } var c = this[_e.ColumnIndex, _e.RowIndex]; if (c == null) { // X:\jsc.internal.svn\core\com.abstractatech.my.business\com.abstractatech.my.business\Application.cs // ?? return; } if (CurrentRow[_e.ColumnIndex] == c.Value) { return; } Console.WriteLine("DataSource at CellValueChanged DataTable"); CurrentRow[_e.ColumnIndex] = this[_e.ColumnIndex, _e.RowIndex].Value; }; #endregion #endregion #region TableNewRow SourceDataTable.TableNewRow += (s, e) => { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } this.InternalDataSourceSync = null; // 60:417ms { FooColumn = foo from server1, GooColumn = 400 } //60:443ms a new row was added, auto resize? //Console.WriteLine("SourceDataTable.TableNewRow"); // script: error JSC1000: No implementation found for this native method, please implement [System.Windows.Forms.DataGridViewRowCollection.Add()] this.Rows.Add(); this.InternalDataSourceSync = CurrentDataSourceSync; }; #endregion #region UserAddedRow this.UserAddedRow += (_s, _e) => { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } // is this allowed? // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableNewRow\TestDataTableNewRow\ApplicationWebService.cs Console.WriteLine("DataSource UserAddedRow" + new { SourceDataTable.Rows.Count }); this.InternalDataSourceSync = null; NewRow = SourceDataTable.NewRow(); SourceDataTable.Rows.Add(NewRow); this.InternalDataSourceSync = CurrentDataSourceSync; foreach (DataColumn item in SourceDataTable.Columns) { // user cannot enter null can he // raise_ColumnChanged NewRow[item] = ""; } // argh we need to add it! Console.WriteLine("DataSource UserAddedRow" + new { RowIndex = SourceDataTable.Rows.IndexOf(NewRow), SourceDataTable.Rows.Count }); }; #endregion #region RemoveAt this.InternalBeforeUserDeletedRow += (sender, e) => { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } //RowDeleted { RowIndex = 2 } this.InternalDataSourceSync = null; SourceDataTable.Rows.RemoveAt(e.Row.Index); this.InternalDataSourceSync = CurrentDataSourceSync; }; // script: error JSC1000: No implementation found for this native method, please implement [System.Data.DataTable.add_RowDeleted(System.Data.DataRowChangeEventHandler)] SourceDataTable.RowDeleting += (sender, e) => { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } var RowIndex = SourceDataTable.Rows.IndexOf(e.Row); Console.WriteLine( "RowDeleted " + new { RowIndex } ); this.InternalDataSourceSync = null; this.Rows.RemoveAt(RowIndex); this.InternalDataSourceSync = CurrentDataSourceSync; }; #endregion #endif // do we still have time for this? // 23230ms event: { Name = dataGridView1 } autoresize done { ElapsedMilliseconds = 2761, Count = 6 } // 23229ms got offsetWidth in { ElapsedMilliseconds = 397 } // 3644ms event: { Name = dataGridView1 } autoresize done { ElapsedMilliseconds = 2275, Count = 6 } // do we want to autoresize if it takes up to 2500 ms? // InternalAutoResizeAll(); //stopwatch.Stop(); // 111485ms { Form = ExampleForm, Name = dataGridView1 } exit InternalSetDataSource{ ElapsedMilliseconds = 2775 } // 2281ms event: dataGridView1 set DataSource { ColumnIndex = 6, SourceRowIndex = 998, ElapsedMilliseconds = 1908, a = 1.90990990990991 } //2136ms event: dataGridView1 set DataSource { ColumnIndex = 6, SourceRowIndex = 998, ElapsedMilliseconds = 1788, a = 1.7897897897897899 } // 750ms event: dataGridView1 set DataSource { ColumnIndex = 6, SourceRowIndex = 998, ElapsedMilliseconds = 435, a = 0.43543543543543545 } // 9710ms event: dataGridView1 set DataSource { SourceDataTableColumnCount = 6, SourceDataTableRowCount = 1000, ElapsedMilliseconds = 1333 } // 079ms event: dataGridView1 set DataSource { SourceDataTableColumnCount = 6, SourceDataTableRowCount = 100, ElapsedMilliseconds = 564 } if (stopwatch.ElapsedMilliseconds > 30) { Console.WriteLine( "event: " // what if there is no form? //+ this.FindForm().Name + "." // what if there is no name? + this.Name + " set DataSource almost done " + new { //SourceDataTableColumnCount, SourceDataTableRowCount, stopwatch.ElapsedMilliseconds } ); } // 4069ms { Form = Form1, Name = dataGridView1 } exit InternalSetDataSource{ ElapsedMilliseconds = 2027 } // 371ms event: dataGridView1 set DataSource { SourceDataTableColumnCount = 6, SourceDataTableRowCount = 32, ElapsedMilliseconds = 188 } // 1182ms event: dataGridView1 set DataSource { SourceDataTableColumnCount = 6, SourceDataTableRowCount = 1000, ElapsedMilliseconds = 901 } Action yield = null; yield = delegate { if (this.InternalDataSourceSync != CurrentDataSourceSync) { return; } var CStopwatch = Stopwatch.StartNew(); while (AddRowAction.MoveNext()) { AddRowAction.Current(); if (CStopwatch.ElapsedMilliseconds > 300) { break; } } if (CStopwatch.ElapsedMilliseconds > 300) { Console.WriteLine( "event: " // what if there is no form? //+ this.FindForm().Name + "." // what if there is no name? + this.Name + " set DataSource yield " + new { //SourceDataTableColumnCount, InternalPrerenderRows.Count , stopwatch.ElapsedMilliseconds } ); Native.window.requestAnimationFrame += yield; return; } //584ms event: dataGridView1 set DataSource { SourceDataTableColumnCount = 6, SourceDataTableRowCount = 1000, ElapsedMilliseconds = 313 } InternalDataSourceBusy = false; var sReposition0 = Stopwatch.StartNew(); // bulk insert done. rorder? // Reposition // do we even allow column resize? if (this.Columns.Count > 0) { this.Columns[0].Width = this.Columns[0].Width; } if (sReposition0.ElapsedMilliseconds > 30) { Console.WriteLine( this.Name + " set DataSource sReposition0 " + new { //SourceDataTableColumnCount, sReposition0.ElapsedMilliseconds } ); } InternalAutoSizeWhenFill(); new XAttribute( "Stopwatch", new { //columns = cstopwatch.ElapsedMilliseconds, prerender = PrerenderStopwatch.ElapsedMilliseconds, rows = AddRowsStopwatch.ElapsedMilliseconds, total = stopwatch.ElapsedMilliseconds }.ToString() ).AttachTo(this.HTMLTargetRef); Console.WriteLine( "event: " // what if there is no form? //+ this.FindForm().Name + "." // what if there is no name? + this.Name + " DataSourceChanged " + new { //SourceDataTableColumnCount, SourceDataTableRowCount, stopwatch.ElapsedMilliseconds } ); if (DataSourceChanged != null) { DataSourceChanged(this, new EventArgs()); } }; Native.window.requestAnimationFrame += yield; }; }
/// <summary> /// 表格弹出菜单事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void tableToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Name) { case "delcolToolStripMenuItem": { GeneralMethodsForDesign.deleteColumn(currentEle); } break; case "inscolToolStripMenuItem": { GeneralMethodsForDesign.insertColumn(currentEle); } break; case "delrowToolStripMenuItem": { GeneralMethodsForDesign.deleteRow(currentEle); break; } case "insrowToolStripMenuItem": { GeneralMethodsForDesign.insertRow(currentEle); break; } case "splitToolStripMenuItem": { #region HTMLEditHelper hp = new HTMLEditHelper(); IHTMLTable tb = hp.GetParentTable(currentEle); IHTMLTableRow tr = hp.GetParentRow(currentEle); IHTMLTableCell td = currentEle as IHTMLTableCell; int rowindex = tr.rowIndex; int rowcount = hp.GetRowCount(tb); int colindex = td.cellIndex; hp.Row_InsertCell(tr, colindex - 1); int currentSpan = 0; for (int k = 0; k < colindex; k++) { currentSpan += (hp.Row_GetCell(tr, colindex) as IHTMLTableCell).colSpan; } for (int i = 0; i < rowcount; i++) { if (i != rowindex) { IHTMLTableRow tr0 = hp.GetRow(tb, i) as IHTMLTableRow; IHTMLTableCell td0 = hp.Row_GetCell(tr0, colindex) as IHTMLTableCell; int rowSpan = 0; int cellnum = 0; do { rowSpan += (hp.Row_GetCell(tr0, cellnum) as IHTMLTableCell).colSpan; td0 = hp.Row_GetCell(tr0, cellnum) as IHTMLTableCell; cellnum++; }while (rowSpan <= currentSpan); if (td0.colSpan > 0) { td0.colSpan += 1; } } else { continue; } } break; #endregion } case "mergerToolStripMenuItem": { #region HTMLEditHelper hp = new HTMLEditHelper(); /* IHTMLTableRow tr = hp.GetParentRow(currentEle); * int colNum = hp.Row_GetCellCount(tr); * MergeCellForm mergeCel = new MergeCellForm(colNum); * if (mergeCel.ShowDialog() == DialogResult.OK) * { * * }*/ IHTMLTableCell c1 = currentEle as IHTMLTableCell; mshtml.IHTMLDOMNode n1 = c1 as mshtml.IHTMLDOMNode; IHTMLTableCell c2 = hp.PreviousSibling(n1) as IHTMLTableCell; IHTMLTableCell c3 = hp.NextSibiling(n1) as IHTMLTableCell; IHTMLElement e1 = c1 as IHTMLElement; IHTMLElement e2 = c2 as IHTMLElement; IHTMLElement e3 = c3 as IHTMLElement; int span = c1.colSpan; string tdtext = e1.innerHTML; if (c2 != null) { span += c2.colSpan; tdtext = e2.innerText + tdtext; hp.RemoveNode(e2, false); } if (c3 != null) { span += c3.colSpan; tdtext += e3.innerText; hp.RemoveNode(e3, false); } c1.colSpan = span; e1.innerHTML = tdtext; break; #endregion } case "otherToolStripMenuItem": { break; } } }
public int Row_GetCellCount(IHTMLTableRow row) { if (row == null) return 0; IHTMLElementCollection cells = row.cells; if (cells != null) return cells.length; return 0; }
private void PasteCellsIntoTable(IHTMLTable sourceTable, TableSelection tableSelection) { // collect up the top level cells we are pasting ArrayList cellsToPaste = new ArrayList(); foreach (IHTMLTableRow row in sourceTable.rows) { foreach (IHTMLElement cell in row.cells) { cellsToPaste.Add(cell); } } // get the list of cells we are pasting into int appendRows = 0; int cellsPerRow = 0; ArrayList targetCells; if (tableSelection.SelectedCells.Count > 1) { targetCells = tableSelection.SelectedCells; } else { targetCells = new ArrayList(); bool accumulatingCells = false; foreach (IHTMLTableRow row in tableSelection.Table.rows) { cellsPerRow = row.cells.length; foreach (IHTMLElement cell in row.cells) { if (!accumulatingCells && HTMLElementHelper.ElementsAreEqual(cell, tableSelection.BeginCell as IHTMLElement)) { accumulatingCells = true; } if (accumulatingCells) { targetCells.Add(cell); } } } // if the target cells aren't enough to paste all of the cells, then // calculate the number of rows we need to append to fit all of the // cells being pasted int cellGap = cellsToPaste.Count - targetCells.Count; if (cellGap > 0 && cellsPerRow > 0) { appendRows = cellGap / cellsPerRow + (cellGap % cellsPerRow == 0 ? 0 : 1); } } // perform the paste using (IUndoUnit undoUnit = EditorContext.CreateUndoUnit()) { // append rows if needed if (appendRows > 0) { // see if we can cast our editor context to the one required // by the table editor IHtmlEditorComponentContext editorContext = EditorContext as IHtmlEditorComponentContext; if (editorContext != null) { // markup range based on last target cell IHTMLElement lastCell = targetCells[targetCells.Count - 1] as IHTMLElement; MarkupRange lastCellRange = EditorContext.MarkupServices.CreateMarkupRange(lastCell); for (int i = 0; i < appendRows; i++) { IHTMLTableRow row = TableEditor.InsertRowBelow(editorContext, lastCellRange); foreach (IHTMLElement cell in row.cells) { targetCells.Add(cell); } lastCellRange = EditorContext.MarkupServices.CreateMarkupRange(row as IHTMLElement); } } else { Debug.Fail("Couldn't cast EditorContext!"); } } // do the paste for (int i = 0; i < cellsToPaste.Count && i < targetCells.Count; i++) { (targetCells[i] as IHTMLElement).innerHTML = (cellsToPaste[i] as IHTMLElement).innerHTML; } undoUnit.Commit(); } }
private IHTMLTableCell InsertCell(IHTMLTableRow row, int index) { IHTMLElement cell = (IHTMLElement)row.insertCell(index); return cell as IHTMLTableCell; }
public TableRow(DomContainer domContainer, IHTMLTableRow htmlTableRow) : base(domContainer, domContainer.NativeBrowser.CreateElement(htmlTableRow)) { }
public IHTMLElement Row_InsertCell(IHTMLTableRow row, int index, string cellwidth) { IHTMLElement elem = row.insertCell(index) as IHTMLElement; if (elem != null) { elem.innerHTML = HtmlSpace; if (!string.IsNullOrEmpty(cellwidth)) { IHTMLTableCell tcell = elem as IHTMLTableCell; if (tcell != null) { tcell.width = cellwidth; } } } return elem; }
public IHTMLElement Row_InsertCell(IHTMLTableRow row, int index) { IHTMLElement elem = row.insertCell(index) as IHTMLElement; if (elem != null) elem.innerHTML = HtmlSpace; return elem; }
public IHTMLElement Row_InsertCol(IHTMLTableRow row, int index) { int col = 0; int span = 0; object obj = 0; IHTMLElementCollection cells = row.cells; IHTMLElement retelem = null; for (int i = 0; true; i++) { obj = i; IHTMLTableCell cell = cells.item(obj, obj) as IHTMLTableCell; if (cell == null) // insert behind the rightmost cell { retelem = Row_InsertCell(row, i); break; } span = cell.colSpan; if (span == col) // insert at the left of the specified cell { retelem = Row_InsertCell(row, i); break; } if ((index > col) && (index < (col + span))) { cell.colSpan = span + 1; // increase cellspan of multi column cell retelem = cell as IHTMLElement; break; } col += span; retelem = null; } //Set width as evenly as possible CalculateCellWidths(cells.length); for (int i = 0; i < cells.length; i++) { obj = i; IHTMLTableCell cell = cells.item(obj, obj) as IHTMLTableCell; if (cell != null) { if ((i + 1) == cells.length) cell.width = m_lastcellwidth; else cell.width = m_cellwidth; } } return retelem; }
private VerticalAlignment GetVAlignmentForRow(IHTMLTableRow row) { VerticalAlignment verticalAlignment = VerticalAlignment.Middle; bool firstCellProcessed = false; foreach (IHTMLTableCell cell in row.cells) { // for the first cell processed, note its alignment if (!firstCellProcessed) { verticalAlignment = TableHelper.GetVAlignmentForHtmlAlignment(cell.vAlign); firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the alignment is mixed else { if (verticalAlignment != TableHelper.GetVAlignmentForHtmlAlignment(cell.vAlign)) { verticalAlignment = VerticalAlignment.Mixed; break; } } } return verticalAlignment; }
private CellColor GetBackgroundColorForRow(IHTMLTableRow row) { CellColor cellColor = new CellColor(); bool firstCellProcessed = false; foreach (IHTMLTableCell cell in row.cells) { // for the first cell processed, note its color if (!firstCellProcessed) { cellColor.Color = TableHelper.GetColorForHtmlColor(cell.bgColor); firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the background color is mixed else { if (cellColor.Color != TableHelper.GetColorForHtmlColor(cell.bgColor)) { cellColor.IsMixed = true; break; } } } return cellColor; }
private IHTMLTableCell InsertCell(IHTMLTableRow row) { return InsertCell(row, -1); }