Пример #1
0
        /// <summary>
        /// Change the focus of the grid. The calls order is: (the user select CellX) Grid.CellGotFocus(CellX), CellX.Enter, (the user select CellY), Grid.CellLostFocus(CellX), CellX.Leave, Grid.CellGotFocus(CellY), CellY.Enter
        /// </summary>
        /// <param name="p_CellToSetFocus">Must be a valid cell linked to the grid or null of you want to remove the focus</param>
        /// <param name="p_DeselectOtherCells">True to deselect others selected cells</param>
        /// <returns>Return true if the grid can select the cell specified, otherwise false</returns>
        public override bool SetFocusCell(Position p_CellToSetFocus, bool p_DeselectOtherCells)
        {
            if (EnableRowColSpan == false || p_CellToSetFocus.IsEmpty())
            {
                return(base.SetFocusCell(p_CellToSetFocus, p_DeselectOtherCells));
            }

            ICell l_Cell = this[p_CellToSetFocus.Row, p_CellToSetFocus.Column];

            if (l_Cell != null)
            {
                return(base.SetFocusCell(l_Cell.Range.Start, p_DeselectOtherCells));
            }
            else
            {
                return(base.SetFocusCell(p_CellToSetFocus, p_DeselectOtherCells));
            }
        }
Пример #2
0
        /// <summary>
        /// Change the focus of the grid. The calls order is: (the user select CellX) Grid.CellGotFocus(CellX), CellX.Enter, (the user select CellY), Grid.CellLostFocus(CellX), CellX.Leave, Grid.CellGotFocus(CellY), CellY.Enter
        /// </summary>
        /// <param name="p_CellToSetFocus">Must be a valid cell linked to the grid or null of you want to remove the focus</param>
        /// <param name="p_DeselectOtherCells">True to deselect others selected cells</param>
        /// <returns>Return true if the grid can select the cell specified, otherwise false</returns>
        public override bool SetFocusCell(Position p_CellToSetFocus, bool p_DeselectOtherCells)
        {
            if (EnableRowColSpan == false || p_CellToSetFocus.IsEmpty())
              {
            return base.SetFocusCell(p_CellToSetFocus, p_DeselectOtherCells);
              }

              ICell l_Cell = this[p_CellToSetFocus.Row, p_CellToSetFocus.Column];
              if (l_Cell != null)
              {
            return base.SetFocusCell(l_Cell.Range.Start, p_DeselectOtherCells);
              }
              else
              {
            return base.SetFocusCell(p_CellToSetFocus, p_DeselectOtherCells);
              }
        }
Пример #3
0
        /// <summary>
        /// Indicates whether the specified cell is selected.
        /// </summary>
        /// <param name="cell">The cell.</param>
        /// <returns>
        /// <c>true</c> if the selection contains the specified cell; otherwise, <c>false</c>.
        /// </returns>
        public bool Contains(Position cell)
        {
            if (cell.IsEmpty())
              {
            return false;
              }

              for (int r = 0; r < rangeList.Count; r++)
              {
            if (this[r].Contains(cell))
            {
              return true;
            }
              }

              return false;
        }
Пример #4
0
        /// <summary>
        /// Fired when the cell under the mouse change. For internal use only.
        /// </summary>
        /// <param name="p_Cell">The cell.</param>
        protected void ChangeMouseCell(Position p_Cell)
        {
            if (this.mouseCellPosition != p_Cell)
              {
            if (this.mouseCellPosition.IsEmpty() == false &&
            this.mouseCellPosition != mouseDownPosition)
            {
              ICellVirtual l_OldCell = GetCell(this.mouseCellPosition.Row, mouseCellPosition.Column);
              if (l_OldCell != null)
              {
            l_OldCell.OnMouseLeave(new PositionEventArgs(this.mouseCellPosition, l_OldCell));
              }
            }

            this.mouseCellPosition = p_Cell;
            if (mouseCellPosition.IsEmpty() == false)
            {
              ICellVirtual l_NewCell = GetCell(this.mouseCellPosition.Row, this.mouseCellPosition.Column);
              if (l_NewCell != null)
              {
            l_NewCell.OnMouseEnter(new PositionEventArgs(this.mouseCellPosition, l_NewCell));
              }
            }
              }
        }
