silverlight查询功能
来源:互联网 发布:js移除节点 编辑:程序博客网 时间:2024/05/17 22:56
<UserControl x:Class="查询.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:slData="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Size="8" Color="Red" Style="Circle" /> <esri:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Red" Width="6" /> <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" BorderBrush="Red" BorderThickness="2" Fill="#50FF0000"/> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="150" /> </Grid.RowDefinitions> <esri:Map x:Name="MyMap" Grid.Row="0" WrapAround="True"> <esri:ArcGISDynamicMapServiceLayer ID="TopoLayer" Url="http://localhost/ArcGIS/rest/services/Map/AnHui/MapServer"/> <esri:FeatureLayer ID="point" Url="http://localhost/ArcGIS/rest/services/Map/AnHui/MapServer/1"/> <esri:GraphicsLayer ID="MyGraphicsLayer" /> </esri:Map> <Border BorderBrush="Black" Grid.Row="0" CornerRadius="5" BorderThickness="1" Height="35" MinWidth="550" HorizontalAlignment="Center" VerticalAlignment="Top" Background="#77919191" Margin="10"> <Border.Effect> <DropShadowEffect ShadowDepth="1" /> </Border.Effect> <Grid MinWidth="550"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBlock Text="Search for" Foreground="White" Grid.Column="0" HorizontalAlignment="Center" Height="24" VerticalAlignment="Center" FontWeight="Bold" FontSize="12" Margin="20,8,5,0"/> <TextBox x:Name="FindText" Background="White" Text="合肥" Height="23" Width="100" HorizontalContentAlignment="Center" Grid.Column="1" /> <TextBlock Text="in the attributes of States, Rivers, or Cities:" Foreground="White" Grid.Column="2" HorizontalAlignment="Center" Height="24" VerticalAlignment="Center" FontWeight="Bold" FontSize="12" Margin="5,8,5,0"/> <Button x:Name="ExecuteButton" Content="Find" Width="75" Height="24" VerticalAlignment="Center" Click="ExecuteButton_Click" Margin="5,0,5,0" Cursor="Hand" Grid.Column="3" /> </Grid> </Border> <slData:DataGrid x:Name="FindDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="All" Background="White" BorderBrush="Black" BorderThickness="1" SelectionChanged="FindDetails_SelectionChanged" HorizontalScrollBarVisibility="Hidden" Grid.Row="1" IsReadOnly="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="Auto" Width="Auto"> <slData:DataGrid.Columns> <slData:DataGridTextColumn Binding="{Binding Path=LayerId}" Header="Layer ID" /> <slData:DataGridTextColumn Binding="{Binding Path=LayerName}" Header="Layer Name"/> <slData:DataGridTextColumn Binding="{Binding Path=FoundFieldName}" Header="Found Field Name" /> <slData:DataGridTextColumn Binding="{Binding Path=Value}" Header="Found Field Value"/> </slData:DataGrid.Columns> </slData:DataGrid> </Grid></UserControl>
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using ESRI.ArcGIS.Client;using ESRI.ArcGIS.Client.Tasks;namespace 查询{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void ExecuteButton_Click(object sender, RoutedEventArgs e) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.Graphics.Clear(); FindTask findTask = new FindTask("http://localhost/ArcGIS/rest/services/Map/AnHui/MapServer"); findTask.Failed += FindTask_Failed; FindParameters findParameters = new FindParameters(); // Layer ids to search findParameters.LayerIds.AddRange(new int[] { 0, 1, 2, 3 }); // Fields in layers to search findParameters.SearchFields.AddRange(new string[] { "Name "}); // Return features in map's spatial reference findParameters.SpatialReference = MyMap.SpatialReference; // Bind data grid to find results. Bind to the LastResult property which returns a list // of FindResult instances. When LastResult is updated, the ItemsSource property on the // will update. Binding resultFeaturesBinding = new Binding("LastResult"); resultFeaturesBinding.Source = findTask; FindDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding); findParameters.SearchText = FindText.Text; findTask.ExecuteAsync(findParameters); // Since binding to DataGrid, handling the ExecuteComplete event is not necessary. } private void FindDetails_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Highlight the graphic feature associated with the selected row DataGrid dataGrid = sender as DataGrid; int selectedIndex = dataGrid.SelectedIndex; if (selectedIndex > -1) { FindResult findResult = (FindResult)FindDetailsDataGrid.SelectedItem; Graphic graphic = findResult.Feature; switch (graphic.Attributes["SHAPE"].ToString()) { case "Polygon": graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; break; case "Polyline": graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; break; case "Point": graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; break; } GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.Graphics.Clear(); graphicsLayer.Graphics.Add(graphic); } } private void FindTask_Failed(object sender, TaskFailedEventArgs args) { MessageBox.Show("Find failed: " + args.Error); } }}
0 0
- silverlight查询功能
- Silverlight 3.0 功能前瞻
- SilverLight内置缓存功能
- Silverlight--实现全屏功能
- Silverlight实现打印功能
- Silverlight的打印功能
- Silverlight 查询目录页面
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- Silverlight的文字输入功能
- linux so库生成(一)
- 关于EclipseLink 2.5.0 HashPartition小BUG的关注
- 网络协议
- Android UI 详解之AlertDialog
- 关于安卓相机拍照的一些问题
- silverlight查询功能
- QML与c++交互
- oracle flashback 闪回
- android如何将资源打入jar并对资源进行保护
- Ubnutu 安装VIM
- 将android程序打包成sdk中资源的处理
- Android中ENTER键(确认键)点击响应
- tomcat6两个常用配置,端口和web目录
- checkbox属性checked="checked"已有,但却不显示打勾的解决办法