码迷,mamicode.com
首页 > 其他好文 > 详细

老师例子

时间:2015-01-16 07:36:51      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:

登陆界面

<UserControl x:Class="WebGIS.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"     mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="#FF2968F0">         <Grid.ColumnDefinitions>             <ColumnDefinition Width="*"/>             <ColumnDefinition Width="150"/>             <ColumnDefinition Width="250"/>             <ColumnDefinition Width="*"/>         </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>             <RowDefinition Height="*"/>             <RowDefinition Height="75"/>             <RowDefinition Height="75"/>             <RowDefinition Height="75"/>             <RowDefinition Height="75"/>             <RowDefinition Height="*"/>         </Grid.RowDefinitions>

        <TextBlock Text="登录界面" FontSize="30" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>         <TextBlock Text="用户名" FontSize="20" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>         <TextBlock Text="密码" FontSize="20" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>

        <TextBox FontSize="20" Grid.Column="2" Grid.Row="2" Width="100" Height="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>         <TextBox FontSize="20" Grid.Column="2" Grid.Row="3" Width="100" Height="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>

        <StackPanel Grid.Column="2" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">             <Button Content="登录" FontSize="20" Width="80" Height="40" Click="Button_Click_1"/>             <Button Content="注册" FontSize="20" Width="80" Height="40" Click="Button_Click_2"/>         </StackPanel>     </Grid> </UserControl>

 

后台代码

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes;

namespace WebGIS {     public partial class MainPage : UserControl     {         public MainPage()         {             InitializeComponent();         }

        private void Button_Click_1(object sender, RoutedEventArgs e)         {             this.Content = new MapPage();         }

        private void Button_Click_2(object sender, RoutedEventArgs e)         {             RegistPage pRegist = new RegistPage();             pRegist.Show();         }     } }

 

 

 

MAP页

