ArcGis API FOR Silverlight 做了个导航工具~

原文 http://www.cnblogs.com/thinkaspx/archive/2012/08/08/2628214.html

转载请注明文章出处:http://www.cnblogs.com/thinkaspx

地图是读取的谷歌图层。。

主要是导航工具 做出来费劲呀。。

马上上代码

namespace ZoomwayWebGis.Controls.Generic
{
    [TemplatePart(Name = "PanLeft", Type = typeof(FrameworkElement))]
    [TemplatePart(Name = "PanRight", Type = typeof(FrameworkElement))]
    [TemplatePart(Name = "PanUp", Type = typeof(FrameworkElement))]
    [TemplatePart(Name = "PanDown", Type = typeof(FrameworkElement))]
    [TemplatePart(Name = "ZoomSlider", Type = typeof(Slider))]
    [TemplatePart(Name = "ZoomInButton", Type = typeof(Button))]
    [TemplatePart(Name = "ZoomOutButton", Type = typeof(Button))]
    [TemplatePart(Name = "InstanceMark", Type = typeof(Button))]
    public class MapNavigator : ContentControl
    {
        FrameworkElement PanLeft;
        FrameworkElement PanRight;
        FrameworkElement PanUp;
        FrameworkElement PanDown;
        Button ZoomInButton;
        Button ZoomOutButton;
        Slider ZoomSlider;

        private double _panFactor = 0.5;
        private const double MaxResolution = 23218.433769164774;
        private const double MinResolution = 0.59716428347743467;

        public MapNavigator()
        {
            this.DefaultStyleKey = typeof(MapNavigator);
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            PanLeft = GetTemplateChild("PanLeft") as FrameworkElement;
            PanRight = GetTemplateChild("PanRight") as FrameworkElement;
            PanUp = GetTemplateChild("PanUp") as FrameworkElement;
            PanDown = GetTemplateChild("PanDown") as FrameworkElement;
            ZoomSlider = GetTemplateChild("ZoomSlider") as Slider;
            ZoomInButton = GetTemplateChild("ZoomInButton") as Button;
            ZoomOutButton = GetTemplateChild("ZoomOutButton") as Button;

            enablePanElement(PanLeft);
            enablePanElement(PanRight);
            enablePanElement(PanUp);
            enablePanElement(PanDown);

            // Set control's flow direction to LTR to avoid flipping East and West keys:
            this.FlowDirection = System.Windows.FlowDirection.LeftToRight;

            if (ZoomSlider != null)
            {
                if (Map != null)
                {
                    SetupZoom();
                }

                ZoomSlider.Minimum = 0;
                ZoomSlider.Maximum = 1;
                ZoomSlider.SmallChange = .01;
                ZoomSlider.LargeChange = .1;
                ZoomSlider.LostMouseCapture += ZoomSlider_LostMouseCapture;
                ZoomSlider.LostFocus += ZoomSlider_LostMouseCapture;
            }
            if (ZoomInButton != null)
                ZoomInButton.Click += ZoomInButton_Click;
            if (ZoomOutButton != null)
                ZoomOutButton.Click += ZoomOutButton_Click;

            bool isDesignMode = System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);
            if (isDesignMode)
                mouseOver = isDesignMode;
            ChangeVisualState(false);
        }

        private void ZoomOutButton_Click(object sender, RoutedEventArgs e)
        {
            Map.Zoom(1 / Map.ZoomFactor);
        }

        private void ZoomInButton_Click(object sender, RoutedEventArgs e)
        {
            Map.Zoom(Map.ZoomFactor);
        }

        private void Map_ExtentChanged(object sender, ExtentEventArgs args)
        {
            if (!double.IsNaN(Map.Resolution) && ZoomSlider != null)
                ZoomSlider.Value = ResolutionToValue(Map.Resolution);
        }

        #region State management

        private bool mouseOver = false;

        protected override void OnMouseLeave(MouseEventArgs e)
        {
            mouseOver = false;
            if (!trackingRotation)
                ChangeVisualState(true);
            base.OnMouseLeave(e);
        }

