Exemplo n.º 1
0
        static void OnLatitudePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VEPushPin pin = d as VEPushPin;

            if (pin == null)
            {
                return;
            }

            if (e.NewValue == null)
            {
                return;
            }

            AnimateUtility.StopAnimation(pin, VEPushPin.DisplayLatitudeProperty);
            if (e.OldValue != null)
            {
                pin.DisplayLatitude = (double)e.OldValue;
            }

            if (pin.isNewPin)
            {
                pin.DisplayLatitude = (double)e.NewValue;
            }
            else
            {
                AnimateUtility.AnimateElementDouble(pin,
                                                    VEPushPin.DisplayLatitudeProperty,
                                                    (double)e.NewValue,
                                                    0, 2);
            }
        }
Exemplo n.º 2
0
        private void ZoomViewTo(Point center, double orientation, Vector scale)
        {
            CircleEase ease = new CircleEase();

            ease.EasingMode = EasingMode.EaseInOut;
            AnimateUtility.AnimateElementPoint(zoomCanvas.CurrentView, DisplayMatrix.CenterProperty, center, 0, 1.5, ease);
            AnimateUtility.AnimateElementDouble(zoomCanvas.CurrentView, DisplayMatrix.OrientationProperty, orientation, 0, 1.5, ease);
            AnimateUtility.AnimateElementVector(zoomCanvas.CurrentView, DisplayMatrix.ScaleProperty, scale, 0, 1.5, ease);
        }
Exemplo n.º 3
0
        public void FlyTo(Rect rect, double newOrientation, TimeSpan delta)
        {
            StopFlyTo();
            Rect          currentRect = DisplayMatrix.MatrixToBounds(this.ZoomMatrix, this.RenderSize);
            DisplayMatrix temp        = DisplayMatrix.BoundsToMatrix(rect, this.RenderSize);

            Point newCenter = (rect.TopLeft + new Vector(rect.Width / 2, rect.Height / 2));

            newCenter = new Point(-newCenter.X, -newCenter.Y);
            double scaleX = currentRect.Size.Width / rect.Size.Width;
            double scaleY = currentRect.Size.Height / rect.Size.Height;

            Vector newScale = this.ZoomMatrix.Scale * Math.Min(scaleX, scaleY);

            newScale = new Vector(1 / temp.Scale.X, 1 / temp.Scale.Y);
            AnimateUtility.AnimateElementPoint(this.ZoomMatrix, DisplayMatrix.CenterProperty, newCenter, 0, delta.TotalSeconds);
            AnimateUtility.AnimateElementVector(this.ZoomMatrix, DisplayMatrix.ScaleProperty, newScale, 0, delta.TotalSeconds);
            AnimateUtility.AnimateElementDouble(this.ZoomMatrix, DisplayMatrix.OrientationProperty, newOrientation, 0, delta.TotalSeconds);
        }
Exemplo n.º 4
0
        private void SetImageLock(bool isImageLocked)
        {
            if (isImageLocked == this.IsImageLocked)
            {
                return;
            }

            this.IsImageLocked = isImageLocked;
            if (isImageLocked)
            {
                imgLockIcon.Source = new BitmapImage(new Uri("pack://application:,,,/NaturalShow.UI.Common;component/Resources/Lock.png", UriKind.Absolute));
                AnimateUtility.AnimateElementDouble(pnlBar, FrameworkElement.OpacityProperty, 0.05, 0, 0.2);
                //                pnlControls.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                imgLockIcon.Source = new BitmapImage(new Uri("pack://application:,,,/NaturalShow.UI.Common;component/Resources/Unlock.png", UriKind.Absolute));
                AnimateUtility.AnimateElementDouble(pnlBar, FrameworkElement.OpacityProperty, 1.0, 0, 0.2);
                //                pnlControls.Visibility = System.Windows.Visibility.Visible;
            }
        }
Exemplo n.º 5
0
        private void GenerateMapModel(Point centerStart, Point centerTarget, double orientationStart, double orientationTarget, Vector scaleStart, Vector scaleTarget)
        {
            ShowZoneModel mapModel = new ShowZoneModel();

            mapModel.Text = "Bing Maps 3D";
            ShowMapView mapView = new ShowMapView(mapModel);

            ShowZoneModel model = mapView.Model as ShowZoneModel;

            if (model == null)
            {
                return;
            }

            centerStart  = zoomCanvas.ScreenToWorld(centerStart);
            centerTarget = zoomCanvas.ScreenToWorld(centerTarget);

            model.IsMap                     = true;
            model.IsLocked                  = this.isLocked;
            model.DisplayMatrix.Center      = centerStart;
            model.DisplayMatrix.Orientation = orientationStart;
            model.DisplayMatrix.Scale       = scaleStart;

            AnimateUtility.AnimateElementPoint(model.DisplayMatrix, DisplayMatrix.CenterProperty, centerTarget, 0, 1);
            AnimateUtility.AnimateElementDouble(model.DisplayMatrix, DisplayMatrix.OrientationProperty, orientationTarget, 0, 1);
            AnimateUtility.AnimateElementVector(model.DisplayMatrix, DisplayMatrix.ScaleProperty, scaleTarget, 0, 1);

            if (!showContext.Models.Contains(model))
            {
                showContext.Models.Add(model);
            }
            showContext.SendToFront(model);

            if (!zoomCanvas.Items.Contains(mapView))
            {
                zoomCanvas.Items.Add(mapView);
            }
        }
