ArcGIS网络分析之Silverlight客户端服务区分析(五)-源码部分

MainPage.xaml 页面布局

 

<UserControl x:Class="RouteTaskApp.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"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White" Height="595">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="MyStopsMarkerSymbol" Size="20" Style="Circle" Color="Salmon" >
                <esri:SimpleMarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid>
                            <Ellipse Fill="{Binding Symbol.Color}" Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}" Stroke="Black" StrokeThickness="1" />
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
                                Text="{Binding Path=Attributes[StopNumber]}"
                                FontSize="9" Margin="0" FontWeight="Bold" Foreground="Black" />
                        </Grid>
                    </ControlTemplate>
                </esri:SimpleMarkerSymbol.ControlTemplate>
            </esri:SimpleMarkerSymbol>
            <esri:SimpleMarkerSymbol x:Name="MyBarriesMarkerSymbol" Color="#FF833232" Style="Square" Size="18"/>
            <esri:SimpleLineSymbol x:Name="MyRouteLineSymbol" Color="#990000FF" Width="5"/>
            <esri:SimpleLineSymbol x:Key="RouteRenderer">
                <!--<esri:SimpleRenderer.Symbol>-->
                    <!--<esri:LineSymbol>-->
                        <esri:LineSymbol.ControlTemplate>
                            <ControlTemplate>
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal">
                                                <Storyboard RepeatBehavior="Forever">
                                                    <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="Element"
                     Storyboard.TargetProperty="StrokeDashOffset"
                     To="1000" Duration="0:3:0" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <!--For polyline and polygon template, a Path
             element with the name "Element" is required-->
                                    <Path x:Name="Element" StrokeDashArray="2,1" StrokeDashOffset="0"
              Stroke="#FF1A39E2" StrokeThickness="8" />
                                </Grid>
                            </ControlTemplate>
                        </esri:LineSymbol.ControlTemplate>
                    <!--</esri:LineSymbol>-->
                <!--</esri:SimpleRenderer.Symbol>-->
            </esri:SimpleLineSymbol>
            <esri:SimpleFillSymbol x:Name="MyServiceArea1" Fill="Red" BorderBrush="Yellow" BorderThickness="3"/>
            <esri:SimpleFillSymbol x:Name="MyServiceArea2" Fill="Yellow" BorderBrush="Green" BorderThickness="3"/>
            <esri:SimpleFillSymbol x:Name="MyServiceArea3" Fill="Green" BorderBrush="Blue" BorderThickness="3"/>
        </Grid.Resources>
     <Grid.Effect>
      <DropShadowEffect/>
     </Grid.Effect>
        <StackPanel  Height="300" HorizontalAlignment="Center"  VerticalAlignment="Top" Width="280" Grid.Column="1" Margin="0,260,0,0">
         <ScrollViewer x:Name="DirectionScrollViewer" Height="300" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
          <StackPanel x:Name="DirectionStackPanel" Orientation="Vertical" Margin="0,0,0,10"/>
         </ScrollViewer>
        </StackPanel>
        <esri:Map Background="White" HorizontalAlignment="Stretch" x:Name="MyMap" VerticalAlignment="Stretch" WrapAround="True" Loaded="MyMap_Loaded" MouseClick="MyMap_MouseClick" IsLogoVisible="False">
            <esri:Map.Layers>
                <esri:LayerCollection>
                    <esri:ArcGISTiledMapServiceLayer ID="BaseMap" Url=">
                    <esri:ArcGISDynamicMapServiceLayer ID="ChinaBaseMap" Url="