        protected override void OnMouseEnter(MouseEventArgs e)
        {
            mouseOver = true;
            ChangeVisualState(true);
            base.OnMouseEnter(e);
        }

        private void ChangeVisualState(bool useTransitions)
        {
            if (mouseOver)
            {
                GoToState(useTransitions, "MouseOver");
            }
            else
            {
                GoToState(useTransitions, "Normal");
            }
        }

        private bool GoToState(bool useTransitions, string stateName)
        {
            return VisualStateManager.GoToState(this, stateName, useTransitions);
        }

        #endregion

        #region Rotation

        Point startMousePos;
        private double angle = 0;
        private bool trackingRotation = false;

        private double GetAngle(Point a, Point b)
        {
            if (a == null || b == null) return 0;
            return Math.Atan2((b.X - a.X), (a.Y - b.Y)) / Math.PI * 180;
        }

        #endregion

        #region Zoom

        private void ZoomSlider_LostMouseCapture(object sender, EventArgs e)
        {
            Map.ZoomToResolution(ValueToResolution(ZoomSlider.Value));
        }

        #endregion

        private void enablePanElement(FrameworkElement element)
        {
            if (element == null) return;
            element.MouseLeave += panElement_MouseLeftButtonUp;
            element.MouseLeftButtonDown += panElement_MouseLeftButtonDown;
            element.MouseLeftButtonUp += panElement_MouseLeftButtonUp;
        }

        private void panElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (Map == null || sender == null) return;

            Envelope env = Map.Extent;
            if (env == null) return;
            double x = 0, y = 0;
            MapPoint oldCenter = env.GetCenter();
            MapPoint newCenter = null;
            var height = env.Height * _panFactor;
            var width = env.Width * _panFactor;
            // if units are degrees (the default), limit or alter panning to the lat/lon limits
            if (sender == PanUp) // North
            {
                y = oldCenter.Y + height;
                newCenter = new MapPoint(oldCenter.X, y);
            }
            else if (sender == PanRight) // East
            {
                x = oldCenter.X + width;
                newCenter = new MapPoint(x, oldCenter.Y);
            }
            else if (sender == PanLeft) // West
            {
                x = oldCenter.X - width;
                newCenter = new MapPoint(x, oldCenter.Y);
            }
            else if (sender == PanDown) // South
            {
                y = oldCenter.Y - height;
                newCenter = new MapPoint(oldCenter.X, y);
            }

