本文整理汇总了C#中SourceGrid.Position类的典型用法代码示例。如果您正苦于以下问题:C# Position类的具体用法?C# Position怎么用?C# Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Position类属于SourceGrid命名空间,在下文中一共展示了Position类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: From
public static Range From(Position startPosition, int rowCount, int colCount)
{
var range = new Range(startPosition);
range.RowsCount = rowCount;
range.ColumnsCount = colCount;
return range;
}
示例2: Range
/// <summary>
/// Constructor
/// </summary>
/// <param name="p_StartRow"></param>
/// <param name="p_StartCol"></param>
/// <param name="p_EndRow"></param>
/// <param name="p_EndCol"></param>
public Range(int p_StartRow, int p_StartCol, int p_EndRow, int p_EndCol)
{
m_Start = new Position(p_StartRow, p_StartCol);
m_End = new Position(p_EndRow, p_EndCol);
Normalize();
}
示例3: GetFirstIntersectedRange
public Range? GetFirstIntersectedRange(Position pos)
{
var result = base.QueryFirst(pos);
if (result == null)
return null;
return result;
}
示例4: MoveTo
/// <summary>
/// Move the current range to the specified position, leaving the current ColumnsCount and RowsCount
/// </summary>
/// <param name="p_StartPosition"></param>
public void MoveTo(Position p_StartPosition)
{
int l_ColCount = ColumnsCount;
int l_RowCount = RowsCount;
m_Start = p_StartPosition;
RowsCount = l_RowCount;
ColumnsCount = l_ColCount;
}
示例5: PositionToCellRange
/// <summary>
/// This method converts a Position to the real range of the cell. This is usefull when RowSpan or ColumnSpan is greater than 1.
/// For example suppose to have at grid[0,0] a cell with ColumnSpan equal to 2. If you call this method with the position 0,0 returns 0,0-0,1 and if you call this method with 0,1 return again 0,0-0,1.
/// </summary>
/// <param name="pPosition"></param>
/// <returns></returns>
public override Range PositionToCellRange(Position pPosition)
{
if (pPosition.IsEmpty())
return Range.Empty;
Cells.ICell l_Cell = this[pPosition.Row, pPosition.Column];
if (l_Cell == null)
return Range.Empty;
else
return l_Cell.Range;
}
示例6: EnsureNoSpannedCellsExist
private void EnsureNoSpannedCellsExist(int row, int col, Cells.ICell p_cell)
{
var spanRange = new Range(row, col, row + p_cell.RowSpan - 1, col + p_cell.ColumnSpan - 1);
var ranges = spannedCellReferences.SpannedRangesCollection.GetRanges(
spanRange);
if (ranges.Count == 0)
return;
var start = new Position(row, col);
foreach (var range in ranges)
{
if (start.Equals(range.Start) == true)
continue;
Cells.ICell existingSpannedCell = this[range.Start];
if (existingSpannedCell == null)
throw new ArgumentException("internal error. please report this bug to developers");
throw new OverlappingCellException(string.Format(
"Given cell at position ({0}, {1}), " +
"intersects with another cell " +
"at position ({2}, {3}) '{4}'",
row, col,
existingSpannedCell.Row.Index,
existingSpannedCell.Column.Index,
existingSpannedCell.DisplayText));
}
}
示例7: GetSpannedCell
/// <summary>
/// Check if a cell exists in spanned cells.
/// If yes, returns. If no, returns null
/// </summary>
private Cells.ICell GetSpannedCell(Position pos)
{
var range = spannedCellReferences.SpannedRangesCollection.GetFirstIntersectedRange(pos);
if (range == null)
return null;
Position cellPos = range.Value.Start;
Cells.ICell cell = DirectGetCell(cellPos);
if (cell == null)
throw new ArgumentException(string.Format(
"Invalid grid state. Grid should contain a spanned cell at position {0}, " +
" but apparently it does not!", cellPos));
return cell;
}
示例8: DirectGetCell
private Cells.ICell DirectGetCell(Position position)
{
if (IsInGrid(position) == false)
return null;
if (OptimizeMode == CellOptimizeMode.ForRows)
{
GridRow row = Rows[position.Row];
if (row == null)
return null;
return row[Columns[position.Column] as GridColumn];
}
else if (OptimizeMode == CellOptimizeMode.ForColumns)
{
GridColumn col = Columns[position.Column] as GridColumn;
if (col == null)
return null;
return col[Rows[position.Row]];
}
else
throw new SourceGridException("Invalid OptimizeMode");
}
示例9: DirectSetCell
private void DirectSetCell(Position position, Cells.ICell cell)
{
if (OptimizeMode == CellOptimizeMode.ForRows)
{
GridRow row = Rows[position.Row];
if (position.Column >= Columns.Count)
throw new ArgumentException(string.Format(
"Grid has only {0} columns, you tried to insert cell into position {1}." +
"You should probably call Redim on grid to increase it's column size",
Columns.Count, position.ToString()));
row[Columns[position.Column] as GridColumn] = cell;
}
else if (OptimizeMode == CellOptimizeMode.ForColumns)
{
GridColumn col = Columns[position.Column] as GridColumn;
col[Rows[position.Row]] = cell;
}
else
throw new SourceGridException("Invalid OptimizeMode");
}
示例10: CellContext
/// <summary>
/// Constructor
/// </summary>
/// <param name="pGridVirtual"></param>
/// <param name="pPosition"></param>
public CellContext(GridVirtual pGridVirtual, Position pPosition)
{
Position = pPosition;
Grid = pGridVirtual;
Cell = Grid.GetCell(Position);
}
示例11: FindFirstFocusableRowInUpDirection
int FindFirstFocusableRowInUpDirection(int BottomRow)
{
for (int k = BottomRow; k > ActualFixedRows; k--)
{
Position newPosition = new Position(k, Selection.ActivePosition.Column);
if (Selection.CanReceiveFocus(newPosition)) return k;
}
return -1;
}
示例12: CustomScrollPageUp
public override void CustomScrollPageUp()
{
bool NeedActualScrolling=false;
int NewProposedTopRow=0;
int NewProposedFocusedRow=0;
//confusing NAMING: ActivePosition -> FocusedPosition - it would be better
int FocusedRow = Selection.ActivePosition.Row;
//TODO: if there is no selection here (ActiveRow is undefined),
//put selection in the first possible cell
//confusing NAMING: Rows.IsRowVisible -> Rows.NotHidden - because it is not hidden,
// may be confused with visible on screen within visible page
if (FocusedRow == -1)
{
Selection.MoveActiveCell(-1, 0);
return;
}
List<int> rows = GetVisibleRows(false);
//TODO: if Rows.height<displayheight
if (rows.Count <= ActualFixedRows + 1)
{
Selection.MoveActiveCell(-1, 0);
return;
};
int firstVisibleRow = rows[ActualFixedRows];
int lastVisibleRow = rows[rows.Count - 1];
//another workaround: if (focusedrow==firstVisibleRow)
//if the row above has height larger than displayheight it is also like one row scrolling-
//so workaround is needed like the one above
if (FocusedRow == firstVisibleRow)
if (FocusedRow>ActualFixedRows)
{
int displayHeight = DisplayRectangle.Height;
//Remove the fixed rows from the scrollable area
for (int f = 0; f < ActualFixedRows; f++)
displayHeight -= Rows.GetHeight(f);
if (displayHeight <= Rows.GetHeight(FocusedRow - 1))
{
Selection.MoveActiveCell(-1, 0);
return;
}
}
// AlanP: Sep 2013 We need to know if SHIFT is pressed
bool shiftPressed = Control.ModifierKeys == Keys.Shift;
if (IsThisRowVisibleOnScreen(FocusedRow))
{ //focus is on the screen
int TopmostFocusableRow = GetTopmostFocusableRowFromRange(firstVisibleRow, lastVisibleRow);
if (TopmostFocusableRow == FocusedRow)
{ //need actual scrolling, ie. displaying new page
int FindFirstFocusableRow = FindFirstFocusableRowInUpDirection(firstVisibleRow);
if (FindFirstFocusableRow != -1)
{
NeedActualScrolling = true;
int NewProposedBottomRow = firstVisibleRow;
NewProposedTopRow = GetTopVisibleRowFromBottomRow(NewProposedBottomRow);
NewProposedFocusedRow = GetTopmostFocusableRowFromRange(NewProposedTopRow, NewProposedBottomRow);
if (NewProposedFocusedRow == -1)
{//There is no Focusable Row in the proposed page, so there need to be new page and focus found
NewProposedFocusedRow = FindFirstFocusableRowInUpDirection(NewProposedTopRow);
NewProposedTopRow = NewProposedFocusedRow;
}
}
else
{ //no focusable cells below -
//in this case we might scroll down page, leaving focus unchanged
//or move focus to the side like in arrow down handler
//this is only temporary
//MICK(24)
Selection.MoveActiveCell(-1, 0);
return;
}
}
else
{ //this time only move focus, wihout actual scrolling
Position newPosition = new Position(TopmostFocusableRow, Selection.ActivePosition.Column);
// AlanP: Sep 2013 We inhibit change events if SHIFT is pressed because we still have more calls to do
Selection.Focus(newPosition, true, shiftPressed);
}
}
else
{// focus is not on the screen, so actual scrolling is done always
NeedActualScrolling = true;
int NewProposedBottomRow = FocusedRow;
//.........这里部分代码省略.........
示例13: FindFirstFocusableRowInDownDirection
int FindFirstFocusableRowInDownDirection(int TopRow)
{
for (int k = TopRow; k < Rows.Count; k++)
{
Position newPosition = new Position(k, Selection.ActivePosition.Column);
if (Selection.CanReceiveFocus(newPosition)) return k;
}
return -1;
}
示例14: CustomScrollPageDown
public override void CustomScrollPageDown()
{
bool NeedActualScrolling=false;
int NewProposedTopRow=0;
int NewProposedFocusedRow=0;
Range rngFocusedCell = PositionToCellRange(Selection.ActivePosition);
//if there is no selection here (ActiveRow is undefined),
//put selection in the first possible cell
//confusing NAMING: Rows.IsRowVisible -> Rows.NotHidden - because it is not hidden,
// may be confused with visible on screen within visible page
if (rngFocusedCell.IsEmpty())
{
Selection.MoveActiveCell(1, 0);
return;
}
List<int> rows = GetVisibleRows(false);
if (rows.Count <= ActualFixedRows + 1)
{
Selection.MoveActiveCell(1, 0);
return;
};
int firstVisibleRow = rows[ActualFixedRows];
int lastVisibleRow = rows[rows.Count - 1];
// AlanP: Sep 2013 We need to know if SHIFT is pressed
bool shiftPressed = Control.ModifierKeys == Keys.Shift;
if (IsThisRowVisibleOnScreen(rngFocusedCell.Start.Row))
{ //focus is on the screen
int BottommostFocusableRow = GetBottommostFocusableRowFromRange(firstVisibleRow, lastVisibleRow);
if (rngFocusedCell.ContainsRow(BottommostFocusableRow))
{ //need actual scrolling, ie. displaying new page
int FindFirstFocusableRow = FindFirstFocusableRowInDownDirection(lastVisibleRow);
if (FindFirstFocusableRow != -1)
{
NeedActualScrolling = true;
NewProposedTopRow = lastVisibleRow;
int NewProposedBottomRow = GetBottomVisibleRowFromTopRow(NewProposedTopRow);
NewProposedFocusedRow = GetBottommostFocusableRowFromRange(NewProposedTopRow, NewProposedBottomRow);
if (NewProposedFocusedRow == -1)
{//There is no Focusable Row in the proposed page, so there need to be new page and focus found
NewProposedFocusedRow = FindFirstFocusableRowInDownDirection(NewProposedBottomRow);
NewProposedTopRow = GetTopVisibleRowFromBottomRow(NewProposedFocusedRow);
}
}
else
{ //no focusable cells below -
//in this case we might scroll down page, leaving focus unchanged
//or move focus to the side like in arrow down handler
//this is only temporary
//MICK(23)
Selection.MoveActiveCell(1, 0);
return;
}
}
else
{ //this time only move focus, wihout actual scrolling
Position newPosition = new Position(BottommostFocusableRow, Selection.ActivePosition.Column);
// AlanP: Sep 2013 We inhibit change events if SHIFT is pressed because we still have more calls to do
Selection.Focus(newPosition, true, shiftPressed);
}
}
else
{// focus is not on the screen, so actual scrolling is done always
NeedActualScrolling = true;
NewProposedTopRow = rngFocusedCell.Start.Row;
int NewProposedBottomRow = GetBottomVisibleRowFromTopRow(NewProposedTopRow);
NewProposedFocusedRow = GetBottommostFocusableRowFromRange(NewProposedTopRow, NewProposedBottomRow);
}
if (NeedActualScrolling)
{
int NewTopRow=0;
int NewFocusedRow=0;
GetValidScrollDown(NewProposedTopRow, NewProposedFocusedRow, out NewTopRow, out NewFocusedRow);
NewTopRow = ExtendTopRowByHiddenRows(NewTopRow);
base.CustomScrollPageToLine(NewTopRow - ActualFixedRows);
if (rngFocusedCell.ContainsRow(NewFocusedRow) == false)
{
Position newPosition = new Position(NewFocusedRow, Selection.ActivePosition.Column);
// AlanP: Sep 2013 We inhibit change events if SHIFT is pressed because we still have more calls to do
Selection.Focus(newPosition, true, shiftPressed);
}
}
//.........这里部分代码省略.........
示例15: ChangeDragCell
/// <summary>
/// Fired when the cell in the drag events change. For internal use only.
/// </summary>
/// <param name="cell"></param>
/// <param name="pDragEventArgs"></param>
public virtual void ChangeDragCell(CellContext cell, DragEventArgs pDragEventArgs)
{
if (cell.Position != mDragCellPosition)
{
if (mDragCellPosition.IsEmpty() == false)
Controller.OnDragLeave(new CellContext(this, mDragCellPosition, GetCell(mDragCellPosition)), pDragEventArgs);
if (cell.Position.IsEmpty() == false)
Controller.OnDragEnter(cell, pDragEventArgs);
mDragCellPosition = cell.Position;
}
}