本文整理汇总了C#中System.Windows.Media.Geometry.GetAsPathGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# Geometry.GetAsPathGeometry方法的具体用法?C# Geometry.GetAsPathGeometry怎么用?C# Geometry.GetAsPathGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Geometry
的用法示例。
在下文中一共展示了Geometry.GetAsPathGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeometryHitTestParameters
/// <summary>
/// The constructor takes the geometry to hit test with.
/// </summary>
public GeometryHitTestParameters(Geometry geometry) : base()
{
// This ctor guarantees that we are initialized in the following way:
//
// 1. The geometry provided by the user is unmodified
// 2. _hitGeometryInternal is a PathGeometry equivilent to the supplied geometry
// 3. _hitGeometryInternal.Tranform is a MatrixTransform equivilent to the supplied
// geometry.Transform
// 4. _origBounds is the untransformed bounds of the _hitGeometryInternal (inner space).
// 5. _bounds is the transformed bounds of the _hitGeometryInternal (outer space).
// 6. _matrixStack is an empty stack.
if (geometry == null)
{
throw new ArgumentNullException("geometry");
}
// Convert the Geometry to an equivilent PathGeometry up front to prevent
// conversion on every call to DoesContainWithDetail. If the geometry is
// animate this also has the side effect of eliminating animation interplay.
_hitGeometryInternal = geometry.GetAsPathGeometry();
// If GetAsPathGeometry was a no-op, force the copy because we do not
// went to modify the user's Geometry.
if (object.ReferenceEquals(_hitGeometryInternal, geometry))
{
_hitGeometryInternal = _hitGeometryInternal.Clone();
}
// Convert _hitGeometryInternal.Transform to an equivilent MatrixTransform
// so that we can aggregate in PushMatrix/PopMatrix without building a
// TransformCollection.
Transform origTransform = _hitGeometryInternal.Transform;
MatrixTransform newTransform = new MatrixTransform();
_hitGeometryInternal.Transform = newTransform;
// Before we initialize MatrixTransform.Matrix, cache the bounds of this
// geometry without any transforms.
_origBounds = _hitGeometryInternal.Bounds;
// If we had a non-Identity transform, update our MatrixTransform.Matrix
// with its Value. (Note that when GetAsPathGeometry *isn't* a no-op
// it applies the transform to the figures and returns with a Geometry
// with an identity Transform.)
if (origTransform != null && !origTransform.IsIdentity)
{
newTransform.Matrix = origTransform.Value;
}
// Initialize the current transformed bounds of this Geometry
_bounds = _hitGeometryInternal.Bounds;
_matrixStack = new MatrixStack();
}
示例2: CreateFromGeometry
/// <summary>
/// Static "CreateFromGeometry" method which creates a new PathGeometry from the Geometry specified.
/// </summary>
/// <param name="geometry">
/// Geometry - The Geometry which will be used as the basis for the newly created
/// PathGeometry. The new Geometry will be based on the current value of all properties.
/// </param>
public static PathGeometry CreateFromGeometry(Geometry geometry)
{
if (geometry == null)
{
return null;
}
return geometry.GetAsPathGeometry();
}