            if (newCenter != null)
                Map.PanTo(newCenter);

        }

        private void panElement_MouseLeftButtonUp(object sender, MouseEventArgs e)
        {
            if (Map == null) return;
        }

        private double ValueToResolution(double value)
        {
            double max = Math.Log10(MaxResolution);
            double min = Math.Log10(MinResolution);
            double resLog = (1 - value) * (max - min) + min;
            return Math.Pow(10, resLog);
        }

        private double ResolutionToValue(double resolution)
        {
            double max = Math.Log10(MaxResolution);
            double min = Math.Log10(MinResolution);
            double value = 1 - ((Math.Log10(resolution) - min) / (max - min));
            return Math.Min(1, Math.Max(value, 0)); //cap values between 0..1
        }

        public void SetupZoom()
        {
            if (ZoomSlider != null && Map != null)
            {
                if (!double.IsNaN(MinResolution) && !double.IsNaN(MaxResolution) &&
                    MaxResolution != double.MaxValue &&
                    MinResolution != double.Epsilon &&
                    !double.IsNaN(Map.Resolution))
                {
                    ZoomSlider.Value = ResolutionToValue(Map.Resolution);
                }
            }
        }

        #region Properties

        public static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map", typeof(Map), typeof(MapNavigator), new PropertyMetadata(OnMapPropertyChanged));

        private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MapNavigator nav = d as MapNavigator;
            Map map = e.NewValue as Map;
            Map oldmap = e.OldValue as Map;

            if (oldmap != null)
            {
                oldmap.RotationChanged -= nav.Map_RotationChanged;
                oldmap.ExtentChanged -= nav.Map_ExtentChanged;
                oldmap.ExtentChanging -= nav.Map_ExtentChanged;
                if (oldmap.Layers != null)
                    oldmap.Layers.LayersInitialized -= nav.Layers_LayersInitialized;
            }
            if (map != null)
            {
                map.RotationChanged += nav.Map_RotationChanged;
                map.ExtentChanged += nav.Map_ExtentChanged;
                map.ExtentChanging += nav.Map_ExtentChanged;
                if (map.Layers != null)
                    map.Layers.LayersInitialized += nav.Layers_LayersInitialized;
                nav.SetupZoom();
            }
        }

        private void Layers_LayersInitialized(object sender, EventArgs args)
        {
            SetupZoom();
        }

        public Map Map
        {
            get { return GetValue(MapProperty) as Map; }
            set { SetValue(MapProperty, value); }
        }

        public Double PanFactor { get { return _panFactor; } set { _panFactor = value; } }

        private void Map_RotationChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            double value = (this.FlowDirection == System.Windows.FlowDirection.LeftToRight) ? (double)e.NewValue : -(double)e.NewValue;
            angle = (double)e.NewValue;
        }

        #endregion
    }

 

 <Style TargetType="nmap:MapNavigator">
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Background" Value="#F0999988" />
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate  TargetType="nmap:MapNavigator">
                    <Grid x:Name="NavigatorRootGrid" Background="Transparent" RenderTransformOrigin="0.5,0.5" Opacity="1">
                        <Grid.Resources>
                            <RadialGradientBrush x:Key="CircleButtonGradientBrush" GradientOrigin="0.25,0.25">
                                <GradientStop Offset="0.25" Color="#99CCCCCC"/>
                                <GradientStop Offset="1.00" Color="#99000000"/>
                            </RadialGradientBrush>

                            <SolidColorBrush x:Key="HoverShineBrush" Color="#749dd2" />
                            <DropShadowEffect x:Key="HoverShineEffect" Color="#749dd2" BlurRadius="20" ShadowDepth="0" />

                            <LinearGradientBrush x:Key="ThumbGradientBrush" EndPoint="0.5,0.95" StartPoint="0.5,0.05">
                                <GradientStop Color="#749dd2" Offset="0" />
                                <GradientStop Color="#749dd2" Offset="1" />
                            </LinearGradientBrush>

                            <LinearGradientBrush x:Key="ThumbPressedBrush" EndPoint="0.5,0.95" StartPoint="0.5,0.05">
                                <GradientStop Color="#99CCCCCC" Offset="0" />
                                <GradientStop Color="#99333333" Offset="1" />
                            </LinearGradientBrush>

                            <!--Circle Button Style-->
                            <Style TargetType="Button" x:Key="CircleButtonStyle" >
                                <Setter Property="Background" Value="#F0CCCCCC" />
                                <Setter Property="Foreground" Value="#FF000000" />
                                <Setter Property="BorderBrush" Value="#F0333333" />
                                <Setter Property="BorderThickness" Value="1" />
                                <Setter Property="Padding" Value="0"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" TargetType="Button">
                                            <Grid x:Name="ButtonRootGrid" Background="Transparent">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates" >
                                                        <VisualState x:Name="Normal" />
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="HoverShineShape" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.1" />
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Pressed" />
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="DisabledMask" Storyboard.TargetProperty="Opacity" To="0.7" Duration="0:0:0.1" />
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Ellipse x:Name="BackgroundShape" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
                                            Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}"
                                            StrokeThickness="{TemplateBinding BorderThickness}"/>
                                                <Ellipse x:Name="HoverShineShape" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
                                            Fill="{StaticResource HoverShineBrush}" Stroke="#00FFFFFF" StrokeThickness="0"
                                            Effect="{StaticResource HoverShineEffect}" Opacity="0.0" />
                                                <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}"
                                            ContentTemplate="{TemplateBinding ContentTemplate}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" />
                                                <Ellipse x:Name="DisabledMask" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
                                            Fill="#F0999999" Stroke="#00FFFFFF" StrokeThickness="0" Opacity="0.0" IsHitTestVisible="false"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>

                            <!-- Zoom Bar Thumb Style-->
                            <Style TargetType="Thumb" x:Key="ZoomBarThumbStyle">
                                <Setter Property="Background" Value="{StaticResource ThumbGradientBrush}" />
                                <Setter Property="BorderThickness" Value="1" />
                                <Setter Property="IsTabStop" Value="False" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Thumb">
                                            <Grid x:Name="ThumbRootGrid" Background="Transparent">
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualStateGroup.Transitions>
                                                            <VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver" />
                                                            <VisualTransition GeneratedDuration="00:00:00.1" To="Pressed" />
                                                            <VisualTransition From="Normal" GeneratedDuration="00:00:00.25" To="MouseOver" />
                                                            <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.25" To="Normal" />
                                                            <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.25" To="Pressed" />
                                                            <VisualTransition From="Pressed" GeneratedDuration="00:00:00.25" To="MouseOver" />
                                                        </VisualStateGroup.Transitions>
                                                        <VisualState x:Name="Normal" />
                                                        <VisualState x:Name="MouseOver">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="HoverShineBorder" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.1" />
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Pressed">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="PressedBorder" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.1" />
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="DisabledBorder" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.1" />
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Border x:Name="BackgroundBorder" Background="{TemplateBinding Background}"
                                         BorderBrush="{TemplateBinding BorderBrush}"
                                         BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" />
                                                <Border x:Name="HoverShineBorder" Background="{StaticResource HoverShineBrush}"
                                         BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                                          CornerRadius="2" Opacity="0" />
                                                <Border x:Name="PressedBorder" Background="{StaticResource ThumbPressedBrush}"
                                         BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Opacity="0" />
                                                <Border x:Name="DisabledBorder" Background="#F0999999" IsHitTestVisible="false" CornerRadius="2" Opacity="0" />
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>

                            <!-- Zoom Slider Style-->
                            <Style TargetType="Slider" x:Key="ZoomSliderStyle">
                                <Setter Property="BorderThickness" Value="1" />
                                <Setter Property="BorderBrush" Value="#99666666" />
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="Foreground" Value="#99666666" />
                                <Setter Property="IsTabStop" Value="False" />
                                <Setter Property="Maximum" Value="1" />
                                <Setter Property="Minimum" Value="0" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Slider">
                                            <Grid x:Name="LayoutRoot" Background="Transparent">
                                                <Grid.Resources>
                                                    <ControlTemplate x:Key="RepeatButtonTemplate1">
                                                        <Grid x:Name="Root" Opacity="0" Background="Transparent" />
                                                    </ControlTemplate>
                                                    <ControlTemplate x:Key="RepeatButtonTemplate2">
                                                        <Grid x:Name="Root" Opacity="1" Background="{StaticResource HoverShineBrush}"  />
                                                    </ControlTemplate>
                                                </Grid.Resources>
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal" />
                                                        <VisualState x:Name="MouseOver" />
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                                    <SplineDoubleKeyFrame KeyTime="0" Value="0.5" />
                                                                </DoubleAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Grid x:Name="HorizontalTemplate" Margin="0,0,0,0" Background="Transparent">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="Auto" />
                                                        <ColumnDefinition Width="Auto" />
                                                        <ColumnDefinition Width="*" />
                                                    </Grid.ColumnDefinitions>
                                                    <Rectangle Margin="0,4,0,4" Grid.Column="0" Grid.ColumnSpan="3" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Opacity="0.8" RadiusX="2" RadiusY="2" />
                                                    <RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButton" Margin="0,4,0,4" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate2}" Grid.Column="0" />
                                                    <RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButton" Margin="0,4,0,4" IsTabStop="False" Template="{StaticResource RepeatButtonTemplate1}" Grid.Column="2" />
                                                    <Thumb x:Name="HorizontalThumb" Height="{TemplateBinding Height}" Width="8" Grid.Column="1" IsTabStop="True" Style="{StaticResource ZoomBarThumbStyle}" />
                                                </Grid>
                                                <Grid x:Name="VerticalTemplate" Margin="0,0,0,0" Visibility="Collapsed" Background="Transparent">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="*" />
                                                        <RowDefinition Height="Auto" />
                                                        <RowDefinition Height="Auto" />
                                                    </Grid.RowDefinitions>
                                                    <Rectangle Margin="4,0,4,0" Grid.Row="0" Grid.RowSpan="3" Fill="{TemplateBinding Background}"
                                             Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Opacity="0.8" RadiusX="2" RadiusY="2" />
                                                    <RepeatButton x:Name="VerticalTrackLargeChangeDecreaseRepeatButton" Margin="4,0,4,0" IsTabStop="False"
                                             Template="{StaticResource RepeatButtonTemplate2}" Grid.Row="2" />
                                                    <RepeatButton x:Name="VerticalTrackLargeChangeIncreaseRepeatButton" Margin="4,0,4,0" IsTabStop="False"
                                             Template="{StaticResource RepeatButtonTemplate1}" Grid.Row="0" BorderBrush="{StaticResource HoverShineBrush}" />
                                                    <Grid Margin="6,2,6,2" Grid.Row="0"
                                             Grid.RowSpan="3" HorizontalAlignment="Stretch"
                                              VerticalAlignment="Stretch" IsHitTestVisible="False"
                                               Background="#FFFBF9FA" >
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                        </Grid.RowDefinitions>
                                                        <Rectangle Grid.Row="0" Fill="{TemplateBinding Foreground}" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="1" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="2" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="3" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="4" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="5" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="6" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="7" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="8" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="9" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="10" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="11" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="12" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="13" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="14" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="15" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="16" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="17" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="18" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                        <Rectangle Grid.Row="19" Fill="{TemplateBinding Foreground}" Stroke="#F0FFFFFF" StrokeThickness="0" Margin="1" RadiusX="0" RadiusY="0" Height="1" />
                                                    </Grid>
                                                    <Thumb x:Name="VerticalThumb"
                                                            Width="{TemplateBinding Width}" Grid.Row="1" Height="8" IsTabStop="True"
                                                            Style="{StaticResource ZoomBarThumbStyle}" >
                                                        <Thumb.BorderBrush>
                                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                                <GradientStop Color="#FFA3AEB9" Offset="0"/>
                                                                <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                                                <GradientStop Color="#FF718597" Offset="0.375"/>
                                                                <GradientStop Color="#FF6C84A4" Offset="1"/>
                                                            </LinearGradientBrush>
                                                        </Thumb.BorderBrush>
                                                        <Thumb.Background>
                                                            <RadialGradientBrush>
                                                                <GradientStop Color="#FF749DD2" Offset="0"/>
                                                                <GradientStop Color="#FF749DD2" Offset="1"/>
                                                            </RadialGradientBrush>
                                                        </Thumb.Background>
                                                    </Thumb>
                                                </Grid>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="64" />
                            <RowDefinition Height="0" />
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates" >
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="NavigatorRootGrid" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Grid x:Name="Navigator" Grid.Row="0" Width="60" Height="60" Background="Transparent" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
                            <Grid.RenderTransform>
                                <RotateTransform x:Name="TransformRotate" Angle="0"/>
                            </Grid.RenderTransform>
                            <Ellipse x:Name="RotateRing1" Width="60" Height="60" HorizontalAlignment="Center"
                                     VerticalAlignment="Center" StrokeThickness="{TemplateBinding BorderThickness}"
                                     Stroke="#FFA6A6A6">
                                <Ellipse.Fill>
                                    <RadialGradientBrush>
                                        <GradientStop Color="#FFFBF9FA" Offset="0"/>
                                        <GradientStop Color="#FFFBF9FA" Offset="1"/>
                                    </RadialGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                            <local:ButtonGrid x:Name="PanUp" Margin="0,2,0,0"
                                                BackgroundShape="M0.0,4.0 A10,3.0 0 0 1 20,4.0 L16,16 A8.0,4.0 0 0 0 4.0,16 L0.0,4.0 z"
                                                ForegroundShape="M0.0,1.0 L0.5,0.0 L1.0,1.0 z" Width="20" Height="16" ForeBorderBrush="Transparent"
                                                ForeBorderThick="0" ForeShapeFill="{TemplateBinding Foreground}" MouseOverBackFill="#F0999999"
                                                MouseOverForeFill="Cyan" VerticalAlignment="Top" HorizontalAlignment="Center"
                                                ToolTipService.ToolTip="向上平移" Cursor="Hand" />
                            <local:ButtonGrid x:Name="PanDown" Margin="0,0,0,2" BackgroundShape="M20,12 A10,3.0 0 0 1 0.0,12 L4.0,0.0 A8.0,4.0 0 0 0 16,0.0 L20.0,12 z"
                                                ForegroundShape="M0.0,0.0 L0.5,1.0 L1.0,0.0" Width="20" Height="16"
                                                ForeBorderBrush="{TemplateBinding Foreground}" MouseOverBackFill="#F0999999" MouseOverForeBorderBrush="Cyan"
                                                VerticalAlignment="Bottom" HorizontalAlignment="Center" ToolTipService.ToolTip="向下平移" Cursor="Hand"/>
                            <local:ButtonGrid x:Name="PanLeft" Margin="2,0,0,0" BackgroundShape="M4.0,0.0 L16,4.0 A4.0,8.0 0 0 0 16,16 L4.0,20 A3.0,10 0 0 1 4.0,0.0 z"
                                                ForegroundShape="M1.0,0.0 L0.0,0.5 L1.0,1.0" Width="16" Height="20"
                                                ForeBorderBrush="{TemplateBinding Foreground}" MouseOverBackFill="#F0999999" MouseOverForeBorderBrush="Cyan"
                                                HorizontalAlignment="Left" VerticalAlignment="Center" ToolTipService.ToolTip="向左平移" Cursor="Hand"/>
                            <local:ButtonGrid x:Name="PanRight" Margin="0,0,2,0" BackgroundShape="M12,0 A3.0,10 0 0 1 12,20 L0.0,16 A4.0,8.0 0 0 0 0.0,4.0 L12.0,0.0 z"
                                                ForegroundShape="M0.0,0.0 L1.0,0.5 L0.0,1.0" Width="16" Height="20"
                                                ForeBorderBrush="{TemplateBinding Foreground}" MouseOverBackFill="#F0999999" MouseOverForeBorderBrush="Cyan"
                                                HorizontalAlignment="Right" VerticalAlignment="Center" ToolTipService.ToolTip="向右平移" Cursor="Hand"/>
                            <Button x:Name="ResetRotation" Margin="0,0,0,0" Visibility="Collapsed" Style="{StaticResource CircleButtonStyle}" Height="24" Width="24"
                                    HorizontalAlignment="Center" VerticalAlignment="Center" Background="#F0FFFFFF" BorderBrush="Transparent" BorderThickness="0"
                                    ToolTipService.ToolTip="Reset Map North" Cursor="Hand">
                                <Image Source="../Images/icons/i_nav.png" Width="20" Height="20" Stretch="Uniform" />
                            </Button>
                        </Grid>

                        <Grid x:Name="ZoomHistoryPanel" Grid.Row="1" Margin="0,8,0,8" Visibility="Collapsed" Background="Transparent" HorizontalAlignment="Center">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="16"/>
                                <ColumnDefinition Width="24"/>
                                <ColumnDefinition Width="16"/>
                            </Grid.ColumnDefinitions>
                            <local:ButtonGrid  x:Name="ZoomBackButton" Grid.Column="0" Margin="1,0,-1,0"
                                                BackgroundShape="M4.0,0.0 L16,4.0 A4.0,8.0 0 0 0 16,16 L4.0,20 A3.0,10 0 0 1 4.0,0.0 z"
                                                ForegroundShape="M1.0,0.0 L0.0,0.5 L1.0,1.0" Width="16" Height="20" BackShapeFill="{TemplateBinding Background}"
                                                ForeBorderBrush="{TemplateBinding Foreground}" MouseOverBackFill="#F0666666" MouseOverForeBorderBrush="Cyan"
                                                HorizontalAlignment="Left" VerticalAlignment="Center" ToolTipService.ToolTip="Zoom to Previous Extent" Cursor="Hand"/>
                            <Button x:Name="ZoomFullButton" Grid.Column="1" Margin="0,0,0,0" Height="24" Width="24" Style="{StaticResource CircleButtonStyle}" Background="#F0FFFFFF" BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTipService.ToolTip="Zoom to Full Extent" Cursor="Hand">
                                <Image Source="../Images/icons/i_globe.png"  Width="20" Height="20" Stretch="Uniform" />
                            </Button>
                            <local:ButtonGrid x:Name="ZoomNextButton" Grid.Column="2" Margin="-1,0,1,0" BackgroundShape="M12,0 A3.0,10 0 0 1 12,20 L0.0,16 A4.0,8.0 0 0 0 0.0,4.0 L12.0,0.0 z" ForegroundShape="M0.0,0.0 L1.0,0.5 L0.0,1.0" Width="16" Height="20" BackShapeFill="{TemplateBinding Background}" ForeBorderBrush="{TemplateBinding Foreground}" MouseOverBackFill="#F0666666" MouseOverForeBorderBrush="Cyan" HorizontalAlignment="Right" VerticalAlignment="Center" ToolTipService.ToolTip="Zoom to Next Extent" Cursor="Hand"/>
                        </Grid>

                        <Border x:Name="ZoomSliderBorder" Grid.Row="2" Background="Transparent"
                                BorderBrush="Transparent" BorderThickness="0" CornerRadius="0" HorizontalAlignment="Center">
                            <StackPanel x:Name="ZoomStack" Orientation="Vertical">
                                <Button x:Name="ZoomInButton" Height="15" Width="22" Margin="2,4,2,0" Foreground="Black"
                                        BorderBrush="#FFA6A6A6" BorderThickness="1" ToolTipService.ToolTip="Zoom In" Cursor="Hand" >
                                    <Button.Background>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#FFFBF9FA" Offset="0"/>
                                            <GradientStop Color="#FFFBF9FA" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Button.Background>
                                    <Path Stroke="#a6a6a6" StrokeThickness="2"
                                          Width="10" Height="10" Stretch="Fill" Data="M0.0,0.5 L1.0,0.5 M0.5,0.0 L0.5,1.0"
                                          Fill="#FF949494"/>
                                </Button>
                                <Grid x:Name="ZoomLevelGrid">
                                    <Slider x:Name="ZoomSlider" Orientation="Vertical" Height="150" Width="20" Foreground="{StaticResource ThumbGradientBrush}"
                                            Minimum="0" Maximum="1" SmallChange="1" LargeChange="1"
                                            ToolTipService.ToolTip="拖动缩放" Style="{StaticResource ZoomSliderStyle}"
                                            BorderBrush="#a6a6a6" RenderTransformOrigin="0,0" Cursor="SizeNS" Background="#fbf9fa" />
                                </Grid>
                                <Button x:Name="ZoomOutButton" Height="15" Width="22" Margin="2,0,2,4" Foreground="Black"
                                        BorderBrush="#FFA6A6A6" BorderThickness="1" ToolTipService.ToolTip="Zoom Out" Cursor="Hand">
                                    <Button.Background>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#FFFBF9FA" Offset="0"/>
                                            <GradientStop Color="White" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Button.Background>
                                    <Path Stroke="#a6a6a6"  StrokeThickness="2" Width="10" Height="10" Stretch="Fill" Data="M0.0,0.5 L1.0,0.5"/>
                                </Button>
                            </StackPanel>
                        </Border>

                        <ContentPresenter Grid.Row="3" ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Content="{TemplateBinding Content}"
                                          Margin="{TemplateBinding Padding}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

