Trim or Extend

This sample demonstrates using the ArcGIS Runtime SDK for WPF to perform a geometry operation that takes an input polyline and a set of other polyline graphics and returns either a trimmed or extended set of polyline graphics. If the input polyline crosses another polyline graphic a trim will occur where the two cross. If the input polyline does not cross the other polyline but crosses an imaginary ray that extends out from the other polyline that and extend will occur.

To use this sample, digitize a line that crosses over or near the end of one or more blue lines. Trimmed or extended lines are returned in red.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LocalTrimExtend"
    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:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Blue" Width="8" />
            <esri:SimpleLineSymbol x:Key="DrawLineSymbol" Color="Yellow" Width="3" />
            <esri:SimpleLineSymbol x:Key="ResultsLineSymbol" Color="Red" Width="4" />
            <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="-15000000,2000000,-7000000,8000000" Background="#FFE3E3E3">
            <esri:Map.Layers>
                <esri:ArcGISLocalTiledLayer ID="BaseMap" Path="..\\Data\\TPKs\\Topographic.tpk"/>
                <esri:GraphicsLayer ID="PolylineGraphicsLayer" x:Name="_polylineGraphicsLayer">
                    <esri:GraphicsLayer.Graphics>
                        <esri:Graphic Symbol="{StaticResource DefaultLineSymbol}">
                            <esri:Polyline x:Name="Polyline_0">
                                <esri:Polyline.Paths>
                                    <esri:PointCollection>-13222659,6689903 -13222659,2649896</esri:PointCollection>
                                </esri:Polyline.Paths>
                            </esri:Polyline>
                        </esri:Graphic>
                        <esri:Graphic Symbol="{StaticResource DefaultLineSymbol}">
                            <esri:Polyline x:Name="Polyline_1">
                                <esri:Polyline.Paths>
                                    <esri:PointCollection>-12330709,6270162 -12330709,3741232</esri:PointCollection>
                                </esri:Polyline.Paths>
                            </esri:Polyline>
                        </esri:Graphic>
                        <esri:Graphic Symbol="{StaticResource DefaultLineSymbol}">
                            <esri:Polyline x:Name="Polyline_2">
                                <esri:Polyline.Paths>
                                    <esri:PointCollection>-11144941,6417071 -11144941,2807299</esri:PointCollection>
                                </esri:Polyline.Paths>
                            </esri:Polyline>
                        </esri:Graphic>
                        <esri:Graphic Symbol="{StaticResource DefaultLineSymbol}">
                            <esri:Polyline x:Name="Polygline_3">
                                <esri:Polyline.Paths>
                                    <esri:PointCollection>-9277094,5098527 -9277094,4024548</esri:PointCollection>
                                </esri:Polyline.Paths>
                            </esri:Polyline>
                        </esri:Graphic>
                    </esri:GraphicsLayer.Graphics>
                </esri:GraphicsLayer>

                <esri:GraphicsLayer ID="ResultsGraphicsLayer" x:Name="_resultsGraphicsLayer"/>
            </esri:Map.Layers>
        </esri:Map>

        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,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" />
            <TextBlock x:Name="InfoTextBlock" Text="Digitize a line that crosses over or near the end of one or more blue lines.  Trimmed or extended lines are returned in red." 
                       Width="200" TextAlignment="Left" Margin="30,20,20,30" TextWrapping="Wrap" Foreground="Black" />
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014