http://qzj-pc/ArcGIS/rest/services/NetworkAnaysisMap/MapServer"  InitializationFailed="ArcGISDynamicMapServiceLayer_InitializationFailed" />
                    <esri:GraphicsLayer ID="MyServiceAreaLayer" Opacity="0.7"/>
                    <esri:GraphicsLayer ID="MyRouteLayer"/>
                    <esri:GraphicsLayer ID="MyStopGraphicsLayer"/>
                    <esri:GraphicsLayer ID="MyBarriesGraphicsLayer"/>
                    </esri:LayerCollection>
            </esri:Map.Layers>
        </esri:Map>
        <sdk:TabControl Height="144" HorizontalAlignment="Center" x:Name="tabControl1" VerticalAlignment="Top" Width="280" Grid.Column="1" Margin="0,40,0,0" >
            <sdk:TabItem Header="路径查询" x:Name="RouteQueryTabItem">
                <StackPanel  x:Name="RouteQueryStackPanel"  Orientation="Horizontal">
                    <RadioButton Content="停靠点" Height="16" x:Name="StopsRadioButton"  GroupName="PointsType" Margin="20" IsChecked="True" />
                    <RadioButton Content="障碍点" Height="16" x:Name="BarriesRadioButton" GroupName="PointsType" Margin="5" />
                    <Button Content="查询" Height="23" x:Name="QueryBestRouteButton" Width="75" Margin="5"  Click="QueryBestRouteButton_Click" />
                </StackPanel>
            </sdk:TabItem>
            <sdk:TabItem Header="最近设施点查询">
                <StackPanel x:Name="ClosestQueryStackPanel" Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" Margin="5">
                        <TextBlock Height="23" x:Name="textBlock1" Text="选择设施点类型" Margin="25,10,0,0" VerticalAlignment="Top"/>
                    <ComboBox Height="23" x:Name="ClosestFacilityTypeComboBox" Width="120" Margin="10,10,0,0" VerticalAlignment="Top"  SelectionChanged="ClosestFacilityTypeComboBox_SelectionChanged">
                        <ComboBoxItem Content="医院" />
                        <ComboBoxItem Content="警局" />
                        <ComboBoxItem Content="学校" />
                    </ComboBox>
                       </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="5">
                        <TextBlock Height="23" x:Name="textBlock2" Text="查询设施点个数" Margin="25,0,0,0" />
                        <TextBox Height="23" x:Name="ClosestFaciclityNumTextBox" Width="120" Margin="10,0,0,0" Text="3"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="5">
                        <Button Content="查询" Height="23" x:Name="QueryClosestFacilityButton" Width="75" Margin="100,0,0,0" Click="QueryClosestFacilityButton_Click" />
                    </StackPanel>
                </StackPanel>
            </sdk:TabItem>
            <sdk:TabItem Header="服务区查询">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                    <TextBlock Height="23" x:Name="textBlock3" Text="添加要素类型" Margin="10,15,0,0" />
                    <ComboBox Height="23" x:Name="comboBox1" Width="100" Margin="10,15,0,0" SelectedIndex="3">
                            <ComboBoxItem Content="路障点" />
                            <ComboBoxItem Content="路障线" />
                            <ComboBoxItem Content="路障面" />
                            <ComboBoxItem Content="事件点" />
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Height="23" x:Name="textBlock4" Text="服务时间等级" Margin="10,5,0,0"/>
                        <TextBox Height="23" x:Name="ServiceAreaBreakTextBox" Width="100" Margin="10,5,0,0" Text="0.1,0.2,0.3" />
                        <ComboBox Height="23" x:Name="TimeUnitcomboBox"  Margin="5,5,0,0" SelectedIndex="0">
                            <ComboBoxItem Content="小时(h)" />
                            <ComboBoxItem Content="分钟(m)" />
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="查询" Height="23" x:Name="QueryServiceAreaButton" Width="75" Margin="86,8,80,5" Click="QueryServiceAreaButton_Click" />
                    </StackPanel>
                </StackPanel>
            </sdk:TabItem>
        </sdk:TabControl>
        <TextBlock x:Name="DirectionTitleTextBox" Text="方向 指 南" Margin="0,235,0,0" Grid.Column="1" HorizontalAlignment="Center" Height="25" VerticalAlignment="Top" Foreground="#FF0C4B89" FontWeight="Bold" FontSize="16" />
        <Button Content="清空查询点及结果" Grid.Column="1" Height="23" HorizontalAlignment="Center" Margin="0,190,0,0" x:Name="RemoveAllButton" VerticalAlignment="Top" Width="229" Click="RemoveAllButton_Click" />
    </Grid>
</UserControl>

后台

