zoukankan      html  css  js  c++  java
  • ArcGis API FOR Silverlight 做了个导航工具~

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

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

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

    马上上代码

    MapNavigator Code
    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
     <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>
  • 相关阅读:
    vue项目中使用bpmn-流程图json属性转xml(七篇更新完成)
    vue项目中使用bpmn-流程图xml文件中节点属性转json结构
    vue项目中使用bpmn-自定义platter
    vue项目中使用bpmn-为节点添加颜色
    vue项目中使用bpmn-节点篇(为节点添加点击事件、根据id找节点实例、更新节点名字、获取指定类型的所有节点)
    vue项目中使用bpmn-流程图预览篇
    vue项目中使用bpmn-基础篇
    万事开头难——学习新知识是要打好基本规则基础的
    老川交易的艺术——普通的一周生活——读后感
    艾宾浩斯遗忘曲线表格——使用
  • 原文地址:https://www.cnblogs.com/thinkaspx/p/2628214.html
Copyright © 2011-2022 走看看