CombinedGeometry Class WPF in VB.NET

In this article you will learn about the CombinedGeometry Class of WPF.
  • 2200

As you see an GeometryGroup Classes example in my previous article, now we see the CombineGeometry in this article.

CombinedGeometry: CombinedGeometry is combining shapes that overlap, and where neither shape contains the other completely, CombinedGeometry takes just two geometries, which you supply using the Geometry1 and Geometry2 properties. A CombinedGeometry uses a specified boolean operation to combine the area described by two Geometry objects. The static Combine method of the Geometry class behaves in exactly the same manner as the CombinedGeometry object.

CombinedGeometry has a GeometryCombineMode attribute to set the combine mode. It can get one of following values.To understand these modes apply these operations to two sets in mathematics.

  • Union: New shape contains all points of two older shapes.  This is the default value.

  • Intersect: New shape contains all points that are shared between two shapes.

  • Xor: New shape contains all points between two older shapes except what is shared between them.

  • Exclude: New shape contains all points between first shape and not second shape.

Example of CombinedGeometry
Union:

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Path Fill="Pink" Stroke="Red" Margin="10">
        <Path.Data>
            <CombinedGeometry GeometryCombineMode="Union">
                <CombinedGeometry.Geometry1>
                    <RectangleGeometry Rect="5,5 120,80"></RectangleGeometry>
                </CombinedGeometry.Geometry1>
                <CombinedGeometry.Geometry2>
                    <EllipseGeometry Center="105,45" RadiusX="85" RadiusY="40"></EllipseGeometry>
                </CombinedGeometry.Geometry2>
            </CombinedGeometry>
        </Path.Data>
    </Path>
</
Window>

Output Window

cg1.gif

Conclusion

Hope this is clear you to the CombinedGeometry class in WPF. Remaining part of this article you will see my next article.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.