更新:2007 年 11 月
命名空间:
System.Windows.Media 程序集:
PresentationCore(在 PresentationCore.dll 中)
用于 XAML 的 XMLNS:http://schemas.microsoft.com/winfx/xaml/presentation
Public NotInheritable Class CombinedGeometry _
Inherits Geometry
Dim instance As CombinedGeometry
public sealed class CombinedGeometry : Geometry
public ref class CombinedGeometry sealed : public Geometry
public final class CombinedGeometry extends Geometry
public final class CombinedGeometry extends Geometry
GeometryCombineMode 属性指定如何组合两个几何图形。请注意,CombinedGeometry 组合两个几何图形指定的区域,所以没有区域(例如 LineGeometry)的几何图形将在组合后消失。
几何图形可通过以下几种方式组合:使用 GeometryGroup、CombinedGeometry 或 Geometry 类的 Combine 方法。
使用 CombinedGeometry 执行联合操作时要谨慎,因为它会占用大量的 CPU 资源。大多数情况下,使用 GeometryGroup 或 AddGeometry 的效果更佳。
仅当存在下列情况之一时,才使用 CombinedGeometry:
Freezable 功能
此示例演示如何组合几何图形。若要组合两个几何图形,请使用 CombinedGeometry 对象。对要组合的两个几何图形,设置该对象的 Geometry1 和 Geometry2 属性,并将 GeometryCombineMode 属性(确定如何将这两个几何图形组合在一起)设置为 Union、Intersect、Exclude 或 Xor。
若要通过两个或两个以上的几何图形创建复合几何图形,可使用 GeometryGroup。
在下面的示例中,用 Exclude 几何图形组合模式定义了一个 CombinedGeometry。 Geometry1 和 Geometry2 定义为半径相同的圆,但是中心偏离 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the exclude combine mode. -->
<CombinedGeometry GeometryCombineMode="Exclude">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
使用 Exclude 模式组合的几何图形
.png)
在下面的标记中,用 Intersect 组合模式定义了一个 CombinedGeometry。 Geometry1 和 Geometry2 定义为半径相同的圆,但是中心偏离 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the intersect combine mode. -->
<CombinedGeometry GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
使用 Intersect 模式组合的几何图形
.png)
在下面的标记中,用 Union 组合模式定义了一个 CombinedGeometry。 Geometry1 和 Geometry2 定义为半径相同的圆,但是中心偏离 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the union combine mode. -->
<CombinedGeometry GeometryCombineMode="Union">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
使用 Union 模式组合的几何图形
.png)
在下面的标记中,用 Xor 组合模式定义了一个 CombinedGeometry。 Geometry1 和 Geometry2 定义为半径相同的圆,但是中心偏离 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the XOR combine mode. -->
<CombinedGeometry GeometryCombineMode="Xor">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
使用 Xor 模式组合的几何图形
System..::.Object
System.Windows.Threading..::.DispatcherObject
System.Windows..::.DependencyObject
System.Windows..::.Freezable
System.Windows.Media.Animation..::.Animatable
System.Windows.Media..::.Geometry
System.Windows.Media..::.CombinedGeometry
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5、3.0
参考
其他资源