本文整理汇总了C#中System.Windows.Media.GeometryGroup.GetFlattenedPathGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryGroup.GetFlattenedPathGeometry方法的具体用法?C# GeometryGroup.GetFlattenedPathGeometry怎么用?C# GeometryGroup.GetFlattenedPathGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.GeometryGroup
的用法示例。
在下文中一共展示了GeometryGroup.GetFlattenedPathGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildVertexGeometry
/// <summary>
/// Returns the flattened geometry for the argument vertex. It does not take the transforms on the vertex into account.
/// </summary>
/// <param name="v"></param>
/// <returns></returns>
private static PathGeometry BuildVertexGeometry(Visual v)
{
GeometryGroup fromGeometry = new GeometryGroup();
fromGeometry.FillRule = FillRule.Nonzero;
WalkChildren((Visual)v, fromGeometry);
PathGeometry fromGeometryFlat = fromGeometry.GetFlattenedPathGeometry();
return fromGeometryFlat;
}
示例2: CombineGeometries
//---------------------------------------------------------//
/// <summary>
/// Combines two Geometries, offset by the specified amount.
/// </summary>
/// <param name="geometry1">The first geometry to combine.</param>
/// <param name="offset1">The offset of the first geometry relative to the second geometry, specified in puzzle piece units.</param>
/// <param name="geometry1">The second geometry to combine.</param>
/// <param name="offset1">The offset of the second geometry relative to the first geometry, specified in puzzle piece units.</param>
/// <returns>The combined geometry</returns>
private Geometry CombineGeometries(PuzzlePiece piece1, PuzzlePiece piece2)
{
// Get the geometires that will be joined
Geometry geometry1 = piece1.ClipShape;
Geometry geometry2 = piece2.ClipShape;
// Get the offset of each piece relative to the puzzle
Vector offset1InPixels = GetPieceTopLeftInScreenUnits(piece1);
Vector offset2InPixels = GetPieceTopLeftInScreenUnits(piece2);
// Use the offsets determined above to find the offset of each piece relative to the other piece
// Between the two offsets, only one offset will have a nonzero value for x and y. This could be
// the same offset, or different offsets. Possible combinations are (0,0) and (100, 100); (50, 0)
// and (0, 75) but not (10, 0) and (15, 0)
Vector relativeOffset1 = new Vector(Math.Max(0, Math.Round(offset1InPixels.X - offset2InPixels.X)), Math.Max(0, Math.Round(offset1InPixels.Y - offset2InPixels.Y)));
Vector relativeOffset2 = new Vector(Math.Max(0, Math.Round(offset2InPixels.X - offset1InPixels.X)), Math.Max(0, Math.Round(offset2InPixels.Y - offset1InPixels.Y)));
// Translate the geometries according to their offsets so they don't overlap when they're joined
geometry1.Transform = new TranslateTransform(relativeOffset1.X, relativeOffset1.Y);
geometry2.Transform = new TranslateTransform(relativeOffset2.X, relativeOffset2.Y);
// Make a new GeometryGroup
GeometryGroup newGeometry = new GeometryGroup();
newGeometry.FillRule = FillRule.Nonzero;
// Add the Geometries to the group
newGeometry.Children.Add(geometry1);
newGeometry.Children.Add(geometry2);
// Flatten the group and return it
return newGeometry.GetFlattenedPathGeometry();
}