protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            base.OnOrientationChanged(e);

            if (_previousOrientation == null)
                return;

            RotateTransition transitionElement = new RotateTransition();

            // counter clockwise rotation
            if (_previousOrientation == PageOrientation.LandscapeRight && e.Orientation == PageOrientation.PortraitUp ||
                _previousOrientation == PageOrientation.PortraitUp && e.Orientation == PageOrientation.LandscapeLeft ||
                _previousOrientation == PageOrientation.LandscapeLeft && e.Orientation == PageOrientation.PortraitDown ||
                _previousOrientation == PageOrientation.PortraitDown && e.Orientation == PageOrientation.LandscapeRight)
                transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;

            // clockwise rotation
            else if (_previousOrientation == PageOrientation.LandscapeLeft && e.Orientation == PageOrientation.PortraitUp ||
                     _previousOrientation == PageOrientation.PortraitDown && e.Orientation == PageOrientation.LandscapeLeft ||
                     _previousOrientation == PageOrientation.LandscapeRight && e.Orientation == PageOrientation.PortraitDown ||
                     _previousOrientation == PageOrientation.PortraitUp && e.Orientation == PageOrientation.LandscapeRight)
                transitionElement.Mode = RotateTransitionMode.In90Clockwise;

            // 180 rotation
            else
                transitionElement.Mode = RotateTransitionMode.In180Clockwise;

            var transition = transitionElement.GetTransition((PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual).Content));
            transition.Completed += delegate { transition.Stop(); };
            transition.Begin();

            _previousOrientation = e.Orientation;
        }
Example #2
0
        private void OnOrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            PageOrientation newOrientation = e.Orientation;

            RotateTransition transitionElement = new RotateTransition();

            // Adjust padding if possible

            if (null != MainGrid)
            {
                switch (newOrientation)
                {
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    HeaderTitle.Margin = new Thickness(20, 12, 12, 12);
                    Picker.Margin      = new Thickness(8, 12, 0, 0);

                    transitionElement.Mode = (lastOrientation == PageOrientation.LandscapeLeft) ?
                                             RotateTransitionMode.In90Counterclockwise : RotateTransitionMode.In90Clockwise;

                    break;

                case PageOrientation.Landscape:
                case PageOrientation.LandscapeLeft:
                    HeaderTitle.Margin = new Thickness(72, 0, 0, 0);
                    Picker.Margin      = new Thickness(60, 0, 0, 0);

                    transitionElement.Mode = (lastOrientation == PageOrientation.LandscapeRight) ?
                                             RotateTransitionMode.In180Counterclockwise : RotateTransitionMode.In90Clockwise;
                    break;

                case PageOrientation.LandscapeRight:
                    HeaderTitle.Margin = new Thickness(20, 0, 0, 0);
                    Picker.Margin      = new Thickness(8, 0, 0, 0);

                    transitionElement.Mode = (lastOrientation == PageOrientation.PortraitUp) ?
                                             RotateTransitionMode.In90Counterclockwise : RotateTransitionMode.In180Clockwise;
                    break;
                }
            }

            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            ITransition          transition           = transitionElement.GetTransition(phoneApplicationPage);

            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            lastOrientation = newOrientation;
        }
        private void FullImage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            RotateTransition rotateTransition = new RotateTransition();
            PhoneApplicationPage element = (PhoneApplicationPage)((PhoneApplicationFrame)Application.Current.RootVisual).Content;

            switch (e.Orientation)
            {
                case PageOrientation.LandscapeLeft:
                    switch (this.previousOrientation)
                    {
                        case PageOrientation.PortraitUp:
                            rotateTransition.Mode = RotateTransitionMode.In90Clockwise;
                            break;
                        case PageOrientation.LandscapeRight:
                            rotateTransition.Mode = RotateTransitionMode.In180Clockwise;
                            break;
                    }
                    break;
                case PageOrientation.LandscapeRight:
                    switch (this.previousOrientation)
                    {
                        case PageOrientation.PortraitUp:
                            rotateTransition.Mode = RotateTransitionMode.In90Counterclockwise;
                            break;
                        case PageOrientation.LandscapeLeft:
                            rotateTransition.Mode = RotateTransitionMode.In180Counterclockwise;
                            break;
                    }
                    break;
                case PageOrientation.Portrait:
                    switch (this.previousOrientation)
                    {
                        case PageOrientation.LandscapeLeft:
                            rotateTransition.Mode = RotateTransitionMode.In90Counterclockwise;
                            break;
                        case PageOrientation.LandscapeRight:
                            rotateTransition.Mode = RotateTransitionMode.In90Clockwise;
                            break;
                    }
                    break;
            }

            ITransition transition = rotateTransition.GetTransition(element);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();
            this.previousOrientation = e.Orientation;
        }
