Esempio n. 1
0
        private void OnMouseUp(TableColumnMouseEventArgs ea)
        {
            if (_sizingOperation.InProgress)
            {
                _sizingOperation.EndSizing();

                ea.Handled = true;
            }
        }
Esempio n. 2
0
        private void OnMouseDown(TableColumnMouseEventArgs ea)
        {
            if (_sizingOperation.Pending)
            {
                _sizingOperation.BeginSizing(GetTargetCell(ea.ClientPoint) as IHTMLTableCell);

                ea.Handled = true;
            }
        }
Esempio n. 3
0
 private void OnMouseMove(TableColumnMouseEventArgs ea)
 {
     if (_sizingOperation.InProgress)
     {
         // mouse move when we are in an active sizing state
         _sizingOperation.ContinueSizing(ea.ClientPoint.X);
         ea.Handled = true;
     }
     else
     {
         // mouse move when we are just tracking the cursor (not sizing)
         HandleMouseMove(ea);
     }
 }
        private int HandleMouseEvent(int inEvtDispId, IHTMLEventObj pIEventObj)
        {
            // WinLive 160252: MSHTML throws a COMException with HRESULT 0x8000FFFF (E_UNEXPECTED) when calling
            // IHTMLPaintSite.TransformGlobalToLocal if the table has no height.
            IHTMLElement tableElement = (IHTMLElement)_table;
            if (tableElement.offsetHeight <= 0 || tableElement.offsetWidth <= 0)
            {
                return HRESULT.S_FALSE;
            }

            // compute the element local coordinates of the point
            POINT clientMouseLocation = new POINT();
            clientMouseLocation.x = pIEventObj.clientX;
            clientMouseLocation.y = pIEventObj.clientY;
            POINT localMouseLocation = new POINT();
            _paintSite.TransformGlobalToLocal(clientMouseLocation, ref localMouseLocation);

            // determine if the point is within our bounds
            int tableWidth = tableElement.offsetWidth + 4; // extra padding for mouse handling at right edge
            Rectangle elementBounds = new Rectangle(-1, -1, tableWidth, tableElement.offsetHeight + 1);
            bool mouseInElement = elementBounds.Contains(localMouseLocation.x, localMouseLocation.y);

            if (mouseInElement || _sizingOperation.InProgress)
            {
                // create args
                TableColumnMouseEventArgs mouseEventArgs = new TableColumnMouseEventArgs(
                    new Point(clientMouseLocation.x, clientMouseLocation.y),
                    new Point(localMouseLocation.x, localMouseLocation.y));

                // fire the event
                switch (inEvtDispId)
                {
                    case DISPID_HTMLELEMENTEVENTS2.ONMOUSEMOVE:
                        OnMouseMove(mouseEventArgs);
                        break;
                    case DISPID_HTMLELEMENTEVENTS2.ONMOUSEDOWN:
                        OnMouseDown(mouseEventArgs);
                        break;
                    case DISPID_HTMLELEMENTEVENTS2.ONMOUSEUP:
                        OnMouseUp(mouseEventArgs);
                        break;
                    default:
                        Trace.Fail("unexpected event id");
                        break;
                }

                // indicate whether we should mask the event from the editor
                return mouseEventArgs.Handled ? HRESULT.S_OK : HRESULT.S_FALSE;

            }
            else
            {
                // if the mouse is not inside the element the end sizing
                _sizingOperation.EndSizing();
            }

            // event not handled
            return HRESULT.S_FALSE;
        }
        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 OnMouseUp(TableColumnMouseEventArgs ea)
        {
            if (_sizingOperation.InProgress)
            {
                _sizingOperation.EndSizing();

                ea.Handled = true;
            }
        }
        private void OnMouseDown(TableColumnMouseEventArgs ea)
        {
            if (_sizingOperation.Pending)
            {
                _sizingOperation.BeginSizing(GetTargetCell(ea.ClientPoint) as IHTMLTableCell);

                ea.Handled = true;
            }
        }
 private void OnMouseMove(TableColumnMouseEventArgs ea)
 {
     if (_sizingOperation.InProgress)
     {
         // mouse move when we are in an active sizing state
         _sizingOperation.ContinueSizing(ea.ClientPoint.X);
         ea.Handled = true;
     }
     else
     {
         // mouse move when we are just tracking the cursor (not sizing)
         HandleMouseMove(ea);
     }
 }
Esempio n. 9
0
        private int HandleMouseEvent(int inEvtDispId, IHTMLEventObj pIEventObj)
        {
            // WinLive 160252: MSHTML throws a COMException with HRESULT 0x8000FFFF (E_UNEXPECTED) when calling
            // IHTMLPaintSite.TransformGlobalToLocal if the table has no height.
            IHTMLElement tableElement = (IHTMLElement)_table;

            if (tableElement.offsetHeight <= 0 || tableElement.offsetWidth <= 0)
            {
                return(HRESULT.S_FALSE);
            }

            // compute the element local coordinates of the point
            POINT clientMouseLocation = new POINT();

            clientMouseLocation.x = pIEventObj.clientX;
            clientMouseLocation.y = pIEventObj.clientY;
            POINT localMouseLocation = new POINT();

            _paintSite.TransformGlobalToLocal(clientMouseLocation, ref localMouseLocation);

            // determine if the point is within our bounds
            int       tableWidth     = tableElement.offsetWidth + 4; // extra padding for mouse handling at right edge
            Rectangle elementBounds  = new Rectangle(-1, -1, tableWidth, tableElement.offsetHeight + 1);
            bool      mouseInElement = elementBounds.Contains(localMouseLocation.x, localMouseLocation.y);

            if (mouseInElement || _sizingOperation.InProgress)
            {
                // create args
                TableColumnMouseEventArgs mouseEventArgs = new TableColumnMouseEventArgs(
                    new Point(clientMouseLocation.x, clientMouseLocation.y),
                    new Point(localMouseLocation.x, localMouseLocation.y));

                // fire the event
                switch (inEvtDispId)
                {
                case DISPID_HTMLELEMENTEVENTS2.ONMOUSEMOVE:
                    OnMouseMove(mouseEventArgs);
                    break;

                case DISPID_HTMLELEMENTEVENTS2.ONMOUSEDOWN:
                    OnMouseDown(mouseEventArgs);
                    break;

                case DISPID_HTMLELEMENTEVENTS2.ONMOUSEUP:
                    OnMouseUp(mouseEventArgs);
                    break;

                default:
                    Trace.Fail("unexpected event id");
                    break;
                }

                // indicate whether we should mask the event from the editor
                return(mouseEventArgs.Handled ? HRESULT.S_OK : HRESULT.S_FALSE);
            }
            else
            {
                // if the mouse is not inside the element the end sizing
                _sizingOperation.EndSizing();
            }

            // event not handled
            return(HRESULT.S_FALSE);
        }
Esempio n. 10
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();
            }
        }