protected virtual void grid_MouseMove(GridVirtual sender, System.Windows.Forms.MouseEventArgs e) { Position l_PointPosition = sender.PositionAtPoint(new Point(e.X, e.Y)); Cells.ICellVirtual l_CellPosition = sender.GetCell(l_PointPosition); #region Mouse Multiselection if (e.Button == MouseButtons.Left && sender.Selection.EnableMultiSelection) { //Only if there is a FocusCell CellContext focusCellContext = new CellContext(sender, sender.Selection.ActivePosition); if (focusCellContext.Cell != null && focusCellContext.IsEditing() == false) { Position l_SelCornerPos = l_PointPosition; Cells.ICellVirtual l_SelCorner = l_CellPosition; //If the current Focus Cell is a scrollable cell then search the current cell (under the mouse)only in scrollable cells // see PositionAtPoint with false parameter if (sender.GetPositionType(sender.Selection.ActivePosition) == CellPositionType.Scrollable) { l_SelCornerPos = sender.PositionAtPoint(new Point(e.X, e.Y)); l_SelCorner = sender.GetCell(l_PointPosition); } if (l_SelCornerPos.IsEmpty() == false && l_SelCorner != null) { //Only if the user start the selection with a cell (m_MouseDownCell!=null) if (sender.MouseDownPosition.IsEmpty() == false && sender.Selection.Contains(sender.MouseDownPosition)) { sender.ChangeMouseSelectionCorner(l_SelCornerPos); sender.ShowCell(l_SelCornerPos); } } } } #endregion }
public bool GetScrollPositionToShowCell(Position position, List <int> visibleColumns, List <int> visibleRows, out Point newScrollPosition) { CellPositionType posType = m_Grid.GetPositionType(position); Rectangle displayRectangle = m_Grid.DisplayRectangle; bool isFixedLeft = posType == CellPositionType.FixedLeft || posType == CellPositionType.FixedTopLeft; int x; if (visibleColumns.Contains(position.Column)) //Is x visible { x = m_Grid.CustomScrollPosition.X; } else { if (isFixedLeft) { x = 0; } else { x = position.Column - m_Grid.ActualFixedColumns; } //Check if the scrollable positioin if not outside the valid area int maxX = m_Grid.GetScrollColumns(displayRectangle.Width); if (x > maxX) { x = maxX; } } bool isFixedTop = posType == CellPositionType.FixedTop || posType == CellPositionType.FixedTopLeft; int y; if (visibleRows.Contains(position.Row)) //Is y visible { y = m_Grid.CustomScrollPosition.Y; //[email protected]:CHDOC00123837: it works as expected without changing y value. the calculation in this method doesn't seem right //y = m_Grid.ExtendTopRowByHiddenRows(y); } else { //MICK(15): add direction dependent procedure of finding y (and x should be too). //It means that when you go from bottom to top, the selected item will be at top, // (this already happens, so this part is not changed) // when you go from top to bottom, the selected item will be at bottom, // y (and x) value is adjusted accordingly if (m_Grid.CustomScrollPosition.Y + m_Grid.ActualFixedRows > position.Row) { //MICK(16): direction bottom to top if (isFixedTop) { y = 0; } else { y = position.Row - m_Grid.FixedRows; } //Check if the scrollable positioin if not outside the valid area int maxY = m_Grid.GetScrollRows(displayRectangle.Height); if (y > maxY) { y = maxY; } //[email protected]:CHDOC00123837: it works as expected without changing y value. the calculation in this method doesn't seem right //MICK(21) //y = m_Grid.ExtendTopRowByHiddenRows(y); } else { //MICK(17): direction from top to bottom y = m_Grid.GetTopVisibleRowFromBottomRow(position.Row) - m_Grid.ActualFixedRows; //[email protected]: CHDOC00123837: it works as expected without changing y value. the calculation in this method doesn't seem right //y = m_Grid.ExtendTopRowByHiddenRows(y); } } newScrollPosition = new Point(x, y); return(true); }
public bool GetScrollPositionToShowCell(Position position, List <int> columns, List <int> rows, out Point newScrollPosition) { newScrollPosition = m_Grid.CustomScrollPosition; if (!m_Grid.IsPositionValid(position)) { return(false); } CellPositionType posType = m_Grid.GetPositionType(position); Rectangle displayRectangle = m_Grid.DisplayRectangle; bool isFixedLeft = posType == CellPositionType.FixedLeft || posType == CellPositionType.FixedTopLeft; int x = m_Grid.CustomScrollPosition.X; if (!columns.Contains(position.Column)) { if (isFixedLeft) { x = 0; } else if (columns.Count > m_Grid.ActualFixedColumns) { if (position.Column < columns[m_Grid.ActualFixedColumns]) { x = m_Grid.Columns.GetAbsoluteLeft(position.Column) - m_Grid.GetFixedAreaWidth(); } else { x = m_Grid.Columns.GetAbsoluteRight(position.Column) - displayRectangle.Width; } } else { x = m_Grid.Columns.GetAbsoluteLeft(position.Column) - m_Grid.GetFixedAreaWidth(); } } bool isFixedTop = posType == CellPositionType.FixedTop || posType == CellPositionType.FixedTopLeft; int y = m_Grid.CustomScrollPosition.Y; if (!rows.Contains(position.Row)) { if (isFixedTop) { y = 0; } else if (rows.Count > m_Grid.ActualFixedRows) { if (position.Row < rows[m_Grid.ActualFixedRows]) { y = m_Grid.Rows.GetAbsoluteTop(position.Row) - m_Grid.GetFixedAreaHeight(); } else { y = m_Grid.Rows.GetAbsoluteBottom(position.Row) - displayRectangle.Height; } } else { y = m_Grid.Rows.GetAbsoluteTop(position.Row) - m_Grid.GetFixedAreaHeight(); } } newScrollPosition = new Point(x, y); return(true); }