Example #4
0
        protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            var newOrientation = e.Orientation;
              var transitionElement = new RotateTransition();

              switch (newOrientation)
              {
            case PageOrientation.Landscape:
            case PageOrientation.LandscapeRight:
              // Come here from PortraitUp (i.e. clockwise) or LandscapeLeft?
              if (_lastOrientation == PageOrientation.PortraitUp)
            transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;
              else
            transitionElement.Mode = RotateTransitionMode.In180Clockwise;
              break;
            case PageOrientation.LandscapeLeft:
              // Come here from LandscapeRight or PortraitUp?
              if (_lastOrientation == PageOrientation.LandscapeRight)
            transitionElement.Mode = RotateTransitionMode.In180Counterclockwise;
              else
            transitionElement.Mode = RotateTransitionMode.In90Clockwise;
              break;
            case PageOrientation.Portrait:
            case PageOrientation.PortraitUp:
              // Come here from LandscapeLeft or LandscapeRight?
              if (_lastOrientation == PageOrientation.LandscapeLeft)
            transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;
              else
            transitionElement.Mode = RotateTransitionMode.In90Clockwise;
              break;
            default:
              break;
              }

              // Execute the transition
              if (Application.Current.RootVisual != null)
              {
            var phoneApplicationPage =
              (((PhoneApplicationFrame)Application.Current.RootVisual)).Content
              as PhoneApplicationPage;
            var transition = transitionElement.GetTransition(phoneApplicationPage);

            transition.Completed += (sender, args) => transition.Stop();
            transition.Begin();

            _lastOrientation = newOrientation;
              }
              base.OnOrientationChanged(e);
        }
Example #5
0
        private void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            var newOrientation = e.Orientation;
            // Orientations are (clockwise) 'PortraitUp', 'LandscapeRight', 'LandscapeLeft'

            var transitionElement = new RotateTransition();
            switch (newOrientation)
            {
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeRight:
                    // Come here from PortraitUp (i.e. clockwise) or LandscapeLeft?
                    transitionElement.Mode = _lastOrientation == PageOrientation.PortraitUp
                        ? RotateTransitionMode.In90Counterclockwise
                        : RotateTransitionMode.In180Clockwise;
                    break;
                case PageOrientation.LandscapeLeft:
                    // Come here from LandscapeRight or PortraitUp?
                    transitionElement.Mode = _lastOrientation == PageOrientation.LandscapeRight
                        ? RotateTransitionMode.In180Counterclockwise
                        : RotateTransitionMode.In90Clockwise;
                    break;
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    // Come here from LandscapeLeft or LandscapeRight?
                    transitionElement.Mode = _lastOrientation == PageOrientation.LandscapeLeft
                        ? RotateTransitionMode.In90Counterclockwise
                        : RotateTransitionMode.In90Clockwise;
                    break;
            }

            // Execute the transition
            var phoneApplicationPage =
                (PhoneApplicationPage) (((PhoneApplicationFrame) Application.Current.RootVisual)).Content;
            var transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            _lastOrientation = newOrientation;
        }
        private void OnOrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            PageOrientation newOrientation = e.Orientation;

            RotateTransition transitionElement = new RotateTransition();

            // Adjust padding if possible
            
            if (null != MainGrid)
            {
                switch (newOrientation)
                {
                    case PageOrientation.Portrait:
                    case PageOrientation.PortraitUp:
                        HeaderTitle.Margin = new Thickness(20, 12, 12, 12);
                        Picker.Margin = new Thickness(8, 12, 0, 0);

                        transitionElement.Mode = (lastOrientation == PageOrientation.LandscapeLeft) ?
                        RotateTransitionMode.In90Counterclockwise : RotateTransitionMode.In90Clockwise;

                        break;
                    case PageOrientation.Landscape:
                    case PageOrientation.LandscapeLeft:
                        HeaderTitle.Margin = new Thickness(72, 0, 0, 0);
                        Picker.Margin = new Thickness(60, 0, 0, 0);

                        transitionElement.Mode = (lastOrientation == PageOrientation.LandscapeRight) ?
                        RotateTransitionMode.In180Counterclockwise : RotateTransitionMode.In90Clockwise;
                        break;
                    case PageOrientation.LandscapeRight:
                        HeaderTitle.Margin = new Thickness(20, 0, 0, 0);
                        Picker.Margin = new Thickness(8, 0, 0, 0);

                        transitionElement.Mode = (lastOrientation == PageOrientation.PortraitUp) ? 
                        RotateTransitionMode.In90Counterclockwise : RotateTransitionMode.In180Clockwise;
                        break;
                }
            }

            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            ITransition transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            lastOrientation = newOrientation;
        }