时间: 2024-08-06 07:34:28

ArcGis API FOR Silverlight 做了个导航工具~的相关文章

ArcGIS API for Silverlight开发入门

你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我 都没关系.但你不能否认3G是一种趋势,最终我们每个人都会被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击犯罪,会在你的1100上强制 装上GPS.GIS工作既然建立在计算机的基础上,当然也得随着IT行业与时俱进.       看看现在计算机应用的趋势吧.云(计算),这个东西可讲不清楚,因为云嘛,飘忽不定的.不过可以这样来看它,以后计算机网络上就有一坨(或者几坨)万能的 云,有什么需求云都可以满足我们,

arcgis api for silverlight

原文 http://blog.sina.com.cn/s/blog_4638cf7b0100wntt.html arcgis api for silverlight(1) (2011-09-21 09:09:26) 转载▼ 标签: 杂谈 分类: 技术 发现了一个很好的学习工具,就是Esri的在线帮助,包括概念,例子,API介绍等等.接下来的学习基本上就是按照例子结合开发方案进行实践学习. http://help.arcgis.com/en/webapi/silverlight/samples/s

使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示

原文:使用Visifire+ArcGIS API for Silverlight实现Graphic信息的动态图表显示   首先来看一看实现的效果: PS:原始的程序中更新曲线数据时添加了过渡的效果,具体可查看官网的示例: http://www.visifire.com/silverlight_spline_charts_gallery.php 点击其中的一个例子,然后点击Live Updates,就可看到数据更新时的过渡效果.但是蛋疼的博客园,不知道为什么,我插入了我原始的xap文件,过渡效果却

