Beispiel #1
0
        internal void UpdatePosition(VEMap map)
        {
            if (provider == null)
            {
                if (this.ContentTemplate != null)
                {
                    DependencyObject depObj = VisualUtility.GetChildByType(this, typeof(ILocationProvider));
                    provider = depObj as ILocationProvider;
                }

                if (provider == null && this.Content != null)
                {
                    provider = this.Content as ILocationProvider;
                }

                if (provider == null)
                {
                    return;
                }
            }

            Canvas.SetZIndex(this, provider.GetZIndex());

            Point?position = provider.UpdatePosition(map);

            if (!position.HasValue)
            {
                Canvas.SetLeft(this, -10000);
                Canvas.SetTop(this, -10000);
                return;
            }

            Canvas.SetLeft(this, position.Value.X);
            Canvas.SetTop(this, position.Value.Y);
        }
Beispiel #2
0
 public virtual Point?UpdatePosition(VEMap map)
 {
     this._map = map;
     return(null);
 }
        public override Point?UpdatePosition(VEMap map)
        {
            if (this.Map != map)
            {
                map.AddRegisteredPosition(this, DisplayLatLong);
                isNewPin = false;
            }

            base.UpdatePosition(map);

            VEPushPinAltitudeEvent altEvent;
            bool  isVisible;
            Point?anchorPosition = GetPosition(DisplayLatLong, out altEvent, out isVisible);

            if (isVisible)
            {
                this.SetValue(VEPushPin.VisibilityProperty, Visibility.Visible);

                //If transitioning from invisible
                if (currentState != VEPushPinState.Visible &&
                    currentState != VEPushPinState.FadingIn)
                {
                    OnShow();

                    AnimationClock showClock = AnimateUtility.AnimateElementDouble(this,
                                                                                   VEPushPin.OpacityProperty,
                                                                                   1,
                                                                                   0,
                                                                                   1);

                    showClock.Completed += new EventHandler(showClock_Completed);
                    currentState         = VEPushPinState.FadingIn;

                    //If transitioning and has a parent
                    if (this.ParentPushPin != null &&
                        (altEvent == VEPushPinAltitudeEvent.TransitionIntoUpperRange))
                    {
                        this.DisplayLatitude  = this.ParentPushPin.Latitude;
                        this.DisplayLongitude = this.ParentPushPin.Longitude;
                    }

                    if (this.DisplayLatitude != this.Latitude ||
                        this.DisplayLongitude != this.Longitude)
                    {
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLatitudeProperty,
                                                            this.Latitude,
                                                            0,
                                                            1);
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLongitudeProperty,
                                                            this.Longitude,
                                                            0,
                                                            1);

                        anchorPosition = GetPosition(DisplayLatLong);
                    }
                }
            }
            else
            {
                //If transitioning from Visible
                if (currentState != VEPushPinState.Hidden &&
                    currentState != VEPushPinState.FadingOut)
                {
                    OnHide();

                    AnimationClock hideClock = AnimateUtility.AnimateElementDouble(this,
                                                                                   VEPushPin.OpacityProperty,
                                                                                   0,
                                                                                   0,
                                                                                   1);

                    hideClock.Completed += new EventHandler(hideClock_Completed);
                    currentState         = VEPushPinState.FadingOut;

                    //If transitioning and has a parent
                    if (this.ParentPushPin != null &&
                        (altEvent == VEPushPinAltitudeEvent.TransitionAboveUpperRange))
                    {
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLatitudeProperty,
                                                            this.ParentPushPin.Latitude,
                                                            0,
                                                            1);
                        AnimateUtility.AnimateElementDouble(this,
                                                            VEPushPin.DisplayLongitudeProperty,
                                                            this.ParentPushPin.Longitude,
                                                            0,
                                                            1);

                        anchorPosition = GetPosition(DisplayLatLong);
                    }
                    else
                    {
                        //Not animating, just hide immediately
                        //this.Visibility = Visibility.Collapsed;
                    }
                }
            }

            //Update the calculated position
            if (anchorPosition == null || !map.IsMapLoaded)
            {
                this.Visibility   = Visibility.Collapsed;
                this.Opacity      = 0;
                this.currentState = VEPushPinState.Hidden;

                return(null);
            }

            if (!this.IsMeasureValid)
            {
                this.Opacity      = 0;
                this.currentState = VEPushPinState.Hidden;
                return(null);
            }

            Point anchorOffset = GetAnchorOffset();

            double displayLeft = anchorPosition.Value.X - anchorOffset.X;
            double displayTop  = anchorPosition.Value.Y - anchorOffset.Y;

            return(new Point(displayLeft, displayTop));
        }