Example #7
0
        private void StartTransition()
        {
            //RollTransition rotatetransition = new RollTransition();
            RotateTransition rotatetransition = new RotateTransition();
            //rotatetransition.Mode = RotateTransitionMode.In90Clockwise;
            rotatetransition.Mode = RotateTransitionMode.In180Counterclockwise;

            PhoneApplicationPage phoneApplicationPage =
            (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;

            ITransition transition = rotatetransition.GetTransition(phoneApplicationPage);

            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();
        }
Example #8
0
        protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            PageOrientation newOrientation = e.Orientation;
            Debug.WriteLine("New orientation: " + newOrientation.ToString());

            // Orientations are (clockwise) 'PortraitUp', 'LandscapeRight', 'LandscapeLeft'

            RotateTransition transitionElement = new RotateTransition();
            if (cam != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    double rotation = cam.Orientation;
                    switch (this.Orientation)
                    {
                        case PageOrientation.PortraitDown:
                            cambiarProporcionesPortrait();
                            rotation = cam.Orientation + 90;
                           
                            break;
                        case PageOrientation.PortraitUp:
                            cambiarProporcionesPortrait();
                            rotation = cam.Orientation;
                            break;
                        case PageOrientation.LandscapeLeft:
                            cambiarProporcionesLandscapeIzquieda();
                            rotation = cam.Orientation - 90;
                            break;
                        case PageOrientation.LandscapeRight:
                            cambiarProporcionesLandscapeDerecha();
                            rotation = cam.Orientation + 90;
                            break;
                    }
                    viewfinderTransform.Rotation = rotation;
                });
            }
            // Execute the transition
            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            ITransition transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            lastOrientation = newOrientation;
            base.OnOrientationChanged(e);
        }
Example #9
0
        void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            PageOrientation newOrientation = e.Orientation;

            // Orientations are (clockwise) 'PortraitUp', 'LandscapeRight', 'LandscapeLeft'
            RotateTransition transitionElement = new RotateTransition();

            switch (newOrientation)
            {
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeRight:
                    // Come here from PortraitUp (i.e. clockwise) or LandscapeLeft?
                    if (lastOrientation == PageOrientation.PortraitUp)
                        transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;
                    else
                        transitionElement.Mode = RotateTransitionMode.In180Clockwise;
                    VisualStateManager.GoToState(this, LandscapeState.Name, true);
                    break;
                case PageOrientation.LandscapeLeft:
                    // Come here from LandscapeRight or PortraitUp?
                    if (lastOrientation == PageOrientation.LandscapeRight)
                        transitionElement.Mode = RotateTransitionMode.In180Counterclockwise;
                    else
                        transitionElement.Mode = RotateTransitionMode.In90Clockwise;
                    VisualStateManager.GoToState(this, LandscapeState.Name, true);
                    break;
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    // Come here from LandscapeLeft or LandscapeRight?
                    if (lastOrientation == PageOrientation.LandscapeLeft)
                        transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;
                    else
                        transitionElement.Mode = RotateTransitionMode.In90Clockwise;
                    VisualStateManager.GoToState(this, PortraitState.Name, true);
                    break;
                default:
                    break;
            }

            // Execute the transition
            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            ITransition transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            lastOrientation = newOrientation;
        }
Example #10
0
        /// <summary>
        /// 页面重力更改处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            PageOrientation newOrientation = e.Orientation;

            RotateTransition transitionElement = new RotateTransition();

            switch (newOrientation)
            {
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeRight:
                    if (lastOrientation == PageOrientation.PortraitUp)
                        transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;
                    else
                        transitionElement.Mode = RotateTransitionMode.In180Clockwise;
                    break;
                case PageOrientation.LandscapeLeft:
                    if (lastOrientation == PageOrientation.LandscapeRight)
                        transitionElement.Mode = RotateTransitionMode.In180Counterclockwise;
                    else
                        transitionElement.Mode = RotateTransitionMode.In90Clockwise;
                    break;
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    if (lastOrientation == PageOrientation.LandscapeLeft)
                        transitionElement.Mode = RotateTransitionMode.In90Counterclockwise;
                    else
                        transitionElement.Mode = RotateTransitionMode.In90Clockwise;
                    break;
                default:
                    break;
            }

            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            ITransition transition = transitionElement.GetTransition(phoneApplicationPage);
            transition.Completed += delegate
            {
                transition.Stop();
            };
            transition.Begin();

            lastOrientation = newOrientation;

        }