ArcGIS API for Silverlight开发入门准备

原文:ArcGIS API for Silverlight开发入门准备          微软的Silverlight提供了跨浏览器和跨平台开发环境,在Web中可用于创建和展现富互联网应用(RIA,Rich  Internet Application).          ArcGIS API for Silverlight 能够让的Silverlight应用程序具有集成ArcGIS Server.ESRI MapIt和Bing Maps服务的能力.利用 ArcGIS Server 和Bing

ArcGIS API for Silverlight学习笔记

ArcGIS API for Silverlight学习笔记(一):为什么要用Silverlight API(转) 你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我都没关系.但你不能否认3G是一种趋势,最终我们每个人都会 被包裹在3G网络中.1100也不是一成不变,没准哪天为了打击犯罪,会在你的1100上强制装上GPS.GIS工作既然建立在计算机的基础上,当然也得 随着IT行业与时俱进.       看看现在计算机应用的趋势吧.云(计算),这个东西可讲不清楚,因

ArcGIS API for Silverlight 使用GP服务实现要素裁剪功能

原文:ArcGIS API for Silverlight 使用GP服务实现要素裁剪功能      昨天一QQ好友问了一个关于裁剪的问题,感觉自己也没有帮上什么忙,之后自己做了一个裁剪的例子,不过在做这个例子的时候还遇到了不少的问题,在此和大家分享一下. 1.裁剪功能的实现过程 这里的裁剪功能很简单,只需要一个Clip(裁剪)工具即可. 但是这里需要注意的问题是裁剪工具的参数: 裁剪工具有两个输入参数: a.输入要素:这里指的是你用什么来裁剪目标要素,也就是你用什么裁剪 b.裁剪要素:这里指的被