<navigation:Page            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:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"            xmlns:esri="http://schemas.esri.com/arcgis/client/2009" x:Class="WebGIS.MapPage"            xmlns:slData="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"            mc:Ignorable="d"            d:DesignWidth="640" d:DesignHeight="480"            Title="MapPage Page">     <Grid x:Name="LayoutRoot" RenderTransformOrigin="0.495,0.144">                 <Grid.Resources>             <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#500000FF" BorderBrush="Blue" BorderThickness="1"/>             <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="6" Style="Diamond"/>         </Grid.Resources>

        <Grid.RowDefinitions>             <RowDefinition Height="150"/>             <RowDefinition Height="*"/>         </Grid.RowDefinitions>                     <Grid Grid.Row="0">             <Grid.Background>                 <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                     <GradientStop Color="Black" Offset="0"/>                     <GradientStop Color="#FF2B21F0" Offset="1"/>                 </LinearGradientBrush>             </Grid.Background>         </Grid>

        <Grid Grid.Row="1">                         <Grid.ColumnDefinitions>                 <ColumnDefinition Width="200"/>                 <ColumnDefinition Width="*"/>             </Grid.ColumnDefinitions>        

            <Grid Grid.Row="0">                 <Grid.Background>                     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                         <GradientStop Color="Black" Offset="0"/>                         <GradientStop Color="#FF3027D3" Offset="1"/>                     </LinearGradientBrush>                 </Grid.Background>             </Grid>                         <!--隐藏按钮-->             <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Vertical"  VerticalAlignment="Top">                 <Button Content="书签" Name="btn_bookmap" FontSize="20" Width="200" Height="30" Click="btn_bookmap_Click_1"/>                 <Button Content="鹰眼" Name="btn_overviewmap" FontSize="20" Width="200" Height="30" Click="btn_overviewmap_Click_1"/>                 <Button Content="地图查询" Name="btn_query" FontSize="20" Width="200" Height="30" Click="btn_query_Click_1"/>                 <Button Content="地图渲染" Name="btn_render" FontSize="20" Width="200" Height="30" Click="btn_render_Click_1"/>                 <Button Content="地图属性" Name="btn_maptip" FontSize="20" Width="200" Height="30" Click="btn_maptip_Click_1"/>             </StackPanel>          

            <!--地图-->             <esri:Map Name="MyMap" Background="White"  WrapAround="True" Extent="-868436,-2480683,24033067,9385902" Grid.ColumnSpan="2" Margin="193,0,7,0">                 <esri:ArcGISDynamicMapServiceLayer ID="MapLayer"   Url="http://localhost/ArcGIS/rest/services/Map/MapServer"/>                                 <!--查询图层-->                 <esri:GraphicsLayer ID="GraphicslayerQuery"/>                                 <!--渲染图层-->                 <esri:GraphicsLayer ID="GraphicslayerRender"/>                                 <!--MapTip图层-->                 <esri:GraphicsLayer ID="StatesGraphicsLayerMapTip">                     <esri:GraphicsLayer.MapTip>                         <Border esri:GraphicsLayer.MapTipHideDelay="00:00:01.5" CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" Margin="0,0,15,15">

                            <Border.Background>                                 <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188">                                     <GradientStop Color="#FFD1DFF2"/>                                     <GradientStop Color="#FF092959" Offset="0.946"/>                                 </LinearGradientBrush>                             </Border.Background>

                            <Border.Effect>                                 <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300"/>                             </Border.Effect>

                            <StackPanel Orientation="Vertical" Margin="20,15,20,15">                                 <StackPanel Orientation="Horizontal" Margin="0,0,0,6">                                     <TextBlock Text="国家:" FontWeight="Bold" Foreground="#FF0F274E" FontSize="12"/>                                     <TextBlock Text="{Binding [Name]}" Foreground="#FFFFFFFF" FontSize="12" FontStyle="Italic" FontFamily="Portable User Interface"/>                                 </StackPanel>                                                                 <StackPanel>                                     <TextBlock Text="人口: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="12"/>                                     <TextBlock Text="{Binding [Population]}" Foreground="#FFFFFFFF" FontSize="12" FontStyle="Italic" FontFamily="Portable User Interface"/>                                 </StackPanel>                             </StackPanel>                                                     </Border>                     </esri:GraphicsLayer.MapTip>                 </esri:GraphicsLayer>                                 <esri:GraphicsLayer ID="CitiesGraphicsLayerMapTip">                     <esri:GraphicsLayer.MapTip>                         <Border BorderBrush="DarkGray" CornerRadius="13" BorderThickness="1" Margin="0,0,15,15">                                                         <Border.Effect>                                 <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300"/>                             </Border.Effect>

                            <Border CornerRadius="10" Background="#DDFFEEEE" BorderThickness="5" BorderBrush="#77FF0000">                                 <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="10">                                                                    <StackPanel Orientation="Horizontal">                                         <TextBlock Text="城市: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="10" VerticalAlignment="Center"/>                                         <TextBlock Text="{Binding [Name]}" HorizontalAlignment="Left" VerticalAlignment="Center"/>                                     </StackPanel>

                                    <StackPanel Orientation="Horizontal">                                         <TextBlock Text="城市人口: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="10" VerticalAlignment="Center"/>                                         <TextBlock Text="{Binding [Population]}" HorizontalAlignment="Left" VerticalAlignment="Center"/>                                     </StackPanel>                                                                   </StackPanel>                             </Border>                                                     </Border>                     </esri:GraphicsLayer.MapTip>                 </esri:GraphicsLayer>             </esri:Map>

            <!--基本工具,地图控件-->                         <esri:Bookmark Name="mybookmap" Map="{Binding ElementName=MyMap}" Grid.Column="1" HorizontalAlignment="Left" Margin="5,45,0,0" VerticalAlignment="Top" Visibility="Collapsed"/>             <esri:OverviewMap Name="myoverviewmap" Map="{Binding ElementName=MyMap}" Grid.Column="1" IsStatic="True" HorizontalAlignment="Right"  Height="106" VerticalAlignment="Bottom" Visibility="Collapsed" Width="118" Opacity="0.6">                 <esri:OverviewMap.Layer >                     <esri:ArcGISDynamicMapServiceLayer Url="http://localhost/ArcGIS/rest/services/Map/MapServer"/>                 </esri:OverviewMap.Layer >             </esri:OverviewMap >

            <!--地图查询-->                         <Border x:Name="QueryBorder" Grid.Row="1" Grid.Column="1" Background="#77919191" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Right" BorderBrush="Gray" VerticalAlignment="Top"                 Margin="5">

                <Border.Effect>                     <DropShadowEffect/>                 </Border.Effect>

                <Grid x:Name="QueryGrid" HorizontalAlignment="Right" VerticalAlignment="Top" Visibility="Collapsed">

                    <Grid.RowDefinitions>                         <RowDefinition Height="30"/>                         <RowDefinition Height="30"/>                         <RowDefinition Height="*"/>                     </Grid.RowDefinitions>

                    <TextBlock x:Name="DataDisplayTitleBottom" Text="Query a layer (search for a state)"                        Foreground="White" FontSize="10" Grid.Row="0"                                             Margin="15,5,15,1" HorizontalAlignment="Center">                         <TextBlock.Effect>                             <DropShadowEffect/>                         </TextBlock.Effect>                     </TextBlock>

                    <!--下拉框-->                                       <ComboBox x:Name="QueryComboBox" Grid.Row="1" MinWidth="150" Margin="5,1,5,5" SelectionChanged="QueryComboBox_SelectionChanged_2">                                           </ComboBox>

                    <ScrollViewer x:Name="DataGridScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"                           Width="230" MinHeight="200" Visibility="Collapsed" Grid.Row="2">                         <slData:DataGrid x:Name="QueryDetailsDataGrid" AutoGenerateColumns="False" HeadersVisibility="None"                               Background="White">                             <slData:DataGrid.Columns>                                 <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>                                 <slData:DataGridTextColumn Binding="{Binding Path=Value}"/>                             </slData:DataGrid.Columns>                         </slData:DataGrid>                     </ScrollViewer>                                                                                           </Grid>             </Border>

            <!--地图渲染-->                     <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Margin="15" HorizontalAlignment="Left" VerticalAlignment="Top">                 <Grid x:Name="LegendGrid" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10,10,10,10" Visibility="Collapsed">                     <Path x:Name="LegendCollapsedTriangle" Canvas.ZIndex="100" Height="10" HorizontalAlignment="Right" Margin="0,19,15.375,0" VerticalAlignment="Top"                       Width="10" Fill="#995C90B2" Stretch="Fill" Stroke="#FF666666" Data="M85,25 L85,25 L87.5,30 L90,25 z"                       RenderTransformOrigin="3.083,-1.417" Visibility="Collapsed" StrokeThickness="0"/>                     <Path x:Name="LegendExpandedTriangle" Canvas.ZIndex="100" Height="10" HorizontalAlignment="Right" Margin="0,16.931,15.294,0" VerticalAlignment="Top" Width="10" Stretch="Fill"                       Stroke="#FF666666" Data="M85,30 L85,30 L87.5,25 L90,30 z" RenderTransformOrigin="3.083,-1.417"                       Fill="#995C90B2" StrokeThickness="0"/>                     <Rectangle RadiusX="10" RadiusY="10" Fill="#22000000" Margin="0,4,0,0" />                     <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="#77919191" Margin="0,0,0,5" />                     <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />                     <TextBlock x:Name="LegendCollapsedTitle" TextAlignment="Center" Text="Legend" Margin="30.331,15.069,29.669,0" FontWeight="Bold" Height="16"                            VerticalAlignment="Top" RenderTransformOrigin="0.501,1.017" Visibility="Collapsed" />                     <StackPanel Orientation="Vertical" Margin="25" HorizontalAlignment="Center" VerticalAlignment="Top" >                         <TextBlock x:Name="LegendTitle" HorizontalAlignment="Center" TextAlignment="Center" Text="Legend" Margin="5" FontWeight="Bold" />                         <StackPanel x:Name="LegendStackPanel" HorizontalAlignment="Center" Margin="5" />                     </StackPanel>                 </Grid>             </StackPanel>

            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Top">                 <Grid x:Name="ClassGrid" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Visibility="Collapsed">                                         <Path x:Name="ClassCollapsedTriangle" Canvas.ZIndex="100" Height="10" HorizontalAlignment="Right" Margin="0,19,15.375,0" VerticalAlignment="Top" Width="10" Fill="#995C90B2"                       Stretch="Fill" Stroke="#FF666666" Data="M85,25 L85,25 L87.5,30 L90,25 z" RenderTransformOrigin="3.083,-1.417" Visibility="Collapsed"                       StrokeThickness="0"/>                     <Path x:Name="ClassExpandedTriangle" Canvas.ZIndex="100" Height="10" HorizontalAlignment="Right" Margin="0,16.931,15.294,0" VerticalAlignment="Top" Width="10" Stretch="Fill"                       Stroke="#FF666666" Data="M85,30 L85,30 L87.5,25 L90,30 z" RenderTransformOrigin="3.083,-1.417" Fill="#995C90B2"                       StrokeThickness="0"/>                                         <Rectangle Fill="#22000000" RadiusX="10" RadiusY="10" Margin="0,4,0,0" />                     <Rectangle Fill="#77919191" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5" />                     <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />                                         <TextBlock x:Name="ClassCollapsedTitle" TextAlignment="Center" Text="Thematic Properties" Margin="30.331,15.069,29.669,0" FontWeight="Bold"                            Height="16" VerticalAlignment="Top" RenderTransformOrigin="0.501,1.017" Visibility="Collapsed" />

                    <StackPanel Orientation="Vertical" Margin="25" HorizontalAlignment="Center" VerticalAlignment="Top">                                                 <TextBlock HorizontalAlignment="Center" TextAlignment="Center" Text="Thematic Properties" Margin="5" FontWeight="Bold"/>                                                 <TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Theme:" Margin="0,5,0,0"  />                         <ComboBox x:Name="FieldCombo" HorizontalAlignment="Left" SelectionChanged="FieldCombo_SelectionChanged_1" MaxWidth="200" Width="150"/>                                                                            <TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Classes:" Margin="0,5,0,0"  />                         <ComboBox x:Name="ClassCountCombo" HorizontalAlignment="Left" SelectionChanged="ClassCountCombo_SelectionChanged_1" SelectedIndex="0">                             <ComboBoxItem Content="6" Tag="6" />                             <ComboBoxItem Content="5" Tag="5" />                             <ComboBoxItem Content="4" Tag="4" />                             <ComboBoxItem Content="3" Tag="3" />                         </ComboBox>

                        <TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Classification Type:" Margin="0,5,0,0"  />                         <ComboBox x:Name="ClassTypeCombo" HorizontalAlignment="Left" SelectionChanged="ClassTypeCombo_SelectionChanged_1" SelectedIndex="0">                             <ComboBoxItem Content="Quantile"/>                             <ComboBoxItem Content="Equal Interval"/>                         </ComboBox>

                        <TextBlock HorizontalAlignment="Left" TextAlignment="Center" Text="Color Theme:" Margin="0,5,0,0"/>                         <ComboBox x:Name="ColorBlendCombo" HorizontalAlignment="Left" SelectionChanged="ColorBlendCombo_SelectionChanged_1" SelectedIndex="0">                             <ComboBoxItem Content="Blue" Background="Blue"/>                             <ComboBoxItem Content="Red" Background="Red" />                             <ComboBoxItem Content="Green" Background="Green" />                             <ComboBoxItem Content="Yellow" Background="Yellow" />                             <ComboBoxItem Content="Magenta" Background="Magenta" />                             <ComboBoxItem Content="Cyan" Background="Cyan" />                             <ComboBoxItem Content="MultiColor" />                         </ComboBox>

                        <Button x:Name="RenderButton" IsEnabled="False" Content="Render" Click="RenderButton_Click_1" Width="100" Margin="0,5,0,0"/>                                             </StackPanel>                                    </Grid>             </StackPanel>                         <!--MapTip-->             <Grid x:Name="MapTipGrid" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,10,10,0" Visibility="Collapsed">                 <Rectangle Fill="#77919191" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5">                     <Rectangle.Effect>                         <DropShadowEffect/>                     </Rectangle.Effect>                 </Rectangle>                            <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,14" Height="42"/>                 <TextBlock Text="Hover over a state or city to see the GraphicsLayer MapTip."  TextAlignment="Center" Margin="25,25,25,25"/>             </Grid>                     </Grid>

    </Grid>      </navigation:Page>

 

