public bool ShowTableContextMenuForElement(IHTMLElement element) { IHTMLTable tableElement = TableHelper.GetContainingTableElement(element); if (tableElement != null) { MarkupRange tableMarkupRange = _editorContext.MarkupServices.CreateMarkupRange(tableElement as IHTMLElement); return(TableHelper.TableElementIsEditable(tableElement as IHTMLElement, tableMarkupRange)); } else { return(false); } }
private IHTMLElement GetTargetCell(Point clientPoint) { // maximum amount of scanning buffer is based on cell spacing int maxScanningRange = Math.Max(TableHelper.GetAttributeAsInteger(_table.cellSpacing), 2); // copy client point so we can modify the x-coordinate while scanning Point targetPoint = new Point(clientPoint.X, clientPoint.Y); // if we go past the end of the table allow the cell closest to the cursor // to become the target cell (necessary for sizing the table larger) Point xTargetPoint = new Point(targetPoint.X, targetPoint.Y); IHTMLTableCell targetCell = null; while (targetCell == null && xTargetPoint.X >= (targetPoint.X - maxScanningRange)) // 0 ) { // determine the cell we are over targetCell = _editorContext.ElementFromClientPoint(xTargetPoint) as IHTMLTableCell; // screen cells that don't belong to us if (!HTMLElementHelper.ElementsAreEqual(_table as IHTMLElement, TableHelper.GetContainingTableElement(targetCell as IHTMLElement) as IHTMLElement)) { targetCell = null; } xTargetPoint.X--; } // if we got a target cell then ensure that the point is over the document area if (targetCell != null) { if (_editorContext.PointIsOverDocumentArea(clientPoint)) { return(targetCell as IHTMLElement); } else { return(null); } } else { return(null); } }
public TableSelection(MarkupRange markupRange) { // calculate the begin and end cells IHTMLTableCell beginCell; IHTMLTableCell endCell; ArrayList selectedCells; FindCellRange(markupRange, out selectedCells, out beginCell, out endCell); // see if the two cells have a single containing table IHTMLTable table = GetSelectedTable(beginCell, endCell, markupRange) as IHTMLTable; // if we have a table then calculate the rest of our states if (table != null) { // validate the table selection if (ValidateTableSelection(table, markupRange, out _entireTableSelected)) { _table = table; _beginCell = beginCell; _endCell = endCell; // filter selected cells to only include direct descendents of this table (no // cells from nested tables) _selectedCells = new ArrayList(); foreach (IHTMLElement cell in selectedCells) { if (HTMLElementHelper.ElementsAreEqual(TableHelper.GetContainingTableElement(cell) as IHTMLElement, _table as IHTMLElement)) { _selectedCells.Add(cell); } } _hasContiguousSelection = !HTMLElementHelper.ElementsAreEqual(_beginCell as IHTMLElement, _endCell as IHTMLElement); _beginRow = GetContainingRowForCell(beginCell); _endRow = GetContainingRowForCell(endCell); _beginColumn = new HTMLTableColumn(_table, beginCell); _endColumn = new HTMLTableColumn(_table, endCell); } } }
protected override void OnElementAttached() { // call base base.OnElementAttached(); // determine whether the cell is editable _cellIsEditable = TableHelper.TableElementIsEditable(HTMLElement, ElementRange); // if editable then do our thing if (_cellIsEditable) { // add ourselves to the list of cell element behaviors TableEditingContext.AddCellBehavior(this); // if the table has no borders then set a runtime style that lets the user see the borders TableHelper.UpdateDesignTimeBorders( TableHelper.GetContainingTableElement(HTMLElement), HTMLElement as IHTMLElement2); } }
private static bool TableElementIsContainedInUnselectableTable(IHTMLElement element) { IHTMLTable table = TableHelper.GetContainingTableElement(element); if (table != null) { object unselectable = (table as IHTMLElement).getAttribute("unselectable", 0); if (unselectable != null) { return(unselectable.ToString() == "on"); } else { return(false); } } else { return(false); } }
private IHTMLElement GetSelectedTable(IHTMLTableCell beginCell, IHTMLTableCell endCell, MarkupRange selectionMarkupRange) { // screen null cases if (beginCell == null || endCell == null) { return(null); } // get containing tables IHTMLTable beginTable = TableHelper.GetContainingTableElement(beginCell as IHTMLElement); IHTMLTable endTable = TableHelper.GetContainingTableElement(endCell as IHTMLElement); // see if they are from the same table if (HTMLElementHelper.ElementsAreEqual(beginTable as IHTMLElement, endTable as IHTMLElement)) { return(beginTable as IHTMLElement); } else { return(null); } }