Generalize

This sample demonstrates using the ArcGIS Runtime SDK for WPF to perform a geometry operation that takes graphic polyline with numerous vertices and returns a generalized polyline with less vertices. Additionally a SliderControl appears after the GeometryService completes that allows adjusting the opacity of the generalized polyline graphics layer for ease of viewing.

To use the sample, click the Generalize Line button to generalize the line feature. Original line and vertices are red. Generalized line a vertices are cyan. Use the slider to change the opacity of the generalized line. Zoom in on the graphics to see in better detail the difference between the original polyline and the generalized line.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalGeneralize"
    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">

        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="6" />
            <esri:SimpleMarkerSymbol x:Key="NewMarkerSymbol" Color="#FF00FFFF" Size="6" />
            <esri:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="#AAFF0000" Width="2" />
            <esri:SimpleLineSymbol x:Key="NewLineSymbol" Color="#AA00FFFF" Width="2"/>
            <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="-14000000,4000000,-12000000,6000000" Background="#FFE3E3E3" MinimumResolution="500">
            <esri:ArcGISLocalTiledLayer ID="Shaded Relief" Path="..\\Data\\TPKs\\Topographic.tpk"/>
            <esri:GraphicsLayer ID="OriginalLineGraphicsLayer" />
            <esri:GraphicsLayer ID="GeneralizedLineGraphicsLayer" />
        </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="Click the Generalize Line button to generalize the line feature.  Original line and vertices are red.  Generalized line a vertices are cyan.  Use the slider to change the opacity of the generalized line." 
                           Width="400" TextAlignment="Left"  TextWrapping="Wrap" Foreground="Black" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
                    <Button Content="Generalize Line" Margin="0,5,5,0" x:Name="GeneralizeButton" 
                             Click="GeneralizeButton_Click" IsEnabled="False" />
                </StackPanel>
                <StackPanel x:Name="SliderStackPanel" Margin="5,5,5,5" Orientation="Horizontal" 
                                HorizontalAlignment="Center" Visibility="Collapsed" >
                    <TextBlock FontSize="9" Foreground="Black" Text="0" />
                    <Slider x:Name="GeneralizeLayersOpacity" Minimum="0" Maximum="1" SmallChange="0.01" 
                                LargeChange="0.1" Value="0.75" Orientation="Horizontal" 
                                ValueChanged="GeneralizeLayerOpacity_ValueChanged" Width="120" />
                    <TextBlock FontSize="9" Foreground="Black" Text="100" />
                </StackPanel>
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014