<UserControl x:Class="RouteTaskApp.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"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White" Height="595">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="MyStopsMarkerSymbol" Size="20" Style="Circle" Color="Salmon" >
                <esri:SimpleMarkerSymbol.ControlTemplate>
                    <ControlTemplate>
                        <Grid>
                            <Ellipse Fill="{Binding Symbol.Color}" Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}" Stroke="Black" StrokeThickness="1" />
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
                                Text="{Binding Path=Attributes[StopNumber]}"
                                FontSize="9" Margin="0" FontWeight="Bold" Foreground="Black" />
                        </Grid>
                    </ControlTemplate>
                </esri:SimpleMarkerSymbol.ControlTemplate>
            </esri:SimpleMarkerSymbol>
            <esri:SimpleMarkerSymbol x:Name="MyBarriesMarkerSymbol" Color="#FF833232" Style="Square" Size="18"/>
            <esri:SimpleLineSymbol x:Name="MyRouteLineSymbol" Color="#990000FF" Width="5"/>
            <esri:SimpleLineSymbol x:Key="RouteRenderer">
                <!--<esri:SimpleRenderer.Symbol>-->
                    <!--<esri:LineSymbol>-->
                        <esri:LineSymbol.ControlTemplate>
                            <ControlTemplate>
                                <Grid>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal">
                                                <Storyboard RepeatBehavior="Forever">
                                                    <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetName="Element"
                     Storyboard.TargetProperty="StrokeDashOffset"
                     To="1000" Duration="0:3:0" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <!--For polyline and polygon template, a Path
             element with the name "Element" is required-->
                                    <Path x:Name="Element" StrokeDashArray="2,1" StrokeDashOffset="0"
              Stroke="#FF1A39E2" StrokeThickness="8" />
                                </Grid>
                            </ControlTemplate>
                        </esri:LineSymbol.ControlTemplate>
                    <!--</esri:LineSymbol>-->
                <!--</esri:SimpleRenderer.Symbol>-->
            </esri:SimpleLineSymbol>
            <esri:SimpleFillSymbol x:Name="MyServiceArea1" Fill="Red" BorderBrush="Yellow" BorderThickness="3"/>
            <esri:SimpleFillSymbol x:Name="MyServiceArea2" Fill="Yellow" BorderBrush="Green" BorderThickness="3"/>
            <esri:SimpleFillSymbol x:Name="MyServiceArea3" Fill="Green" BorderBrush="Blue" BorderThickness="3"/>
        </Grid.Resources>
     <Grid.Effect>
      <DropShadowEffect/>
     </Grid.Effect>
        <StackPanel  Height="300" HorizontalAlignment="Center"  VerticalAlignment="Top" Width="280" Grid.Column="1" Margin="0,260,0,0">
         <ScrollViewer x:Name="DirectionScrollViewer" Height="300" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
          <StackPanel x:Name="DirectionStackPanel" Orientation="Vertical" Margin="0,0,0,10"/>
         </ScrollViewer>
        </StackPanel>
        <esri:Map Background="White" HorizontalAlignment="Stretch" x:Name="MyMap" VerticalAlignment="Stretch" WrapAround="True" Loaded="MyMap_Loaded" MouseClick="MyMap_MouseClick" IsLogoVisible="False">
            <esri:Map.Layers>
                <esri:LayerCollection>
                    <esri:ArcGISTiledMapServiceLayer ID="BaseMap" Url=">
                    <esri:ArcGISDynamicMapServiceLayer ID="ChinaBaseMap" Url="
