本文整理汇总了C#中System.Windows.Media.MatrixTransform.TryTransform方法的典型用法代码示例。如果您正苦于以下问题:C# MatrixTransform.TryTransform方法的具体用法?C# MatrixTransform.TryTransform怎么用?C# MatrixTransform.TryTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.MatrixTransform
的用法示例。
在下文中一共展示了MatrixTransform.TryTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformFromContent
/// <summary>
/// Transforms point to content's coordinate system.
/// </summary>
/// <param name="point">Point to which transform is applied.</param>
private void TransformFromContent(ref Point point)
{
Point newPoint;
// DocumentPage.Visual for printing scenarions needs to be always returned
// in LeftToRight FlowDirection. Hence, if the document is RightToLeft,
// mirroring transform need to be applied to the content of DocumentPage.Visual.
FlowDirection flowDirection = (FlowDirection)_owner.StructuralCache.PropertyOwner.GetValue(FlowDocument.FlowDirectionProperty);
if (flowDirection == FlowDirection.RightToLeft)
{
MatrixTransform transform = new MatrixTransform(-1.0, 0.0, 0.0, 1.0, _owner.Size.Width, 0.0);
transform.TryTransform(point, out newPoint);
point = newPoint;
}
}
示例2: GetPagePosition
/// <summary>
/// Returns the ContentPosition for the given page.
/// </summary>
/// <param name="page">Document page.</param>
/// <returns>Returns the ContentPosition for the given page.</returns>
/// <exception cref="ArgumentException">
/// Throws ArgumentException if the page is not valid.
/// </exception>
public override ContentPosition GetPagePosition(DocumentPage page)
{
FlowDocumentPage flowDocumentPage;
ITextView textView;
ITextPointer position;
Point point, newPoint;
MatrixTransform transform;
// Ensure usage from just one Dispatcher object.
// FlowDocumentPaginator runs its own layout, hence there is a need
// to protect it from random access from other threads.
_dispatcherObject.VerifyAccess();
// ContentPosition cannot be null.
if (page == null)
{
throw new ArgumentNullException("page");
}
// DocumentPage must be of appropriate type.
flowDocumentPage = page as FlowDocumentPage;
if (flowDocumentPage == null || flowDocumentPage.IsDisposed)
{
return ContentPosition.Missing;
}
// DocumentPage.Visual for printing scenarions needs to be always returned
// in LeftToRight FlowDirection. Hence, if the document is RightToLeft,
// mirroring transform need to be applied to the content of DocumentPage.Visual.
point = new Point(0, 0);
if (_document.FlowDirection == FlowDirection.RightToLeft)
{
transform = new MatrixTransform(-1.0, 0.0, 0.0, 1.0, flowDocumentPage.Size.Width, 0.0);
transform.TryTransform(point, out newPoint);
point = newPoint;
}
// Get TextView for DocumentPage. Position of the page is calculated through hittesting
// the top-left of the page. If position cannot be found, the start position of
// the first range for TextView is treated as ContentPosition for the page.
textView = (ITextView)((IServiceProvider)flowDocumentPage).GetService(typeof(ITextView));
Invariant.Assert(textView != null, "Cannot access ITextView for FlowDocumentPage.");
Invariant.Assert(textView.TextSegments.Count > 0, "Page cannot be empty.");
position = textView.GetTextPositionFromPoint(point, true);
if (position == null)
{
position = textView.TextSegments[0].Start;
}
return (position is TextPointer) ? (ContentPosition)position : ContentPosition.Missing;
}