Difference Online

This sample demonstrates using an ESRI.ArcGIS.Client.Tasks GeometryService that takes an input polygon that cuts across another existing polygon graphic to return the different between the two polygons.

To use the sample, create a polygon on the map that intersects the existing graphic on the map (red). When complete the difference between the polygon and the original graphics will be displayed (yellow). Click the Reset button to remove the results.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.Difference"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#88FF0000" BorderBrush="Red" />
            <esri:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Red" Width="2" />
            <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="8" />
            <esri:SimpleFillSymbol x:Key="DrawFillSymbol" Fill="#8800FFFF" BorderBrush="Cyan" />
            <esri:SimpleFillSymbol x:Key="DifferenceFillSymbol" Fill="#88FFFF00" BorderBrush="Yellow" />
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Extent="-117.5,32.5,-116.5,35.5">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
                                                 Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
            <esri:GraphicsLayer ID="InputGraphicsLayer">
                <esri:GraphicsLayer.Graphics >
                    <esri:Graphic Symbol="{StaticResource DefaultFillSymbol}">
                        <esri:Polygon>
                            <esri:Polygon.SpatialReference>
                                <esri:SpatialReference WKID="4326"/>
                            </esri:Polygon.SpatialReference>
                            <esri:Polygon.Rings>
                                <esri:PointCollection>-116.5,33 -116.5,34 -116,34 -116,33 -116.5,33</esri:PointCollection>
                            </esri:Polygon.Rings>
                        </esri:Polygon>
                    </esri:Graphic>
                    <esri:Graphic Symbol="{StaticResource DefaultFillSymbol}">
                        <esri:Polygon>
                            <esri:Polygon.SpatialReference>
                                <esri:SpatialReference WKID="4326"/>
                            </esri:Polygon.SpatialReference>
                            <esri:Polygon.Rings>
                                <esri:PointCollection>-118,34 -118,35 -117.5,35 -117.5,34 -118,34</esri:PointCollection>
                            </esri:Polygon.Rings>
                        </esri:Polygon>
                    </esri:Graphic>
                    <esri:Graphic Symbol="{StaticResource DefaultFillSymbol}">
                        <esri:Polygon>
                            <esri:Polygon.SpatialReference>
                                <esri:SpatialReference WKID="4326"/>
                            </esri:Polygon.SpatialReference>
                            <esri:Polygon.Rings>
                                <esri:PointCollection>-117.3,34 -116.3,34 -116.3,33.5 -117.3,33.5 -117.3,34</esri:PointCollection>
                            </esri:Polygon.Rings>
                        </esri:Polygon>
                    </esri:Graphic>
                </esri:GraphicsLayer.Graphics>
            </esri:GraphicsLayer>
            <esri:GraphicsLayer ID="OutputGraphicsLayer" />
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" >
            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical" Margin="30,20,20,30" >
                <TextBlock x:Name="ResponseTextBlock" Text="Create a polygon on the map that intersects the existing graphic on the map (red). When complete the difference between the polygon and the original graphics will be displayed (yellow).  Click the Reset button to remove the results."  
                           Width="400" TextAlignment="Left"  TextWrapping="Wrap" Foreground="Black"/>
                <Button Content="Reset" Margin="0,5,5,0" x:Name="ResetButton" 
                             Click="ResetButton_Click" IsEnabled="False" Width="150" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
Sample code usage restrictions
5/16/2014