1 <UserControl x:Class="GraphicsAction.MainPage" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:esri="http://schemas.esri.com/arcgis/client/2009" 7 xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors" 8 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 9 mc:Ignorable="d" 10 d:DesignHeight="300" d:DesignWidth="400"> 11 12 <Grid x:Name="LayoutRoot" Background="White"> 13 14 <Grid.Resources> 15 <LinearGradientBrush x:Key="CommonGradient" StartPoint="0.5,0" EndPoint="0.5,1"> 16 <GradientStop Offset="0" Color="#99919191"/> 17 <GradientStop Offset="0.25" Color="#aa919191"/> 18 <GradientStop Offset="0.75" Color="#cc919191"/> 19 </LinearGradientBrush> 20 <Style x:Key="CommonBorder" TargetType="Border"> 21 <Setter Property="BorderBrush" Value="White" /> 22 <Setter Property="BorderThickness" Value="1" /> 23 <Setter Property="CornerRadius" Value="5" /> 24 <Setter Property="Background" Value="{StaticResource CommonGradient}" /> 25 <Setter Property="Opacity" Value="1" /> 26 </Style> 27 <Style x:Key="MenuItem" TargetType="Button"> 28 <Setter Property="Foreground" Value="White"/> 29 <Setter Property="HorizontalAlignment" Value="Left"/> 30 <Setter Property="VerticalAlignment" Value="Center"/> 31 <Setter Property="HorizontalContentAlignment" Value="Left"/> 32 <Setter Property="FontSize" Value="12" /> 33 <Setter Property="Template"> 34 <Setter.Value> 35 <ControlTemplate TargetType="Button"> 36 <Grid> 37 <VisualStateManager.VisualStateGroups> 38 <VisualStateGroup x:Name="CommonStates"> 39 <VisualState x:Name="Normal"> 40 <Storyboard> 41 <DoubleAnimation To="0" FillBehavior="HoldEnd" 42 Storyboard.TargetName="menuItemHighlight" 43 Storyboard.TargetProperty="Opacity" 44 Duration="0:0:0.3" /> 45 </Storyboard> 46 </VisualState> 47 <VisualState x:Name="MouseOver"> 48 <Storyboard> 49 <DoubleAnimation To="0.15" FillBehavior="HoldEnd" 50 Storyboard.TargetName="menuItemHighlight" 51 Storyboard.TargetProperty="Opacity" 52 Duration="0:0:0.3" /> 53 </Storyboard> 54 </VisualState> 55 </VisualStateGroup> 56 </VisualStateManager.VisualStateGroups> 57 <Rectangle x:Name="menuItemHighlight" Fill="#FFFFFFFF" 58 Opacity="0" Margin="0" /> 59 <ContentPresenter 60 x:Name="contentPresenter" 61 Content="{TemplateBinding Content}" 62 ContentTemplate="{TemplateBinding ContentTemplate}" 63 VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 64 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 65 Margin="{TemplateBinding Padding}" /> 66 </Grid> 67 </ControlTemplate> 68 </Setter.Value> 69 </Setter> 70 </Style> 71 <esri:UniqueValueRenderer x:Key="GraphicsLayerLineSymbol"> 72 <esri:UniqueValueRenderer.DefaultSymbol> 73 <esri:SimpleLineSymbol Width="5"> 74 <esri:SimpleLineSymbol.Color> 75 <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 76 <GradientStop Color="Yellow" Offset="0"/> 77 <GradientStop Color="#FFB45050" Offset="1"/> 78 </LinearGradientBrush> 79 </esri:SimpleLineSymbol.Color> 80 </esri:SimpleLineSymbol> 81 </esri:UniqueValueRenderer.DefaultSymbol> 82 </esri:UniqueValueRenderer> 83 <esri:SimpleFillSymbol x:Key="GraphicsLayerFillSymbol"> 84 <esri:SimpleFillSymbol.Fill> 85 <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> 86 <GradientStop Color="Yellow" Offset="0.0" /> 87 <GradientStop Color="Red" Offset="0.25" /> 88 <GradientStop Color="Blue" Offset="0.75" /> 89 <GradientStop Color="LimeGreen" Offset="1.0" /> 90 </LinearGradientBrush> 91 </esri:SimpleFillSymbol.Fill> 92 </esri:SimpleFillSymbol> 93 </Grid.Resources> 94 95 <esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000"> 96 <esri:ArcGISTiledMapServiceLayer ID="MyBaseLayer" 97 Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> 98 <esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource GraphicsLayerLineSymbol}" /> 99 <esri:GraphicsLayer ID="MyQueryResultsGraphicsLayer" Opacity="0.5" /> 100 </esri:Map> 101 102 <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="10" > 103 <Border Style="{StaticResource CommonBorder}" Padding="10,3,10,3"> 104 <Border.Effect> 105 <DropShadowEffect/> 106 </Border.Effect> 107 <StackPanel> 108 <TextBlock Text="Graphics Actions" Foreground="White" FontSize="14" FontWeight="Bold" Margin="4" /> 109 <StackPanel Orientation="Horizontal" Margin="2"> 110 <StackPanel Orientation="Vertical" Margin="2"> 111 <Button Style="{StaticResource MenuItem}" 112 Content="Redline" HorizontalAlignment="Left" > 113 <i:Interaction.Triggers> 114 <i:EventTrigger EventName="Click"> 115 <esri:RedlineAction 116 Color="#FF32FF00" 117 DrawMode="Freehand" 118 GraphicsLayerID="MyGraphicsLayer" 119 TargetName="MyMap"/> 120 </i:EventTrigger> 121 </i:Interaction.Triggers> 122 </Button> 123 <Button Style="{StaticResource MenuItem}" 124 Content="Spatial Query" > 125 <i:Interaction.Triggers> 126 <i:EventTrigger EventName="Click"> 127 <esri:SpatialQueryAction 128 DrawMode="Rectangle" 129 LayerID="MyQueryResultsGraphicsLayer" 130 Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2" 131 Symbol="{StaticResource GraphicsLayerFillSymbol}" 132 TargetName="MyMap" /> 133 </i:EventTrigger> 134 </i:Interaction.Triggers> 135 </Button> 136 </StackPanel> 137 <Line X1="0" Y1="0" X2="0" Y2="1" Stretch="Fill" Stroke="White" StrokeThickness="1" /> 138 <StackPanel Orientation="Vertical" Margin="2"> 139 <Button Style="{StaticResource MenuItem}" Content="Clear" 140 HorizontalAlignment="Right" FontSize="12" > 141 <i:Interaction.Triggers> 142 <i:EventTrigger EventName="Click"> 143 <esri:ClearGraphicsAction 144 GraphicsLayerID="MyGraphicsLayer" 145 TargetName="MyMap" /> 146 </i:EventTrigger> 147 </i:Interaction.Triggers> 148 </Button> 149 <Button Style="{StaticResource MenuItem}" Content="Clear" FontSize="12" > 150 <i:Interaction.Triggers> 151 <i:EventTrigger EventName="Click"> 152 <esri:ClearGraphicsAction 153 GraphicsLayerID="MyQueryResultsGraphicsLayer" 154 TargetName="MyMap" /> 155 </i:EventTrigger> 156 </i:Interaction.Triggers> 157 </Button> 158 </StackPanel> 159 </StackPanel> 160 </StackPanel> 161 </Border> 162 </Grid> 163 164 </Grid> 165 </UserControl>