后台代码

sing System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Navigation; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Symbols; using ESRI.ArcGIS.Client.Tasks;

namespace WebGIS {     public partial class MapPage : Page     {         //地图渲染         List<ThematicItem> ThematicItemList = new List<ThematicItem>();         List<List<SolidColorBrush>> ColorList = new List<List<SolidColorBrush>>();         int _colorShadeIndex = 0;         int _thematicListIndex = 0;         FeatureSet _featureSet = null;         int _classType = 0; // EqualInterval = 1; Quantile = 0;         int _classCount = 6;         int _lastGeneratedClassCount = 0;         bool _legendGridCollapsed;         bool _classGridCollapsed;

        // 当用户导航到此页面时执行。              protected override void OnNavigatedTo(NavigationEventArgs e)         {

        }

        public MapPage()         {             InitializeComponent();

            //地图查询             QueryTask queryTask = new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/2");             queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;             queryTask.Failed += QueryTask_Failed;

            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();

            // Specify fields to return from initial query             query.OutFields.AddRange(new string[] { "Name" });

            // This query will just populate the drop-down, so no need to return geometry             query.ReturnGeometry = false;

            // Return all features             query.Where = "1=1";             queryTask.ExecuteAsync(query, "initial");

            //MapTip             //MyMap.PropertyChanged += MyMap_PropertyChanged;                  }

      

        //基本工具,地图控件         private void btn_bookmap_Click_1(object sender, RoutedEventArgs e)         {             if (this.mybookmap.Visibility == Visibility.Collapsed)             {                 this.mybookmap.Visibility = Visibility.Visible;             }             else             {                 this.mybookmap.Visibility = Visibility.Collapsed;             }         }

        private void btn_overviewmap_Click_1(object sender, RoutedEventArgs e)         {             if (this.myoverviewmap.Visibility == Visibility.Collapsed)             {                 this.myoverviewmap.Visibility = Visibility.Visible;             }             else             {                 this.myoverviewmap.Visibility = Visibility.Collapsed;             }         }

        private void btn_query_Click_1(object sender, RoutedEventArgs e)         {             if (this.QueryGrid.Visibility == Visibility.Collapsed)             {                 this.QueryGrid.Visibility = Visibility.Visible;             }             else             {                 this.QueryGrid.Visibility = Visibility.Collapsed;             }         }

        private void btn_render_Click_1(object sender, RoutedEventArgs e)         {             if (this.LegendGrid.Visibility == Visibility.Collapsed)             {                 this.LegendGrid.Visibility = Visibility.Visible;             }             else             {                 this.LegendGrid.Visibility = Visibility.Collapsed;             }

            if (this.ClassGrid.Visibility == Visibility.Collapsed)             {                 this.ClassGrid.Visibility = Visibility.Visible;

                //地图渲染开                 //MyMap.PropertyChanged += MyMap_PropertyChanged;                 BeginMapRanderOpen();             }             else             {                 this.ClassGrid.Visibility = Visibility.Collapsed;

                //地图渲染关                 BeginMapRanderClose();             }                   }

        private void btn_maptip_Click_1(object sender, RoutedEventArgs e)         {             if (this.MapTipGrid.Visibility == Visibility.Collapsed)             {                 this.MapTipGrid.Visibility = Visibility.Visible;

                //MapTip                 BeginMapTip();             }             else             {                 this.MapTipGrid.Visibility = Visibility.Collapsed;             }         }              //地图查询事件         private void QueryComboBox_SelectionChanged_2(object sender, SelectionChangedEventArgs e)         {             if (QueryComboBox.SelectedItem.ToString().Contains("Select..."))                 return;

            QueryTask queryTask = new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/2");             queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;             queryTask.Failed += QueryTask_Failed;

            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();             query.ReturnGeometry = true;             query.Text = QueryComboBox.SelectedItem.ToString();             query.OutSpatialReference = MyMap.SpatialReference;             query.OutFields.Add("*");

            queryTask.ExecuteAsync(query);         }                private void QueryTask_ExecuteCompleted(object sender,ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)         {          

            FeatureSet featureSet = args.FeatureSet;

            // If initial query to populate states combo box             if ((args.UserState as string) == "initial")             {                 // Just show on initial load                 QueryComboBox.Items.Add("Select...");

                foreach (Graphic graphic in args.FeatureSet.Features)                 {                     QueryComboBox.Items.Add(graphic.Attributes["Name"].ToString());                 }

                QueryComboBox.SelectedIndex = 0;                 return;             }

            // Remove the first entry if "Select..."             if (QueryComboBox.Items[0].ToString().Contains("Select..."))                 QueryComboBox.Items.RemoveAt(0);

            // If an item has been selected                        GraphicsLayer graphicsLayerQuery = MyMap.Layers["graphicsLayerQuery"] as GraphicsLayer;             if (graphicsLayerQuery != null)                 graphicsLayerQuery.ClearGraphics();

            if (featureSet != null && featureSet.Features.Count > 0)             {                 // Show selected feature attributes in DataGrid                 Graphic selectedFeature = featureSet.Features[0];

                QueryDetailsDataGrid.ItemsSource = selectedFeature.Attributes;

                // Highlight selected feature                 selectedFeature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;                 if (graphicsLayerQuery != null)                     graphicsLayerQuery.Graphics.Add(selectedFeature);

                // Zoom to selected feature (define expand percentage)                 ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent;

                double expandPercentage = 30;

                double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100);                 double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100);

                ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(                 selectedFeatureExtent.XMin - (widthExpand / 2),                 selectedFeatureExtent.YMin - (heightExpand / 2),                 selectedFeatureExtent.XMax + (widthExpand / 2),                 selectedFeatureExtent.YMax + (heightExpand / 2));

                MyMap.ZoomTo(displayExtent);

                // If DataGrid not visible (initial load), show it                 if (DataGridScrollViewer.Visibility == Visibility.Collapsed)                 {                     DataGridScrollViewer.Visibility = Visibility.Visible;                     QueryGrid.Height = Double.NaN;                     QueryGrid.UpdateLayout();                 }             }             else             {                 QueryDetailsDataGrid.ItemsSource = null;                 DataGridScrollViewer.Visibility = Visibility.Collapsed;                 QueryGrid.Height = Double.NaN;                 QueryGrid.UpdateLayout();             }         }

        private void QueryTask_Failed(object sender, TaskFailedEventArgs args)         {                       MessageBox.Show("Query failed: " + args.Error);         }

        //地图查询生成类         public object featureSet { get; set; }

        //地图渲染         void BeginMapRanderOpen()         {             _legendGridCollapsed = false;             _classGridCollapsed = false;

            LegendCollapsedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;             LegendExpandedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;             ClassCollapsedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;             ClassExpandedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;

            // Get start value for number of classifications in XAML.             _lastGeneratedClassCount = Convert.ToInt32(((ComboBoxItem)ClassCountCombo.SelectedItem).Content);

            // Set query where clause to include features with an area greater than 70 square miles.  This             // will effectively exclude the District of Columbia from attributes to avoid skewing classifications.             ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()             {                 Where = "1=1",                 OutSpatialReference = MyMap.SpatialReference,                 ReturnGeometry = true             };             query.OutFields.Add("*");

            QueryTask queryTask =                 new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/2");

            //queryTask.ExecuteCompleted += (evtsender, args) =>             //{             //    if (args.FeatureSet == null)             //        return;             //    _featureSet = args.FeatureSet;             //    SetRangeValues();             //    RenderButton.IsEnabled = true;             //};

            queryTask.ExecuteCompleted += queryTask_ExecuteCompleted;             queryTask.Failed += queryTask_Failed;             queryTask.ExecuteAsync(query);

            CreateColorList();             CreateThematicList();         }

        void BeginMapRanderClose()         {             _legendGridCollapsed = false;             _classGridCollapsed = false;

            LegendCollapsedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;             LegendExpandedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;             ClassCollapsedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;             ClassExpandedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;

            // Get start value for number of classifications in XAML.             _lastGeneratedClassCount = Convert.ToInt32(((ComboBoxItem)ClassCountCombo.SelectedItem).Content);

            // Set query where clause to include features with an area greater than 70 square miles.  This             // will effectively exclude the District of Columbia from attributes to avoid skewing classifications.             ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()             {                 Where = "1=1",                 OutSpatialReference = MyMap.SpatialReference,                 ReturnGeometry = false             };             query.OutFields.Add("*");

            QueryTask queryTask =                 new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/2");

            //queryTask.ExecuteCompleted += (evtsender, args) =>             //{             //    if (args.FeatureSet == null)             //        return;             //    _featureSet = args.FeatureSet;             //    SetRangeValues();             //    RenderButton.IsEnabled = true;             //};

            queryTask.ExecuteCompleted += queryTask_ExecuteCompleted;             queryTask.Failed += queryTask_Failed;             queryTask.ExecuteAsync(query);

            CreateColorList();             CreateThematicList();         }                //void MyMap_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs arge)         //{         //    if (arge.PropertyName == "SpatialReference")         //    {         //        MyMap.PropertyChanged -= MyMap_PropertyChanged;

        //        _legendGridCollapsed = false;         //        _classGridCollapsed = false;

        //        LegendCollapsedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;         //        LegendExpandedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;         //        ClassCollapsedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;         //        ClassExpandedTriangle.MouseLeftButtonUp += Triangle_MouseLeftButtonUp;

        //        // Get start value for number of classifications in XAML.         //        _lastGeneratedClassCount = Convert.ToInt32(((ComboBoxItem)ClassCountCombo.SelectedItem).Content);

        //        // Set query where clause to include features with an area greater than 70 square miles.  This         //        // will effectively exclude the District of Columbia from attributes to avoid skewing classifications.         //        ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()         //        {         //            Where = "1=1",         //            OutSpatialReference = MyMap.SpatialReference,         //            ReturnGeometry = true         //        };         //        query.OutFields.Add("*");

        //        QueryTask queryTask =         //            new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/2");

        //        //queryTask.ExecuteCompleted += (evtsender, args) =>         //        //{         //        //    if (args.FeatureSet == null)         //        //        return;         //        //    _featureSet = args.FeatureSet;         //        //    SetRangeValues();         //        //    RenderButton.IsEnabled = true;         //        //};

        //        queryTask.ExecuteCompleted += queryTask_ExecuteCompleted;         //        queryTask.Failed += queryTask_Failed;         //        queryTask.ExecuteAsync(query);

        //        CreateColorList();         //        CreateThematicList();         //    }         //}

        void queryTask_Failed(object sender, TaskFailedEventArgs e)         {             MessageBox.Show(e.ToString());         }

        void queryTask_ExecuteCompleted(object sender, QueryEventArgs e)         {             if (e.FeatureSet == null)                 return;             _featureSet = e.FeatureSet;             SetRangeValues();             RenderButton.IsEnabled = true;         }      

        public struct ThematicItem         {             public string Name { get; set; }             public string Description { get; set; }             public string CalcField { get; set; }             public double Min { get; set; }             public double Max { get; set; }             public string MinName { get; set; }             public string MaxName { get; set; }             public List<double> RangeStarts { get; set; }

        }

        private void CreateColorList()         {             ColorList = new List<List<SolidColorBrush>>();

            List<SolidColorBrush> BlueShades = new List<SolidColorBrush>();             List<SolidColorBrush> RedShades = new List<SolidColorBrush>();             List<SolidColorBrush> GreenShades = new List<SolidColorBrush>();             List<SolidColorBrush> YellowShades = new List<SolidColorBrush>();             List<SolidColorBrush> MagentaShades = new List<SolidColorBrush>();             List<SolidColorBrush> CyanShades = new List<SolidColorBrush>();

            int rgbFactor = 255 / _classCount;

            for (int j = 0; j < 256; j = j + rgbFactor)             {                 BlueShades.Add(new SolidColorBrush(Color.FromArgb(192, (byte)j, (byte)j, 255)));                 RedShades.Add(new SolidColorBrush(Color.FromArgb(192, 255, (byte)j, (byte)j)));                 GreenShades.Add(new SolidColorBrush(Color.FromArgb(192, (byte)j, 255, (byte)j)));                 YellowShades.Add(new SolidColorBrush(Color.FromArgb(192, 255, 255, (byte)j)));                 MagentaShades.Add(new SolidColorBrush(Color.FromArgb(192, 255, (byte)j, 255)));                 CyanShades.Add(new SolidColorBrush(Color.FromArgb(192, (byte)j, 255, 255)));             }

            ColorList.Add(BlueShades);             ColorList.Add(RedShades);             ColorList.Add(GreenShades);             ColorList.Add(YellowShades);             ColorList.Add(MagentaShades);             ColorList.Add(CyanShades);

            foreach (List<SolidColorBrush> brushList in ColorList)             {                 brushList.Reverse();             }

            List<SolidColorBrush> MixedShades = new List<SolidColorBrush>();             if (_classCount > 5) MixedShades.Add(new SolidColorBrush(Color.FromArgb(192, 0, 255, 255)));             if (_classCount > 4) MixedShades.Add(new SolidColorBrush(Color.FromArgb(192, 255, 0, 255)));             if (_classCount > 3) MixedShades.Add(new SolidColorBrush(Color.FromArgb(192, 255, 255, 0)));             MixedShades.Add(new SolidColorBrush(Color.FromArgb(192, 0, 255, 0)));             MixedShades.Add(new SolidColorBrush(Color.FromArgb(192, 0, 0, 255)));             MixedShades.Add(new SolidColorBrush(Color.FromArgb(192, 255, 0, 0)));             ColorList.Add(MixedShades);

            _lastGeneratedClassCount = _classCount;         }

        private void CreateThematicList()         {             ThematicItemList.Add(new ThematicItem() { Name = "GDP", Description = "GDP", CalcField = "" });             ThematicItemList.Add(new ThematicItem() { Name = "Population", Description = "Population", CalcField = "" });                       foreach (ThematicItem items in ThematicItemList)             {                 FieldCombo.Items.Add(items.Description);             }             FieldCombo.SelectedIndex = 0;         }

        GraphicsLayer graphicsLayerRender;

        private void SetRangeValues()         {             graphicsLayerRender = MyMap.Layers["GraphicslayerRender"] as GraphicsLayer;

            if (graphicsLayerRender != null)             {                 graphicsLayerRender.Graphics.Clear();             }

            // if necessary, update ColorList based on current number of classes.             if (_lastGeneratedClassCount != _classCount) CreateColorList();

            // Field on which to generate a classification scheme.              ThematicItem thematicItem = ThematicItemList[_thematicListIndex];

            // Calculate value for classification scheme             bool useCalculatedValue = !string.IsNullOrEmpty(thematicItem.CalcField);

            // Store a list of values to classify             List<double> valueList = new List<double>();

            // Get range, min, max, etc. from features             for (int i = 0; i < _featureSet.Features.Count; i++)             {                 Graphic graphicFeature = _featureSet.Features[i];

                double graphicValue = Convert.ToDouble(graphicFeature.Attributes[thematicItem.Name]);                 string graphicName = graphicFeature.Attributes["Name"].ToString();

                if (useCalculatedValue)                 {                     double calcVal = Convert.ToDouble(graphicFeature.Attributes[thematicItem.CalcField]);                     graphicValue = Math.Round(graphicValue / calcVal * 100, 2);                 }

                if (i == 0)                 {                     thematicItem.Min = graphicValue;                     thematicItem.Max = graphicValue;                     thematicItem.MinName = graphicName;                     thematicItem.MaxName = graphicName;                 }                 else                 {                     if (graphicValue < thematicItem.Min) { thematicItem.Min = graphicValue; thematicItem.MinName = graphicName; }                     if (graphicValue > thematicItem.Max) { thematicItem.Max = graphicValue; thematicItem.MaxName = graphicName; }                 }

                valueList.Add(graphicValue);             }

            // Set up range start values             thematicItem.RangeStarts = new List<double>();

            double totalRange = thematicItem.Max - thematicItem.Min;             double portion = totalRange / _classCount;

            thematicItem.RangeStarts.Add(thematicItem.Min);             double startRangeValue = thematicItem.Min;

            // Equal Interval             if (_classType == 1)             {                 for (int i = 1; i < _classCount; i++)                 {                     startRangeValue += portion;                     thematicItem.RangeStarts.Add(startRangeValue);                 }             }             // Quantile             else             {                 // Enumerator of all values in ascending order                 IEnumerable<double> valueEnumerator =                 from aValue in valueList                 orderby aValue //"ascending" is default                 select aValue;

                int increment = Convert.ToInt32(Math.Ceiling(_featureSet.Features.Count / _classCount));                 for (int i = increment; i < valueList.Count; i += increment)                 {                     double value = valueEnumerator.ElementAt(i);                     thematicItem.RangeStarts.Add(value);                 }             }

            // Create graphic features and set symbol using the class range which contains the value             List<SolidColorBrush> brushList = ColorList[_colorShadeIndex];             if (_featureSet != null && _featureSet.Features.Count > 0)             {                 // Clear previous graphic features                 if (graphicsLayerRender != null)                     graphicsLayerRender.ClearGraphics();

                for (int i = 0; i < _featureSet.Features.Count; i++)                 {                     Graphic graphicFeature = _featureSet.Features[i];

                    double graphicValue = Convert.ToDouble(graphicFeature.Attributes[thematicItem.Name]);                     if (useCalculatedValue)                     {                         double calcVal = Convert.ToDouble(graphicFeature.Attributes[thematicItem.CalcField]);                         graphicValue = Math.Round(graphicValue / calcVal * 100, 2);                     }

                    int brushIndex = GetRangeIndex(graphicValue, thematicItem.RangeStarts);

                    SimpleFillSymbol symbol = new SimpleFillSymbol()                     {                         Fill = brushList[brushIndex],                         BorderBrush = new SolidColorBrush(Colors.Transparent),                         BorderThickness = 1                     };

                    Graphic graphic = new Graphic();                     graphic.Geometry = graphicFeature.Geometry;                     graphic.Attributes.Add("Name", graphicFeature.Attributes["Name"].ToString());                     graphic.Attributes.Add("Description", thematicItem.Description);                     graphic.Attributes.Add("Value", graphicValue.ToString());                     graphic.Symbol = symbol;

                    if (graphicsLayerRender != null)                         graphicsLayerRender.Graphics.Add(graphic);                 }

                // Create new legend with ranges and swatches.                 LegendStackPanel.Children.Clear();

                ListBox legendList = new ListBox();                 LegendTitle.Text = thematicItem.Description;

                for (int c = 0; c < _classCount; c++)                 {                     Rectangle swatchRect = new Rectangle()                     {                         Width = 20,                         Height = 20,                         Stroke = new SolidColorBrush(Colors.Black),                         Fill = brushList[c]                     };

                    TextBlock classTextBlock = new TextBlock();

                    // First classification                     if (c == 0)                         classTextBlock.Text = String.Format("  Less than {0}", Math.Round(thematicItem.RangeStarts[1], 2));                     // Last classification                     else if (c == _classCount - 1)                         classTextBlock.Text = String.Format("  {0} and above", Math.Round(thematicItem.RangeStarts[c], 2));                     // Middle classifications                     else                         classTextBlock.Text = String.Format("  {0} to {1}", Math.Round(thematicItem.RangeStarts[c], 2), Math.Round(thematicItem.RangeStarts[c + 1], 2));

                    StackPanel classStackPanel = new StackPanel();                     classStackPanel.Orientation = Orientation.Horizontal;                     classStackPanel.Children.Add(swatchRect);                     classStackPanel.Children.Add(classTextBlock);

                    legendList.Items.Add(classStackPanel);                 }

                TextBlock minTextBlock = new TextBlock();                 StackPanel minStackPanel = new StackPanel();                 minStackPanel.Orientation = Orientation.Horizontal;                 minTextBlock.Text = String.Format("Min: {0} ({1})", thematicItem.Min, thematicItem.MinName);                 minStackPanel.Children.Add(minTextBlock);                 legendList.Items.Add(minStackPanel);

                TextBlock maxTextBlock = new TextBlock();                 StackPanel maxStackPanel = new StackPanel();                 maxStackPanel.Orientation = Orientation.Horizontal;                 maxTextBlock.Text = String.Format("Max: {0} ({1})", thematicItem.Max, thematicItem.MaxName);                 maxStackPanel.Children.Add(maxTextBlock);                 legendList.Items.Add(maxStackPanel);

                LegendStackPanel.Children.Add(legendList);             }         }

        private int GetRangeIndex(double val, List<double> ranges)         {             int index = _classCount - 1;             for (int r = 0; r < _classCount - 1; r++)             {                 if (val >= ranges[r] && val < ranges[r + 1]) index = r;             }             return index;         }

        public struct Values         {             public string Name { get; set; }             public string Description { get; set; }             public string Value { get; set; }         }

        //地图渲染事件         private void FieldCombo_SelectionChanged_1(object sender, SelectionChangedEventArgs e)         {             if (FieldCombo != null)                 _thematicListIndex = FieldCombo.SelectedIndex;         }

        private void ColorBlendCombo_SelectionChanged_1(object sender, SelectionChangedEventArgs e)         {             if (ColorBlendCombo != null)                 _colorShadeIndex = ColorBlendCombo.SelectedIndex;         }

        private void RenderButton_Click_1(object sender, RoutedEventArgs e)         {             SetRangeValues();         }

        private void ClassCountCombo_SelectionChanged_1(object sender, SelectionChangedEventArgs e)         {             if (ClassCountCombo != null)             {                 ComboBoxItem item = ClassCountCombo.SelectedItem as ComboBoxItem;                 _classCount = Convert.ToInt32(item.Content);             }         }                 private void ClassTypeCombo_SelectionChanged_1(object sender, SelectionChangedEventArgs e)         {             if (ClassTypeCombo != null)                 _classType = ClassTypeCombo.SelectedIndex;         }                     //地图渲染生成类         void Triangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)         {             FrameworkElement source = sender as FrameworkElement;

            switch (source.Name)             {                 case "ClassExpandedTriangle":                 case "ClassCollapsedTriangle":                     if (_classGridCollapsed)                     {                         ClassExpandedTriangle.Visibility = Visibility.Visible;                         ClassCollapsedTriangle.Visibility = Visibility.Collapsed;                         ClassCollapsedTitle.Visibility = Visibility.Collapsed;                         ClassGrid.Height = Double.NaN;                         ClassGrid.UpdateLayout();                     }                     else                     {                         ClassCollapsedTriangle.Visibility = Visibility.Visible;                         ClassExpandedTriangle.Visibility = Visibility.Collapsed;                         ClassCollapsedTitle.Visibility = Visibility.Visible;                         ClassGrid.Height = 50;                     }                     _classGridCollapsed = !_classGridCollapsed;                     break;                 case "LegendExpandedTriangle":                 case "LegendCollapsedTriangle":                     if (_legendGridCollapsed)                     {                         LegendExpandedTriangle.Visibility = Visibility.Visible;                         LegendCollapsedTriangle.Visibility = Visibility.Collapsed;                         LegendCollapsedTitle.Visibility = Visibility.Collapsed;                         LegendGrid.Height = Double.NaN;                         LegendGrid.UpdateLayout();                     }                     else                     {                         LegendCollapsedTriangle.Visibility = Visibility.Visible;                         LegendExpandedTriangle.Visibility = Visibility.Collapsed;                         LegendCollapsedTitle.Visibility = Visibility.Visible;                         LegendGrid.Height = 50;                     }                     _legendGridCollapsed = !_legendGridCollapsed;                     break;             }         }             //MapTip

        private void BeginMapTip()         {             StatesGraphicsLayerLoad();             CitiesGraphicsLayerLoad();         }

        //void MyMap_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args)         //{         //    if (args.PropertyName == "SpatialReference")         //    {         //        StatesGraphicsLayerLoad();         //        CitiesGraphicsLayerLoad();         //        MyMap.PropertyChanged -= MyMap_PropertyChanged;         //    }         //}

        void StatesGraphicsLayerLoad()         {             ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()             {                 ReturnGeometry = true,                 OutSpatialReference = MyMap.SpatialReference             };             query.Where = "1=1";             query.OutFields.Add("*");

            QueryTask queryTask = new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/2");             queryTask.ExecuteCompleted += StatesGraphicsLayerQueryTask_ExecuteCompleted;             queryTask.Failed += StatesqueryTask_Failed;             queryTask.ExecuteAsync(query);         }

        private void StatesqueryTask_Failed(object sender, TaskFailedEventArgs e)         {             string result = e.ToString();         }     

        void StatesGraphicsLayerQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs queryArgs)         {             if (queryArgs.FeatureSet == null)                 return;

            FeatureSet resultFeatureSet = queryArgs.FeatureSet;             ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer =             MyMap.Layers["StatesGraphicsLayerMapTip"] as ESRI.ArcGIS.Client.GraphicsLayer;

            if (resultFeatureSet != null && resultFeatureSet.Features.Count > 0)             {                 foreach (ESRI.ArcGIS.Client.Graphic graphicFeature in resultFeatureSet.Features)                 {                     graphicFeature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;                     graphicsLayer.Graphics.Add(graphicFeature);                 }             }         }

        void CitiesGraphicsLayerLoad()         {             ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query()             {                 ReturnGeometry = true,                 OutSpatialReference = MyMap.SpatialReference             };             query.Where = "1=1";             query.OutFields.Add("*");

            QueryTask queryTask = new QueryTask("http://localhost/ArcGIS/rest/services/Map/MapServer/0");             queryTask.ExecuteCompleted += CitiesGraphicsLayerQueryTask_ExecuteCompleted;             queryTask.Failed += CitisequeryTask_Failed;             queryTask.ExecuteAsync(query);         }

        private void CitisequeryTask_Failed(object sender, TaskFailedEventArgs e)         {             string result = e.ToString();         }

        void CitiesGraphicsLayerQueryTask_ExecuteCompleted(object sender, QueryEventArgs queryArgs)         {             if (queryArgs.FeatureSet == null)                 return;

            FeatureSet resultFeatureSet = queryArgs.FeatureSet;             ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer =             MyMap.Layers["CitiesGraphicsLayerMapTip"] as ESRI.ArcGIS.Client.GraphicsLayer;

            if (resultFeatureSet != null && resultFeatureSet.Features.Count > 0)             {                 foreach (ESRI.ArcGIS.Client.Graphic graphicFeature in resultFeatureSet.Features)                 {                     graphicFeature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;                     graphicsLayer.Graphics.Add(graphicFeature);                 }             }         }

       

      

                          } }

 

