<UserControl x:Class="EditorDeMapas.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:userControls="clr-namespace:ESRI.ArcGIS.SilverlightMapApp"
xmlns:actions="clr-namespace:ESRI.ArcGIS.SilverlightMapApp.Actions">
<UserControl.Resources>
<esriSymbols:SimpleFillSymbol x:Name="Default" Fill="#33FF0000" BorderBrush="Red" BorderThickness="2" />
<esriSymbols:SimpleFillSymbol x:Name="area" ControlTemplate="{StaticResource EstiloDefaultFillSymbol}"/>
<esriSymbols:SimpleLineSymbol x:Name="linha" ControlTemplate="{StaticResource EstiloLineSymbol}"/>
<esriSymbols:SimpleMarkerSymbol x:Name="ponto" ControlTemplate="{StaticResource EstiloMarkerSymbol}"/>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="{StaticResource BaseColor}">
<Border>
<esri:Map x:Name="mapa" Extent="-13054165,3850112,-13027133,3863559" esri:Editor.SnapDistance="20" esri:Editor.SnapKey="S">
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
<esri:FeatureLayer ID="featureParaPontos"
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/0"
AutoSave="False"
Mode="OnDemand"
ValidateEdits="True"
DisableClientCaching="True" />
<esri:FeatureLayer ID="featureParaLinha"
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/1"
AutoSave="False"
Mode="OnDemand"
ValidateEdits="True"
DisableClientCaching="True" />
<esri:FeatureLayer ID="featureParaArea"
Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/2"
AutoSave="False"
Mode="OnDemand"
ValidateEdits="True"
DisableClientCaching="True" />
</esri:Map>
</Border>
<Border VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,5,5,0">
<Border.Resources>
<esri:Editor x:Key="editorGeral" Map="{Binding ElementName=mapa}" LayerIDs="featureParaPontos,featureParaLinha,featureParaArea"/>
<esri:Editor x:Key="editorPonto" Map="{Binding ElementName=mapa}" LayerIDs="featureParaPontos"/>
<esri:Editor x:Key="editorLinha" Map="{Binding ElementName=mapa}" LayerIDs="featureParaLinha"/>
<esri:Editor x:Key="editorArea" Map="{Binding ElementName=mapa}" LayerIDs="featureParaArea"/>
</Border.Resources>
<StackPanel DataContext="{StaticResource editorGeral}">
<Button Content="Select" Command="{Binding Select}" CommandParameter="New" />
<Button Content="Add Selection" Command="{Binding Select}" CommandParameter="Add" />
<Button Content="Unselect" Command="{Binding Select}" CommandParameter="Remove" />
<Button Content="Clear Selection" Command="{Binding ClearSelection}" />
<Button Content="Add Default" Command="{Binding Add}" />
<StackPanel DataContext="{StaticResource editorPonto}">
<Button Content="Add Point" Command="{Binding Add}" CommandParameter="ponto"/>
</StackPanel>
<StackPanel DataContext="{StaticResource editorLinha}">
<Button Content="Add Line" Command="{Binding Add}" CommandParameter="{StaticResource linha}"/>
</StackPanel>
<StackPanel DataContext="{StaticResource editorArea}">
<Button Content="Add Area" Command="{Binding Add}" CommandParameter="{StaticResource area}"/>
</StackPanel>
<Button Content="Save" Command="{Binding Save}" />
<Button Content="Delete Selected" Command="{Binding DeleteSelected}" />
<!--<CheckBox IsChecked="{Binding Path=Freehand, Mode=TwoWay}" Content="Freehand Draw" VerticalAlignment="Center" />-->
</StackPanel>
</Border>
</Grid>
</UserControl><UserControl x:Class="EditorDeMapas.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:userControls="clr-namespace:ESRI.ArcGIS.SilverlightMapApp"
xmlns:actions="clr-namespace:ESRI.ArcGIS.SilverlightMapApp.Actions">
<UserControl.Resources>
<esriSymbols:SimpleFillSymbol x:Name="Default" Fill="#33FF0000" BorderBrush="Red" BorderThickness="2" />
<esriSymbols:SimpleFillSymbol x:Name="area" ControlTemplate="{StaticResource EstiloDefaultFillSymbol}"/>
<esriSymbols:SimpleLineSymbol x:Name="linha" ControlTemplate="{StaticResource EstiloLineSymbol}"/>
<esriSymbols:SimpleMarkerSymbol x:Name="ponto" ControlTemplate="{StaticResource EstiloMarkerSymbol}"/>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="{StaticResource BaseColor}">
<Border>
<esri:Map x:Name="mapa" Background="Aqua" esri:Editor.SnapDistance="20" esri:Editor.SnapKey="S">
<esri:ArcGISDynamicMapServiceLayer ID="Mapa Base"
ImageFormat="JPG"
Url="http://192.168.5.4/ArcGIS/rest/services/MDSalvador/1MapaBase14-01-2011/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="Sistema de Transporte"
ImageFormat="PNG32"
Url="http://192.168.5.4/ArcGIS/rest/services/MDSalvador/5MapaTopo14-01-2011/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="Bairros"
ImageFormat="PNG32"
Url="http://192.168.5.4/ArcGIS/rest/services/MDSalvador/3SistemadeTransporte14-01-2011/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="Mapa Topo"
ImageFormat="PNG32"
Url="http://192.168.5.4/ArcGIS/rest/services/MDSalvador/4Bairros03-11-2010-1/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="Pontos de Referencia"
ImageFormat="PNG32"
Url="http://192.168.5.4/ArcGIS/rest/services/MDSalvador/6PontosDeReferencia03-11-2010-1/MapServer"/>
<esri:FeatureLayer ID="featureParaArea"
Url="http://192.168.5.104/ArcGIS/rest/services/Projeto_SL/FeatureServer/2"
AutoSave="False"
Mode="OnDemand"
ValidateEdits="True"
Visible="True"
DisableClientCaching="True" />
<esri:FeatureLayer ID="featureParaLinha"
Url="http://192.168.5.104/ArcGIS/rest/services/Projeto_SL/FeatureServer/1"
AutoSave="False"
Mode="Snapshot"
ValidateEdits="True"
Visible="True"
DisableClientCaching="False" />
<esri:FeatureLayer ID="featureParaPontos"
Url="http://192.168.5.104/ArcGIS/rest/services/Projeto_SL/FeatureServer/0"
AutoSave="False"
Mode="Snapshot"
ValidateEdits="True"
Visible="True"
DisableClientCaching="False" />
</esri:Map>
</Border>
<esri:MapProgressBar Map="{Binding ElementName=mapa}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="12" Margin="0" BorderBrush="#FF18428C" Foreground="#FF18428C" Background="#FF26A1E2" d:LayoutOverrides="Height" Grid.Row="1"/>
<Border VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,5,5,0">
<Border.Resources>
<esri:Editor x:Key="editorGeral" Map="{Binding ElementName=mapa}" LayerIDs="featureParaPontos,featureParaLinha,featureParaArea"/>
<esri:Editor x:Key="editorPonto" Map="{Binding ElementName=mapa}" LayerIDs="featureParaPontos"/>
<esri:Editor x:Key="editorLinha" Map="{Binding ElementName=mapa}" LayerIDs="featureParaLinha"/>
<esri:Editor x:Key="editorArea" Map="{Binding ElementName=mapa}" LayerIDs="featureParaArea"/>
</Border.Resources>
<StackPanel DataContext="{StaticResource editorGeral}">
<Button Content="Select" Command="{Binding Select}" CommandParameter="New" />
<Button Content="Add Selection" Command="{Binding Select}" CommandParameter="Add" />
<Button Content="Unselect" Command="{Binding Select}" CommandParameter="Remove" />
<Button Content="Clear Selection" Command="{Binding ClearSelection}" />
<Button Content="Add Default" Command="{Binding Add}" />
<StackPanel DataContext="{StaticResource editorPonto}">
<Button Content="Add Point" Command="{Binding Add}"/>
</StackPanel>
<StackPanel DataContext="{StaticResource editorLinha}">
<Button Content="Add Line" Command="{Binding Add}"/>
</StackPanel>
<StackPanel DataContext="{StaticResource editorArea}">
<Button Content="Add Area" Command="{Binding Add}"/>
</StackPanel>
<Button Content="Save" Command="{Binding Save}" />
<Button Content="Delete Selected" Command="{Binding DeleteSelected}" />
</StackPanel>
</Border>
</Grid>
</UserControl>
private void draw_DrawComplete(object sender, DrawEventArgs e)
{
if (layer.LayerInfo.GeometryType == GeometryType.Polygon)
{
graphic.Attributes[layer.LayerInfo.TypeIdField] = typeId;
Graphic graphic = new Graphic();
Polygon polygon = e.Geometry is Polygon ? result as Polygon : new Polygon();
if (e.Geometry is Envelope)
polygon.Rings.Add(GetPointCollectionFromEnvelope(result as Envelope));
graphic.Geometry = polygon;
layer.Graphics.Add(graphic);
}
}
private PointCollection GetPointCollectionFromEnvelope(Envelope env)
{
PointCollection pc = new PointCollection();
pc.Add(new MapPoint(env.XMin, env.YMin));
pc.Add(new MapPoint(env.XMin, env.YMax));
pc.Add(new MapPoint(env.XMax, env.YMax));
pc.Add(new MapPoint(env.XMax, env.YMin));
pc.Add(new MapPoint(env.XMin, env.YMin));
return pc;
}
}