本文整理汇总了C#中Cell.TranslatePoint方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.TranslatePoint方法的具体用法?C# Cell.TranslatePoint怎么用?C# Cell.TranslatePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell.TranslatePoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BringIntoViewScrollingCell
private bool BringIntoViewScrollingCell( Cell cell, FrameworkElement container, RequestBringIntoViewEventArgs e )
{
Debug.Assert( cell != null );
Debug.Assert( container != null );
// The cell must be measured/arranged for the BringIntoView to correctly reacts
if( this.ForceScrollingCellToLayout( cell ) )
{
container.UpdateLayout();
}
var fixedWidth = this.GetFixedWidth();
var scrollingPanel = this.ScrollingCellsDecorator;
var scrollingArea = new Rect( scrollingPanel.TranslatePoint( FixedCellPanel.EmptyPoint, this ),
new Size( this.ParentScrollViewer.ViewportWidth - fixedWidth, scrollingPanel.ActualHeight ) );
var cellArea = new Rect( cell.TranslatePoint( FixedCellPanel.EmptyPoint, this ),
new Size( cell.ParentColumn.ActualWidth, cell.ActualHeight ) );
// The cell is larger than the scrolling area.
if( cellArea.Width > scrollingArea.Width )
{
var targetObject = e.TargetObject as UIElement;
var targetRect = e.TargetRect;
// Try to narrow the area within the cell that we clearly want to bring into view.
if( ( targetObject != null ) && ( targetObject != cell || !targetRect.IsEmpty ) )
{
Debug.Assert( targetObject.IsDescendantOf( cell ) );
if( targetRect.IsEmpty )
{
targetRect = new Rect( new Point( 0d, 0d ), targetObject.RenderSize );
}
if( targetRect.Width <= scrollingArea.Width )
{
var offset = targetObject.TranslatePoint( FixedCellPanel.EmptyPoint, cell );
var location = cellArea.Location;
location.Offset( offset.X, offset.Y );
cellArea.Location = location;
cellArea.Size = targetRect.Size;
}
}
}
if( ( cellArea.Left <= scrollingArea.Left ) && ( cellArea.Right >= scrollingArea.Right ) )
{
// Ensure to bring the container into view vertically.
container.BringIntoView();
}
else if( cellArea.Left < scrollingArea.Left )
{
// The ScrollViewer's extent width includes the fixed section. We must offset the target area or the cell
// will come into view under the fixed panel.
cellArea.X -= fixedWidth;
this.BringIntoView( cellArea );
}
else if( cellArea.Right > scrollingArea.Right )
{
this.BringIntoView( cellArea );
}
// The cell is fully visible.
else
{
// Ensure to bring the container into view vertically.
container.BringIntoView();
}
return true;
}
示例2: Rect
bool IVirtualizingCellsHost.BringIntoView( Cell cell )
{
DataGridContext dataGridContext = DataGridControl.GetDataGridContext( this );
if( dataGridContext == null )
return false;
TableViewColumnVirtualizationManager columnVirtualizationManager = dataGridContext.ColumnVirtualizationManager as TableViewColumnVirtualizationManager;
if( columnVirtualizationManager == null )
return false;
Rect cellRect = new Rect();
cellRect.Width = cell.ParentColumn.Width;
cellRect.Height = cell.ActualHeight;
string targetFieldName = cell.FieldName;
DataGridItemsHost itemsHost = dataGridContext.DataGridControl.ItemsHost as DataGridItemsHost;
IScrollInfo scrollInfo = itemsHost as IScrollInfo;
Debug.Assert( scrollInfo != null );
// Fixed Cells are always visible
if( !columnVirtualizationManager.FixedFieldNames.Contains( targetFieldName ) )
{
// The Cell must be measured/arranged for the BringIntoView to correctly reacts
bool isCellLayouted = !this.ForceScrollingCellToLayout( cell );
// Use the DataGridControl.Container attached property to assert a container is always returned even if the container is in FixedHeaders or FixedFooters
FrameworkElement container = DataGridControl.GetContainer( cell.ParentRow );
// Ensure to call UpdateLayout to be sure the offset returned are the correct ones.
if( ( !isCellLayouted ) && ( container != null ) )
{
container.UpdateLayout();
}
double containerToCellsHostWidth = this.TranslatePoint( FixedCellPanel.EmptyPoint, container ).X;
double viewportWidth = scrollInfo.ViewportWidth;
double fixedColumnWidth = columnVirtualizationManager.FixedColumnsWidth;
Point cellToScrollingCellsDecorator = cell.TranslatePoint( FixedCellPanel.EmptyPoint, this.ScrollingCellsDecorator );
// If the Cell's left edge is not fully visible, but displays its full content in the Viewport because its width is still
// greater than the Viewport, let the ScrollViewer process any events that would have requested a BringIntoView
if( ( cellRect.Width - Math.Abs( cellToScrollingCellsDecorator.X ) ) >= ( viewportWidth - fixedColumnWidth ) )
{
// The cell can't be more into view horizontally, but ensure to bring into view the container vertically.
if( container != null )
{
container.BringIntoView();
}
return true;
}
double scrollViewerDesiredOffset = 0;
if( cellToScrollingCellsDecorator.X < 0 )
{
scrollViewerDesiredOffset = cellToScrollingCellsDecorator.X;
}
else
{
// The Cell's left edge is visible in the Viewport
double cellRightEdgeOffset = ( cellToScrollingCellsDecorator.X + cellRect.Width );
// Verify if the Cell's right edge is visible in the ViewPort
Point cellToItemsHost = cell.TranslatePoint( new Point( cellRect.Width, 0 ), itemsHost );
double rightSideOutOfViewOffset = ( cellToItemsHost.X - viewportWidth );
// If the right edge is out of Viewport, ensure to bring into view the out of view part
if( rightSideOutOfViewOffset > 0 )
{
// Ensure to bring into view the right edge, but we don't want to scroll to far and hide the left edge.
double avoidHiddingLeftEdgeCorrectedOffset = Math.Max( 0, ( rightSideOutOfViewOffset - cellToScrollingCellsDecorator.X ) );
// The desired offset of the rectangle is the left edge of the Cell and since we specified the width, IScrollInfo.MakeVisible
// will ensure to scroll horizontally so this rectangle is fully visible
scrollViewerDesiredOffset = cellToItemsHost.X - cellRect.Width - avoidHiddingLeftEdgeCorrectedOffset;
}
else
{
// No need to precise a Rect to bring into view since the Cell is already fully visible. Only call BringIntoView on the container
// to be sure it will be fully visible vertically.
if( container != null )
{
container.BringIntoView();
}
return true;
}
}
// We computed the desired offset according to the ScrollViewer.Content ( ItemsHost in the DataGridControl)
// translate it to a point accoring to the FixedCellPanel to ensure to bring this point into view
cellRect.X = itemsHost.TranslatePoint( new Point( scrollViewerDesiredOffset, 0 ), this ).X;
}
else
{
// We must consider the actual position of the Cell according to the FixedCellPanel in order to be sure we don't force
// an horizontal change. The fixed Cells are always visible so there is no need for horizontal change.
double desiredOffset = -1;
//.........这里部分代码省略.........