http://qzj-pc/ArcGIS/rest/services/NetworkAnaysisMap/MapServer"  InitializationFailed="ArcGISDynamicMapServiceLayer_InitializationFailed" />
                    <esri:GraphicsLayer ID="MyServiceAreaLayer" Opacity="0.7"/>
                    <esri:GraphicsLayer ID="MyRouteLayer"/>
                    <esri:GraphicsLayer ID="MyStopGraphicsLayer"/>
                    <esri:GraphicsLayer ID="MyBarriesGraphicsLayer"/>
                    </esri:LayerCollection>
            </esri:Map.Layers>
        </esri:Map>
        <sdk:TabControl Height="144" HorizontalAlignment="Center" x:Name="tabControl1" VerticalAlignment="Top" Width="280" Grid.Column="1" Margin="0,40,0,0" >
            <sdk:TabItem Header="路径查询" x:Name="RouteQueryTabItem">
                <StackPanel  x:Name="RouteQueryStackPanel"  Orientation="Horizontal">
                    <RadioButton Content="停靠点" Height="16" x:Name="StopsRadioButton"  GroupName="PointsType" Margin="20" IsChecked="True" />
                    <RadioButton Content="障碍点" Height="16" x:Name="BarriesRadioButton" GroupName="PointsType" Margin="5" />
                    <Button Content="查询" Height="23" x:Name="QueryBestRouteButton" Width="75" Margin="5"  Click="QueryBestRouteButton_Click" />
                </StackPanel>
            </sdk:TabItem>
            <sdk:TabItem Header="最近设施点查询">
                <StackPanel x:Name="ClosestQueryStackPanel" Orientation="Vertical">
                    <StackPanel Orientation="Horizontal" Margin="5">
                        <TextBlock Height="23" x:Name="textBlock1" Text="选择设施点类型" Margin="25,10,0,0" VerticalAlignment="Top"/>
                    <ComboBox Height="23" x:Name="ClosestFacilityTypeComboBox" Width="120" Margin="10,10,0,0" VerticalAlignment="Top"  SelectionChanged="ClosestFacilityTypeComboBox_SelectionChanged">
                        <ComboBoxItem Content="医院" />
                        <ComboBoxItem Content="警局" />
                        <ComboBoxItem Content="学校" />
                    </ComboBox>
                       </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="5">
                        <TextBlock Height="23" x:Name="textBlock2" Text="查询设施点个数" Margin="25,0,0,0" />
                        <TextBox Height="23" x:Name="ClosestFaciclityNumTextBox" Width="120" Margin="10,0,0,0" Text="3"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="5">
                        <Button Content="查询" Height="23" x:Name="QueryClosestFacilityButton" Width="75" Margin="100,0,0,0" Click="QueryClosestFacilityButton_Click" />
                    </StackPanel>
                </StackPanel>
            </sdk:TabItem>
            <sdk:TabItem Header="服务区查询">
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                    <TextBlock Height="23" x:Name="textBlock3" Text="添加要素类型" Margin="10,15,0,0" />
                    <ComboBox Height="23" x:Name="comboBox1" Width="100" Margin="10,15,0,0" SelectedIndex="3">
                            <ComboBoxItem Content="路障点" />
                            <ComboBoxItem Content="路障线" />
                            <ComboBoxItem Content="路障面" />
                            <ComboBoxItem Content="事件点" />
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Height="23" x:Name="textBlock4" Text="服务时间等级" Margin="10,5,0,0"/>
                        <TextBox Height="23" x:Name="ServiceAreaBreakTextBox" Width="100" Margin="10,5,0,0" Text="0.1,0.2,0.3" />
                        <ComboBox Height="23" x:Name="TimeUnitcomboBox"  Margin="5,5,0,0" SelectedIndex="0">
                            <ComboBoxItem Content="小时(h)" />
                            <ComboBoxItem Content="分钟(m)" />
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="查询" Height="23" x:Name="QueryServiceAreaButton" Width="75" Margin="86,8,80,5" Click="QueryServiceAreaButton_Click" />
                    </StackPanel>
                </StackPanel>
            </sdk:TabItem>
        </sdk:TabControl>
        <TextBlock x:Name="DirectionTitleTextBox" Text="方向 指 南" Margin="0,235,0,0" Grid.Column="1" HorizontalAlignment="Center" Height="25" VerticalAlignment="Top" Foreground="#FF0C4B89" FontWeight="Bold" FontSize="16" />
        <Button Content="清空查询点及结果" Grid.Column="1" Height="23" HorizontalAlignment="Center" Margin="0,190,0,0" x:Name="RemoveAllButton" VerticalAlignment="Top" Width="229" Click="RemoveAllButton_Click" />
    </Grid>
</UserControl>

设施点添加AddFacilitiesName.xaml

<controls:ChildWindow x:Class="RouteTaskApp.AddFacilitiesName"
           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="200" Height="200"
           Title="AddFacilitiesName" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Closed="ChildWindow_Closed">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Button x:Name="CancelButton" Content="取消" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="确认" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        <sdk:Label Height="25" HorizontalAlignment="Left" Name="label1" VerticalAlignment="Top" Width="80" Margin="24,26,0,0" Content="设施点名称:" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="24,71,0,0" Name="NameTextBox" VerticalAlignment="Top" Width="120" />
    </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 RouteTaskApp
{
    public partial class AddFacilitiesName : ChildWindow
    {
        public event EventHandler OnAddFacilityName;
        public AddFacilitiesName()
        {
            InitializeComponent();
        }

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

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

        private void ChildWindow_Closed(object sender, EventArgs e)
        {

        }
    }
}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值