注册页

<controls:ChildWindow x:Class="WebGIS.RegistPage"            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"            xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"            Width="400" Height="300"            Title="RegistPage">     <Grid x:Name="LayoutRoot" Margin="2">         <Grid.RowDefinitions>             <RowDefinition />             <RowDefinition Height="75"/>             <RowDefinition Height="75"/>             <RowDefinition Height="75"/>             <RowDefinition Height="35"/>             <RowDefinition Height="Auto" />         </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>             <ColumnDefinition Width="*"/>             <ColumnDefinition Width="140"/>             <ColumnDefinition Width="240"/>             <ColumnDefinition Width="*"/>         </Grid.ColumnDefinitions>                 <TextBlock Text="用户名" FontSize="20" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>         <TextBlock Text="密码" FontSize="20" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>         <TextBlock Text="确认密码" FontSize="20" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>                 <TextBox FontSize="20" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="40"/>         <TextBox FontSize="20" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="40"/>         <TextBox FontSize="20" Grid.Column="2" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="40"/>                 <StackPanel Grid.Column="2" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">             <Button x:Name="OKButton" Content="确定" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" />             <Button x:Name="CancelButton" Content="取消" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0"  />               </StackPanel>         </Grid> </controls:ChildWindow>

 

后台代码

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes;

namespace WebGIS {     public partial class RegistPage : ChildWindow     {         public RegistPage()         {             InitializeComponent();         }

        private void OKButton_Click(object sender, RoutedEventArgs e)         {             this.DialogResult = true;         }

        private void CancelButton_Click(object sender, RoutedEventArgs e)         {             this.DialogResult = false;         }     } }

 

老师例子

标签:

原文地址:http://www.cnblogs.com/aisi-liu/p/4227620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!