Пример #5
0
        /// <summary>
        /// Change the focus of the grid.
        /// </summary>
        /// <param name="p_CellToSetFocus">Must be a valid cell linked to the grid or null of you want to remove the focus</param>
        /// <param name="p_DeselectOtherCells">True to deselect others selected cells</param>
        /// <returns>
        /// Return true if the grid can select the cell specified, otherwise false
        /// </returns>
        /// <remarks>
        /// The call order is:
        /// (the user select CellX)
        /// CellX.FocusEntering
        /// Grid.CellGotFocus(CellX),
        /// CellX.FocusEntered,
        /// (the user select CellY),
        /// CellY.FocusEntering
        /// CellX.FocusLeaving
        /// Grid.CellLostFocus(CellX),
        /// CellX.FocusLeft,
        /// Grid.CellGotFocus(CellY),
        /// CellY.FocusEntered
        /// </remarks>
        public virtual bool SetFocusCell(Position p_CellToSetFocus, bool p_DeselectOtherCells)
        {
            if (p_CellToSetFocus == FocusCellPosition
            || (p_CellToSetFocus.Column != FocusCellPosition.Column && p_CellToSetFocus.Row == FocusCellPosition.Row && Selection.SelectionMode == GridSelectionMode.Row))
              {
            // put anyway the focus on the cells
            if (p_CellToSetFocus.IsEmpty() == false)
            {
              SetFocusOnCells();
            }

            if (FocusCellPosition.IsEmpty() == false && GetCell(FocusCellPosition) != null)
            {
              PositionCancelEventArgs l_OldEventArg = new PositionCancelEventArgs(FocusCellPosition, GetCell(FocusCellPosition));

              l_OldEventArg.Cell.OnFocusLeaving(l_OldEventArg);
              if (l_OldEventArg.Cancel)
              {
            return false;
              }

              OnCellLostFocus(l_OldEventArg);
              if (l_OldEventArg.Cancel)
              {
            return false;
              }
            }

            // deselect old selected cells
            if (p_DeselectOtherCells)
            {
              Selection.Clear();
            }
              }
              else // if (p_CellToSetFocus != FocusCellPosition || (p_CellToSetFocus.Column==FocusCellPosition.Column || p_CellToSetFocus.Row!=FocusCellPosition.Row || Selection.SelectionMode==GridSelectionMode.Row) ) //
              {
            // New Focus Cell Entering
            ICellVirtual l_CellToFocus = GetCell(p_CellToSetFocus);
            PositionCancelEventArgs l_NewEventArg = new PositionCancelEventArgs(p_CellToSetFocus, l_CellToFocus);
            if (p_CellToSetFocus.IsEmpty() == false && l_CellToFocus != null)
            {
              l_CellToFocus.OnFocusEntering(l_NewEventArg);
              if (l_NewEventArg.Cancel)
              {
            return false;
              }
            }

            if (l_CellToFocus != null && l_CellToFocus.CanReceiveFocus == false)
            {
              return false;
            }

            // Old Focus Cell Leaving and Left
            if (FocusCellPosition.IsEmpty() == false && GetCell(FocusCellPosition) != null)
            {
              PositionCancelEventArgs l_OldEventArg = new PositionCancelEventArgs(FocusCellPosition, GetCell(FocusCellPosition));

              l_OldEventArg.Cell.OnFocusLeaving(l_OldEventArg);
              if (l_OldEventArg.Cancel)
              {
            return false;
              }

              OnCellLostFocus(l_OldEventArg);
              if (l_OldEventArg.Cancel)
              {
            return false;
              }
            }

            // Deselect Old Cells
            if (p_DeselectOtherCells)
            {
              Selection.Clear();
            }

            // New Focus Cell Entered
            if (p_CellToSetFocus.IsEmpty() == false &&
            l_CellToFocus != null)
            {
              OnCellGotFocus(l_NewEventArg);

              return !l_NewEventArg.Cancel;
            }
              }

              return true;
        }
Пример #6
0
 /// <summary>
 /// Get the panels that contains the specified cells position. Returns null if the position is not valid
 /// </summary>
 /// <param name="cellPosition">The cell position.</param>
 /// <returns></returns>
 public GridSubPanel PanelAtPosition(Position cellPosition)
 {
     if (cellPosition.IsEmpty() == false)
       {
     CellPositionType l_Type = GetPositionType(cellPosition);
     if (l_Type == CellPositionType.FixedTopLeft)
     {
       return this.topLeftPanel;
     }
     else if (l_Type == CellPositionType.FixedLeft)
     {
       return this.leftPanel;
     }
     else if (l_Type == CellPositionType.FixedTop)
     {
       return this.topPanel;
     }
     else if (l_Type == CellPositionType.Scrollable)
     {
       return this.scrollablePanel;
     }
     else
     {
       return null;
     }
       }
       else
       {
     return null;
       }
 }
Пример #7
0
        /// <summary>
        /// Force a cell to redraw. If Redraw is set to false this function has no effects
        /// </summary>
        /// <param name="position">The position.</param>
        public virtual void InvalidateCell(Position position)
        {
            if (Redraw && position.IsEmpty() == false)
              {
            Rectangle l_GridRectangle = PositionToDisplayRect(position);
            GridSubPanel l_Panel = PanelAtPosition(position);

            l_Panel.Invalidate(l_Panel.RectangleGridToPanel(l_GridRectangle), false);
              }
        }
Пример #8
0
 /// <summary>
 /// Returns the type of a cell position
 /// </summary>
 /// <param name="p_CellPosition">The cell position.</param>
 /// <returns></returns>
 public CellPositionType GetPositionType(Position p_CellPosition)
 {
     if (p_CellPosition.IsEmpty())
       {
     return CellPositionType.Empty;
       }
       else if (p_CellPosition.Row < FixedRows && p_CellPosition.Column < FixedColumns)
       {
     return CellPositionType.FixedTopLeft;
       }
       else if (p_CellPosition.Row < FixedRows)
       {
     return CellPositionType.FixedTop;
       }
       else if (p_CellPosition.Column < FixedColumns)
       {
     return CellPositionType.FixedLeft;
       }
       else
       {
     return CellPositionType.Scrollable;
       }
 }
Пример #9
0
        /// <summary>
        /// Return the Cell at the specified Row and Column position. This method is called for sort
        /// operations and for Move operations. If position is Empty return <c>null</c>. This method calls GetCell(int rowIndex, int columnIndex)
        /// </summary>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public ICellVirtual GetCell(Position position)
        {
            if (position.IsEmpty())
              {
            return null;
              }

              return GetCell(position.Row, position.Column);
        }