ArcGIS API for Silverlight 点沿着线流动

原文:ArcGIS API for Silverlight 点沿着线流动 概述 前段时间做了一个项目,要求是有一些电力输送线,电力输送线或者石油管道都是有流动方向的,用户想做一个动态效果来模拟电力的输送.其实做简单了只要在线上标识个箭头就可以了.但也要是做成动态的,至少ArcEngine实现起来是有点麻烦的.但ArcGIS API for Silverlight可以解决这个问题. 实现思路 在地图上展示输送电力的线和模拟电力输送方向的电都是ArcGIS  API中定义的对象,否者这些数据在地图上

arcgis api for silverlight使用google map等多个在线地图

原文 http://blog.csdn.net/leesmn/article/details/6820245 无可否认,google map实在是很漂亮.可惜对于使用arcgis api for silverlight的我们来说,无法使用它的确不爽.虽然,arcgis api for silverlight可以使用bing map.但是bing map中国地区的地图很差,城市道路信息几乎没有.稍微得到些许安慰的是最新版本(比方2.2版本)可以支持OpenStreetMap,效果比bing map

创建第一个ArcGIS API for Silverlight应用

原文:创建第一个ArcGIS API for Silverlight应用       在完成前面的开发环境搭建以后,接下来实现我们的第一个ArcGIS API forSilverlight应用程序.       接下来我们一步一步来操作: 1.  打开Visual Studio2010,创建一个Silverlight应用项目及一个宿主的Web网站,如下图: 2.创建好的应用程序结构如下,包括一个Silverlight应用和一个宿主的Web项目. 3.接着右键点击Silverlight项目中的引用