Exemplo n.º 6
0
        private ShowView GenerateModel(ShowModel model, Point centerStart, Point centerTarget, double orientationStart, double orientationTarget, Vector scaleStart, Vector scaleTarget)
        {
            centerStart  = zoomCanvas.ScreenToWorld(centerStart);
            centerTarget = zoomCanvas.ScreenToWorld(centerTarget);

            model.IsLocked                  = this.isLocked;
            model.DisplayMatrix.Center      = centerStart;
            model.DisplayMatrix.Orientation = orientationStart;
            model.DisplayMatrix.Scale       = scaleStart;

            AnimateUtility.AnimateElementPoint(model.DisplayMatrix, DisplayMatrix.CenterProperty, centerTarget, 0, 1);
            AnimateUtility.AnimateElementDouble(model.DisplayMatrix, DisplayMatrix.OrientationProperty, orientationTarget, 0, 1);
            AnimateUtility.AnimateElementVector(model.DisplayMatrix, DisplayMatrix.ScaleProperty, scaleTarget, 0, 1);

            showContext.Models.Add(model);
            showContext.SendToFront(model);

            ShowView view = showContext.CreateView(model);

            zoomCanvas.Items.Add(view);

            return(view);
        }
Exemplo n.º 7
0
        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));
        }
        void ToggleDetailState()
        {
            if (cpContent == null)
            {
                pendingToggle = true;
                return;
            }
            cpContent.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size sizeTitle = cpContent.DesiredSize;

            Visibility original = cpDetails.Visibility;

            cpDetails.Visibility = Visibility.Visible;

            cpDetails.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size sizeDetails = cpDetails.DesiredSize;

            cpDetails.Visibility = original;

            pnlContainer.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size currentSize = pnlContainer.DesiredSize;

            AnimateUtility.StopAnimation(pnlContainer, Panel.WidthProperty);
            AnimateUtility.StopAnimation(pnlContainer, Panel.HeightProperty);

            pnlContainer.Width  = currentSize.Width;
            pnlContainer.Height = currentSize.Height;

            Size expandedSize = new Size(sizeTitle.Width, sizeTitle.Height + sizeDetails.Height);

            if (sizeDetails.Width > sizeTitle.Width)
            {
                expandedSize.Width = sizeDetails.Width;
            }


            if (currentDetailState == ExpandingSurfaceVEPushPinDetailState.Full ||
                currentDetailState == ExpandingSurfaceVEPushPinDetailState.Growing)
            {
                // Hide pp details.
                if (Map != null)
                {
                    Map.SendToBack(this);
                }

                currentDetailState = ExpandingSurfaceVEPushPinDetailState.Shrinking;

                AnimateUtility.AnimateElementDouble(cpDetails, Panel.OpacityProperty, 0, 0, 1);
                AnimateUtility.AnimateElementDouble(pnlContainer, Panel.WidthProperty, sizeTitle.Width, 0, 1);
                AnimationClock shrinkClock = AnimateUtility.AnimateElementDouble(pnlContainer, Panel.HeightProperty, sizeTitle.Height, 0, 1);

                shrinkClock.CurrentTimeInvalidated += new EventHandler(currentTimeInvalidated);
                shrinkClock.Completed += new EventHandler(shrinkClock_Completed);
                SendOnCollapsing();
            }
            else
            {
                // Show pp details.
                if (Map != null)
                {
                    Map.SendToFront(this);
                }
                currentDetailState = ExpandingSurfaceVEPushPinDetailState.Growing;

                cpDetails.Visibility = Visibility.Visible;

                AnimateUtility.AnimateElementDouble(cpDetails, Panel.OpacityProperty, 1, 0, 1);
                AnimateUtility.AnimateElementDouble(pnlContainer, Panel.WidthProperty, expandedSize.Width, 0, 1);
                AnimationClock growClock = AnimateUtility.AnimateElementDouble(pnlContainer, Panel.HeightProperty, expandedSize.Height, 0, 1);

                growClock.CurrentTimeInvalidated += new EventHandler(currentTimeInvalidated);
                growClock.Completed += new EventHandler(growClock_Completed);
                SendOnExpanding();
            }
        }