Beispiel #1
0
        private void OffsetChildrenProjections(int offset)
        {
            if (!Children.Any())
            {
                return;
            }

            CalculateChildrenProjections();

            var n = childrenProjections.Length;

            if (offset < 0 || offset > n)
            {
                return;
            }

            var copy = new PlaneProjection[n];

            for (int i = offset; i < n; ++i)
            {
                copy[i] = childrenProjections[i - offset];
            }
            for (int i = 0; i < offset; ++i)
            {
                copy[i] = childrenProjections[n - offset + i];
            }

            childrenProjections = copy;
        }
        private void SlantSlider_LostMouseCapture(object sender, MouseEventArgs e)
        {
            Slider          slider = sender as Slider;
            RotateTransform rt     = new RotateTransform();
            PlaneProjection pp     = new PlaneProjection();

            if (mapWidth > 0 && mapHeight > 0 && slider.Value < 0)
            {
                double wmargin = mapWidth * -1;
                double hmargin = (mapHeight) * -1;
                Map.Margin = new Thickness(wmargin, hmargin, wmargin, hmargin);

                pp.CenterOfRotationX = mapWidth * 1.5;
                pp.CenterOfRotationY = mapHeight * 1.5;
                Map.Projection       = pp;
            }
            else
            {
                Map.Margin           = new Thickness(0);
                pp.CenterOfRotationX = mapWidth * 0.5;
                pp.CenterOfRotationY = mapHeight * 0.5;
                Map.Projection       = pp;
            }

            Map.PanTo(mapCenter);
        }
        /// <inheritdoc/>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            var carouselItem = (CarouselItem)element;

            carouselItem.Selected += OnCarouselItemSelected;

            carouselItem.RenderTransformOrigin = new Point(0.5, 0.5);

            carouselItem.IsTabStop             = Items.IndexOf(item) == SelectedIndex;
            carouselItem.UseSystemFocusVisuals = true;

            PlaneProjection planeProjection = new PlaneProjection();

            planeProjection.CenterOfRotationX = 0.5;
            planeProjection.CenterOfRotationY = 0.5;
            planeProjection.CenterOfRotationZ = 0.5;

            var compositeTransform = new CompositeTransform();

            compositeTransform.CenterX = 0.5;
            compositeTransform.CenterY = 0.5;
            compositeTransform.CenterY = 0.5;

            carouselItem.Projection      = planeProjection;
            carouselItem.RenderTransform = compositeTransform;

            if (item == SelectedItem)
            {
                carouselItem.IsSelected = true;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Closes the blinds to hide the content
        /// </summary>
        public void Close()
        {
            if (ElementRoot != null)
            {
                ElementTop.Visibility = Visibility.Visible;
                if (OpenType == RollerOpenType.Scroll)
                {
                    if (ElementBottom != null)
                    {
                        ElementBottom.Visibility = Visibility.Visible;
                    }

                    ElementClose.Begin();
                    ElementOpen.Stop();
                }
                else
                {
                    PlaneProjection p = (PlaneProjection)ElementTopProjection;

                    if (OpenType == RollerOpenType.RotateX)
                    {
                        p.RotationX = 270;
                    }
                    else
                    {
                        p.RotationY = 270;
                    }

                    ElementRotateClose.Begin();
                    ElementRotateOpen.Stop();
                }

                _isOpen = false;
            }
        }
        private void StartGame()
        {
#if NOESIS
            PlaneProjection projection = (PlaneProjection)_boardPanel.Projection;
            projection.ClearAnimation(PlaneProjection.RotationYProperty);
#endif

            ScaleTransform t = (ScaleTransform)_boardPanel.RenderTransform;
            t.ClearAnimation(ScaleTransform.ScaleXProperty);
            t.ClearAnimation(ScaleTransform.ScaleYProperty);

            for (int row = 0; row < 3; ++row)
            {
                for (int col = 0; col < 3; ++col)
                {
                    Cell cell = _board[row, col];

                    cell.Player = Player.None;
                    cell.Button.ClearAnimation(UIElement.OpacityProperty);
                    cell.Button.IsEnabled = true;
                    cell.Button.IsChecked = false;

                    VisualStateManager.GoToState(cell.Button, PlayerState, false);
                }
            }

            _progressAnimation.Begin(this, true);
        }
Beispiel #6
0
        void BikePointPin_Tapped(object sender, TappedRoutedEventArgs tappedRoutedEventArgs)
        {
            var up = new PlaneProjection {
                LocalOffsetY = 0
            };

            _mapInfoCanvas.Projection = up;
            _mapInfoCanvas.Opacity    = 1;
            _tapped = true;
            var pin = sender as Pushpin;

            pin.Background = new SolidColorBrush(Colors.DodgerBlue);
            var pos = MapLayer.GetPosition(pin);



            _bikeMap.SetView(new Location(pos.Latitude, pos.Longitude));

            foreach (var item in BikeDataGroups
                     .Where(item => item.Lat == pos.Latitude)
                     .Where(item => item.Lon == pos.Longitude))
            {
                _mainName.Text  = item.CommonName;
                _mainDocks.Text = item.AdditionalProperties[7].Value;
                _mainBikes.Text = item.AdditionalProperties[6].Value;
            }
        }
        /// <summary>
        /// Prepares a control to be tilted by setting up a plane projection and some event handlers
        /// </summary>
        /// <param name="element">The control that is to be tilted</param>
        /// <param name="centerDelta">Delta between the element's center and the tilt container's</param>
        /// <returns>true if successful; false otherwise</returns>
        /// <remarks>
        /// This method is pretty conservative; it will fail any attempt to tilt a control that already
        /// has a projection on it
        /// </remarks>
        static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta)
        {
            // Don't clobber any existing transforms
            if (element.Projection != null || (element.RenderTransform != null && element.RenderTransform.GetType() != typeof(MatrixTransform)))
            {
                return(false);
            }

            TranslateTransform transform = new TranslateTransform();

            transform.X             = centerDelta.X;
            transform.Y             = centerDelta.Y;
            element.RenderTransform = transform;

            PlaneProjection projection = new PlaneProjection();

            projection.GlobalOffsetX = -1 * centerDelta.X;
            projection.GlobalOffsetY = -1 * centerDelta.Y;
            element.Projection       = projection;

            element.ManipulationDelta     += TiltEffect_ManipulationDelta;
            element.ManipulationCompleted += TiltEffect_ManipulationCompleted;

            return(true);
        }
Beispiel #8
0
        private void carta_Tapped(object sender, TappedRoutedEventArgs e)
        {
            //Instanciamos los objetos necesarios

            Image           cartaClicada = (Image)sender;
            PlaneProjection proyeccion   = new PlaneProjection {
                RotationY = 90
            };

            cartaClicada.Projection = proyeccion;

            DoubleAnimation darVuelta = new DoubleAnimation();

            darVuelta.From     = 0;
            darVuelta.To       = 180;
            darVuelta.Duration = new Duration(TimeSpan.FromMilliseconds(1000));

            Storyboard storyboard = new Storyboard();

            Storyboard.SetTarget(darVuelta, cartaClicada);

            Storyboard.SetTargetProperty(darVuelta, "(UIElement.Projection).(PlaneProjection.RotationY)");

            storyboard.Children.Add(darVuelta);

            storyboard.Begin();
            //LO SIGUIENTE A IMPLEMENTAR
            //cartaClicada.Source = anverso
            //
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _page                   = (Page)GetTemplateChild(PageName);
            _contentPresenter       = (ContentPresenter)GetTemplateChild(ContentPresenterName);
            _flyoutContentPresenter = (Frame)GetTemplateChild(FlyoutContentPresenterName);
            _flyoutFadeIn           = (Storyboard)GetTemplateChild(FlyoutFadeInName);
            _flyoutFadeOut          = (Storyboard)GetTemplateChild(FlyoutFadeOutName);
            _topBarFadeOut          = (Storyboard)GetTemplateChild(TopBarFadeOutName);
            _topBarFadeIn           = (Storyboard)GetTemplateChild(TopBarFadeInName);
            _flyoutPlaneProjection  = (PlaneProjection)GetTemplateChild(FlyoutPlaneProjectionName);
            _flyoutGridContainer    = (Grid)GetTemplateChild(FlyoutGridContainerName);
            _flyoutBackgroundGrid   = (Grid)GetTemplateChild(FlyoutBackgroundGridName);
            _backdrop               = (BackDrop)GetTemplateChild(BackdropGridName);

            Responsive();
            Window.Current.SizeChanged += Current_SizeChanged;
            _contentPresenter.Width     = Window.Current.Bounds.Width;

            TemplateApplied.SetResult(true);

            _flyoutGridContainer.Visibility = Visibility.Collapsed;
            if (_flyoutBackgroundGrid != null)
            {
                _flyoutBackgroundGrid.Tapped += FlyoutGridContainerOnTapped;
            }

            _windowResizerTimer.Tick += _windowResizerTimer_Tick;

            _flyoutFadeOut.Completed += _flyoutFadeOut_Completed;
            _flyoutFadeIn.Completed  += _flyoutFadeIn_Completed;

            _topBarFadeIn.Completed += _topBarFadeIn_Completed;
        }
Beispiel #10
0
        private static void ApplyTiltEffect(FrameworkElement element, Point touchPoint, Point centerPoint)
        {
            TiltEffect.ResetTiltReturnStoryboard();
            Point point = new Point(Math.Min(Math.Max(touchPoint.X / (centerPoint.X * 2.0), 0.0), 1.0), Math.Min(Math.Max(touchPoint.Y / (centerPoint.Y * 2.0), 0.0), 1.0));

            if (double.IsNaN(point.X) || double.IsNaN(point.Y))
            {
                return;
            }
            double          num1            = Math.Abs(point.X - 0.5);
            double          num2            = Math.Abs(point.Y - 0.5);
            double          num3            = (double)-Math.Sign(point.X - 0.5);
            double          num4            = (double)Math.Sign(point.Y - 0.5);
            double          num5            = num1 + num2;
            double          num6            = num1 + num2 > 0.0 ? num1 / (num1 + num2) : 0.0;
            double          num7            = num5 * 0.3 * 180.0 / Math.PI;
            double          num8            = (1.0 - num5) * 25.0;
            PlaneProjection planeProjection = element.Projection as PlaneProjection;
            double          num9            = num7 * num6 * num3;

            planeProjection.RotationY = num9;
            double num10 = num7 * (1.0 - num6) * num4;

            planeProjection.RotationX = num10;
            double num11 = -num8;

            planeProjection.GlobalOffsetZ = num11;
        }
Beispiel #11
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            ContentPresenter = (ContentControl)GetTemplateChild("ContentPresenter");
            planeProjection  = (PlaneProjection)GetTemplateChild("Rotator");
            LayoutRoot       = (FrameworkElement)GetTemplateChild("LayoutRoot");

            Animation            = (Storyboard)GetTemplateChild("Animation");
            Animation.Completed += Animation_Completed;
            rotationKeyFrame     = (EasingDoubleKeyFrame)GetTemplateChild("rotationKeyFrame");
            offestZKeyFrame      = (EasingDoubleKeyFrame)GetTemplateChild("offestZKeyFrame");
            scaleXKeyFrame       = (EasingDoubleKeyFrame)GetTemplateChild("scaleXKeyFrame");
            scaleYKeyFrame       = (EasingDoubleKeyFrame)GetTemplateChild("scaleYKeyFrame");
            scaleTransform       = (ScaleTransform)GetTemplateChild("scaleTransform");

            planeProjection.RotationY    = yRotation;
            planeProjection.LocalOffsetZ = zOffset;
            if (ContentPresenter != null)
            {
                ContentPresenter.Tapped += ContentPresenter_Tapped;
            }

            if (Animation != null)
            {
                xAnimation = new DoubleAnimation();
                Animation.Children.Add(xAnimation);

                Storyboard.SetTarget(xAnimation, this);
                Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)");
            }
        }
        /// <summary>
        /// Returns a plane projection, creating it if necessary
        /// </summary>
        /// <param name="element">The element</param>
        /// <param name="create">Whether or not to create the projection if it doesn't already exist</param>
        /// <returns>The plane project, or null if not found / created</returns>
        public static PlaneProjection GetPlaneProjection(this UIElement element, bool create)
        {
            Projection      originalProjection = element.Projection;
            PlaneProjection projection         = null;

            // Projection is already a plane projection; return it
            if (originalProjection is PlaneProjection)
            {
                return(originalProjection as PlaneProjection);
            }

            // Projection is null; create it if necessary
            if (originalProjection == null)
            {
                if (create)
                {
                    projection         = new PlaneProjection();
                    element.Projection = projection;
                }
            }

            // Note that if the project is a Matrix projection, it will not be
            // changed and null will be returned.
            return(projection);
        }
        private void DrawLeftPage()
        {
            //Tworzę obiekt canvas
            Canvas cv = new Canvas();
            cv.Width = 100;
            cv.Height = 100;
            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(255, 0, 255, 255));
            cv.Background = sb;
            Canvas.SetLeft(cv, 150);
            Canvas.SetTop(cv, 100);

            //Projekcja
            PlaneProjection pp = new PlaneProjection();
            pp.LocalOffsetX = -50.0;
            cv.Projection = pp;

            //Dodaję canvas
            plutno.Children.Add(cv);

            //Tworzę animację
            stL = new Storyboard();
            DoubleAnimation db = new DoubleAnimation();
            db.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
            db.From = 0.0;
            db.To = -180.0;

            Storyboard.SetTarget(db, pp);
            Storyboard.SetTargetProperty(db, new PropertyPath(PlaneProjection.RotationYProperty));

            //Dodanie animacji do storyboarda
            stL.Children.Add(db);
        }
Beispiel #14
0
 private void RefreshPlaneProjection(PlaneProjection planeProjection, double rotationX, double rotationY, double rotationZ, double centerOfRotationX, double centerOfRotationY, double centerOfRotationZ)
 {
     // Change rotation and rotation center related properties of PlaneProjection.
     if (!double.IsNaN(rotationX))
     {
         planeProjection.RotationX = rotationX;
     }
     if (!double.IsNaN(rotationY))
     {
         planeProjection.RotationY = rotationY;
     }
     if (!double.IsNaN(rotationZ))
     {
         planeProjection.RotationZ = rotationZ;
     }
     if (!double.IsNaN(centerOfRotationX))
     {
         planeProjection.CenterOfRotationX = centerOfRotationX;
     }
     if (!double.IsNaN(centerOfRotationY))
     {
         planeProjection.CenterOfRotationY = centerOfRotationY;
     }
     if (!double.IsNaN(centerOfRotationZ))
     {
         planeProjection.CenterOfRotationZ = centerOfRotationZ;
     }
 }
Beispiel #15
0
        /// <summary>
        /// Creates a PlaneProjection and associates it with the given element, returning
        /// a Storyboard which will animate the PlaneProjection to 'peel' the item
        /// from the screen.
        /// </summary>
        private static Storyboard GetPeelAnimation(FrameworkElement element, double delay)
        {
            Storyboard sb;

            var projection = new PlaneProjection()
            {
                CenterOfRotationX = -0.1
            };

            element.Projection = projection;

            // compute the angle of rotation required to make this element appear
            // at a 90 degree angle at the edge of the screen.
            var width       = element.ActualWidth;
            var targetAngle = Math.Atan(1000 / (width / 2));

            targetAngle = targetAngle * 180 / Math.PI;

            // animate the projection
            sb           = new Storyboard();
            sb.BeginTime = TimeSpan.FromMilliseconds(delay);
            sb.Children.Add(CreateAnimation(0, -(180 - targetAngle), 0.3, "RotationY", projection));
            sb.Children.Add(CreateAnimation(0, 23, 0.3, "RotationZ", projection));
            sb.Children.Add(CreateAnimation(0, -23, 0.3, "GlobalOffsetZ", projection));
            return(sb);
        }
        /// <summary>
        /// Applies already stored (if any) animated values.
        /// </summary>
        /// <param name="info"></param>
        protected internal override void ApplyAnimationValues(PlayAnimationInfo info)
        {
            PlaneProjection projection = info.Target.Projection as PlaneProjection;

            if (projection == null)
            {
                return;
            }

            double direction = this.Direction == PerspectiveAnimationDirection.Clockwise ? -1 : 1;
            double rotation;

            PerspectiveAnimationAxis axes = this.Axes;
            bool autoReverse = this.GetAutoReverse();

            if ((axes & PerspectiveAnimationAxis.X) == PerspectiveAnimationAxis.X)
            {
                rotation             = autoReverse ? this.StartAngleX : this.EndAngleX;
                projection.RotationX = rotation * direction;
            }
            if ((axes & PerspectiveAnimationAxis.Y) == PerspectiveAnimationAxis.Y)
            {
                rotation             = autoReverse ? this.StartAngleY : this.EndAngleY;
                projection.RotationY = rotation * direction;
            }
            if ((axes & PerspectiveAnimationAxis.Z) == PerspectiveAnimationAxis.Z)
            {
                rotation             = autoReverse ? this.StartAngleZ : this.EndAngleZ;
                projection.RotationZ = rotation * direction;
            }
        }
        static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta)
#endif
        {
            // Prevents interference with any existing transforms
            if (element.Projection != null || (element.RenderTransform != null && element.RenderTransform.GetType() != typeof(MatrixTransform)))
            {
                return(false);
            }

            OriginalCacheMode[element] = element.CacheMode;
            element.CacheMode          = new BitmapCache();

            var transform = new TranslateTransform {
                X = centerDelta.X, Y = centerDelta.Y
            };

            element.RenderTransform = transform;

            var projection = new PlaneProjection {
                GlobalOffsetX = -1 * centerDelta.X, GlobalOffsetY = -1 * centerDelta.Y
            };

            element.Projection = projection;

#if WINDOWS_STORE
            element.PointerMoved       += TiltEffect_PointerMoved;
            element.PointerReleased    += TiltEffect_PointerReleased;
            element.PointerCaptureLost += TiltEffect_PointerCaptureLost;
            element.CapturePointer(p);
#elif WINDOWS_PHONE
            element.ManipulationDelta     += TiltEffectDelta;
            element.ManipulationCompleted += TiltEffectCompleted;
#endif
            return(true);
        }
        /// <summary>
        /// Flips the view over time.
        /// </summary>
        /// <param name="view">View.</param>
        /// <param name="transition">Transition.</param>
        /// <param name="direction">Direction.</param>
        /// <param name="duration">Duration.</param>
        /// <param name="onFinished">On finished.</param>
        public static void Flip(this UIElement view, AnimationTransition transition, AnimationDirection direction, double duration = AnimationConstants.DefaultDuration, Action onFinished = null)
        {
            double minTransform = 0;
            double maxTransform = 0;
            var    isIn         = transition == AnimationTransition.In;
            var    isHorizontal = direction == AnimationDirection.Left || direction == AnimationDirection.Right;

            if (direction == AnimationDirection.Right || direction == AnimationDirection.Up)
            {
                minTransform = isIn ? 90 : 270;
                maxTransform = isIn ? 0 : 360;
            }
            else
            {
                minTransform = isIn ? -90 : 440;
                maxTransform = isIn ? 0 : 360;
            }

            var transform = new PlaneProjection();

            view.RenderTransform = null;
            view.Projection      = transform;

            CreateStoryboard(view, duration, transition)
            .CreateDoubleAnimation(transform, isHorizontal ? "RotationY" : "RotationX", minTransform, maxTransform, transition)
            .Begin();
        }
Beispiel #19
0
        /// <summary>
        /// Applies the tilt effect to the control
        /// </summary>
        /// <param name="element">the control to tilt</param>
        /// <param name="touchPoint">The touch point, in the container's coordinates</param>
        /// <param name="centerPoint">The center point of the container</param>
        static void ApplyTiltEffect(FrameworkElement element, Point touchPoint, Point centerPoint)
        {
            // Stop any active animation
            ResetTiltReturnStoryboard();

            // Get relative point of the touch in percentage of container size
            Point normalizedPoint = new Point(
                Math.Min(Math.Max(touchPoint.X / (centerPoint.X * 2), 0), 1),
                Math.Min(Math.Max(touchPoint.Y / (centerPoint.Y * 2), 0), 1));

            // Shell values
            double xMagnitude         = Math.Abs(normalizedPoint.X - 0.5);
            double yMagnitude         = Math.Abs(normalizedPoint.Y - 0.5);
            double xDirection         = -Math.Sign(normalizedPoint.X - 0.5);
            double yDirection         = Math.Sign(normalizedPoint.Y - 0.5);
            double angleMagnitude     = xMagnitude + yMagnitude;
            double xAngleContribution = xMagnitude + yMagnitude > 0 ? xMagnitude / (xMagnitude + yMagnitude) : 0;

            double angle      = angleMagnitude * MaxAngle * 180 / Math.PI;
            double depression = (1 - angleMagnitude) * MaxDepression;

            // RotationX and RotationY are the angles of rotations about the x- or y-*axis*;
            // to achieve a rotation in the x- or y-*direction*, we need to swap the two.
            // That is, a rotation to the left about the y-axis is a rotation to the left in the x-direction,
            // and a rotation up about the x-axis is a rotation up in the y-direction.
            PlaneProjection projection = element.Projection as PlaneProjection;

            projection.RotationY     = angle * xAngleContribution * xDirection;
            projection.RotationX     = angle * (1 - xAngleContribution) * yDirection;
            projection.GlobalOffsetZ = -depression;
        }
Beispiel #20
0
        private static void EnsureTransformations(FrameworkElement element, FrameworkElement container)
        {
            if (element.RenderTransform != null && element.Projection != null)
            {
                return;
            }

            Point elementCenter = new Point(element.ActualWidth / 2, element.ActualHeight / 2);

            Point containerCenter = new Point(container.ActualWidth / 2, container.ActualHeight / 2);

            Size  emptySize = new Size(0, 0);
            Point elementCenterInContainerBounds = elementCenter;

            if (element.RenderSize != emptySize && container.RenderSize != emptySize)
            {
                elementCenterInContainerBounds = element.TransformToVisual(container).TransformPoint(elementCenter);
            }

            double             xDelta    = containerCenter.X - elementCenterInContainerBounds.X;
            double             yDelta    = containerCenter.Y - elementCenterInContainerBounds.Y;
            TranslateTransform translate = new TranslateTransform();

            translate.X             = xDelta;
            translate.Y             = yDelta;
            element.RenderTransform = translate;

            PlaneProjection projection = new PlaneProjection();

            projection.GlobalOffsetX = -xDelta;
            projection.GlobalOffsetY = -yDelta;
            element.Projection       = projection;
        }
Beispiel #21
0
        static DoubleAnimation MakeRotationAnimation(PlaneProjection planeProjection, FlipAxis axis, FlipDirection direction, Duration duration)
        {
            DoubleAnimation da = new DoubleAnimation();

            da.Duration = duration;

            switch (axis)
            {
            case FlipAxis.Vertical:
                da.By = direction == FlipDirection.Backwards ? -90 : 90;
                break;

            case FlipAxis.Horizontal:
                da.By = direction == FlipDirection.Backwards ? 90 : -90;
                break;

            default:
                break;
            }

            Storyboard.SetTarget(da, planeProjection);

            Storyboard.SetTargetProperty(da, new PropertyPath(
                                             axis == FlipAxis.Vertical ? "RotationX" : "RotationY"));

            return(da);
        }
Beispiel #22
0
        /// <summary>
        /// Opens the blinds to reveal the content
        /// </summary>
        public void Open()
        {
            if (ElementRoot != null)
            {
                ((FrameworkElement)Content).Visibility = Visibility.Visible;

                if (OpenType == RollerOpenType.Scroll)
                {
                    ElementOpen.Begin();
                    ElementClose.Stop();
                }
                else
                {
                    PlaneProjection p = (PlaneProjection)ElementContentProjection;

                    if (OpenType == RollerOpenType.RotateX)
                    {
                        p.RotationX = 270;
                    }
                    else
                    {
                        p.RotationY = 270;
                    }

                    ElementRotateOpen.Begin();
                    ElementRotateClose.Stop();
                }

                _isOpen = true;
            }
        }
Beispiel #23
0
        /// <summary>
        /// Prepares a control to be tilted by setting up a plane projection and
        /// some event handlers.
        /// </summary>
        /// <param name="element">The control that is to be tilted.</param>
        /// <param name="centerDelta">Delta between the element's center and the
        /// tilt container's.</param>
        /// <returns>true if successful; false otherwise.</returns>
        /// <remarks>
        /// This method is conservative; it will fail any attempt to tilt a
        /// control that already has a projection on it.
        /// </remarks>
        static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta)
        {
            // Prevents interference with any existing transforms
            if (element.Projection != null || (element.RenderTransform != null && element.RenderTransform.GetType() != typeof(MatrixTransform)))
            {
                return(false);
            }

            _originalCacheMode[element] = element.CacheMode;
            element.CacheMode           = new BitmapCache();

            TranslateTransform transform = new TranslateTransform();

            transform.X             = centerDelta.X;
            transform.Y             = centerDelta.Y;
            element.RenderTransform = transform;

            PlaneProjection projection = new PlaneProjection();

            projection.GlobalOffsetX = -1 * centerDelta.X;
            projection.GlobalOffsetY = -1 * centerDelta.Y;
            element.Projection       = projection;

            element.ManipulationDelta     += TiltEffect_ManipulationDelta;
            element.ManipulationCompleted += TiltEffect_ManipulationCompleted;

            return(true);
        }
Beispiel #24
0
                public void Exit(System.Action onCompleted)
                {
                    storyboard.Stop();
                    storyboard.Children.Clear();

                    //exit animation
                    var projection = new PlaneProjection {
                        CenterOfRotationY = 0.1
                    };

                    viewContainer.Projection = projection;
                    AddDoubleAnimation(projection, "RotationX", from: 0, to: 90, ms: 250);
                    AddDoubleAnimation(maskingLayer, "Opacity", from: 1, to: 0, ms: 350);

                    EventHandler handler = null;

                    handler = new EventHandler((o, e) =>
                    {
                        storyboard.Completed -= handler;
                        onCompleted();
                        currentPlacement = null;
                    });
                    storyboard.Completed += handler;
                    storyboard.Begin();
                }
        /// <summary>
        /// Go through all the items that were not visible on the page and set their properties accordingly without animation.
        /// </summary>
        private void UpdateOutOfViewItems()
        {
            IList <WeakReference> itemsInView = ItemsControlExtensions.GetItemsInViewPort(Picker);

            for (int k = 0; k < Picker.Items.Count; k++)
            {
                FrameworkElement item = (FrameworkElement)Picker.ItemContainerGenerator.ContainerFromIndex(k);

                if (item != null)
                {
                    bool found = false;
                    foreach (WeakReference refr in itemsInView)
                    {
                        if (refr.Target == item)
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        item.Opacity = (IsOpen) ? 1 : 0;
                        PlaneProjection p = item.Projection as PlaneProjection;
                        if (null != p)
                        {
                            p.RotationX = 0;
                        }
                    }
                }
            }
        }
        public MainPage()
        {
            this.InitializeComponent();

            // create the colour list - only needs to be done once
            _colorList = CreateColourList();
            // assign the background image brushes
            SetImageBrushes();

            // and set some properties on the rootGrid
            PlaneProjection pp = new PlaneProjection();

            pp.RotationX                  = -10;
            this.rootGrid.Projection      = pp;
            this.rootGrid.Background      = MAIN_BG;
            this.rootGrid.BorderBrush     = BORDER_BG;
            this.rootGrid.BorderThickness = new Thickness(20);

            // setup the button backgrounds
            btnNewGame.Background  = SECONDARY_BG;
            btnNewGame.BorderBrush = BORDER_BG;
            btnExit.Background     = SECONDARY_BG;
            btnExit.BorderBrush    = BORDER_BG;

            // create a new game
            CreateNewGame();
        }
Beispiel #27
0
        /// <summary>
        /// 由(屏幕)左至右显示Element
        /// </summary>
        /// <param name="Element">目标对象,你的Element</param>
        /// <param name="seconds">动画处理时间</param>
        /// <returns>已经根据Element封装好的动画,返回的Storyboard直接使用Begin函数即可</returns>
        public static Storyboard PrepareSlideInFromLeftStoryBoard(FrameworkElement Element, double seconds)
        {
            PlaneProjection _planePrj = new PlaneProjection();

            Element.Projection = _planePrj;
            Storyboard         _storyboard = new Storyboard();
            TransformGroup     transGroup  = new TransformGroup();
            TranslateTransform translate   = new TranslateTransform();

            transGroup.Children.Add(translate);
            Element.RenderTransform       = transGroup;
            Element.RenderTransformOrigin = new Point(0.5, 0.5);

            DoubleAnimation doubleX = new DoubleAnimation();

            doubleX.From         = -Element.ActualWidth;
            doubleX.To           = 0;
            doubleX.FillBehavior = FillBehavior.HoldEnd;
            doubleX.Duration     = new Duration(TimeSpan.FromSeconds(seconds));
            _storyboard.Children.Add(doubleX);

            AddDoubleAnimation(Element, seconds, _storyboard);

            Storyboard.SetTarget(doubleX, Element);
            Storyboard.SetTargetProperty(doubleX,
                                         new PropertyPath("(UIElement.RenderTransform).(transGroup.Children)[0].(TranslateTransform.X)"));
            _storyboard.Completed += (s, e) => { _storyboard.Stop(); };
            return(_storyboard);
        }
Beispiel #28
0
        /// <summary>
        /// 综合动画
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        Timeline BuildAnimation(PointerDirection direction)
        {
            DoubleAnimationUsingKeyFrames timeline = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(timeline, this);
            if (direction != PointerDirection.Center)
            {
                PlaneProjection projection2 = new PlaneProjection();
                projection2.CenterOfRotationZ = 0.0;
                PlaneProjection      projection = projection2;
                EasingDoubleKeyFrame frame3     = new EasingDoubleKeyFrame();
                frame3.KeyTime = (KeyTime)TimeSpan.FromSeconds(0.0);
                frame3.Value   = 0.0;
                EasingDoubleKeyFrame frame  = frame3;
                EasingDoubleKeyFrame frame4 = new EasingDoubleKeyFrame();
                frame4.KeyTime = _tilePressDuration;
                EasingDoubleKeyFrame frame2 = frame4;
                timeline.KeyFrames.Add(frame);
                timeline.KeyFrames.Add(frame2);
                if ((direction == PointerDirection.Left) || (direction == PointerDirection.Bottom))
                {
                    frame2.Value = _rotationDepth;
                }
                else if ((direction == PointerDirection.Top) || (direction == PointerDirection.Right))
                {
                    frame2.Value = -_rotationDepth;
                }
                if ((direction == PointerDirection.Top) || (direction == PointerDirection.Bottom))
                {
                    Storyboard.SetTargetProperty(timeline, "(UIElement.Projection).(PlaneProjection.RotationX)");
                }
                else if ((direction == PointerDirection.Left) || (direction == PointerDirection.Right))
                {
                    Storyboard.SetTargetProperty(timeline, "(UIElement.Projection).(PlaneProjection.RotationY)");
                }
                if (direction == PointerDirection.Bottom)
                {
                    projection.CenterOfRotationX = 0.5;
                    projection.CenterOfRotationY = 0.0;
                }
                else if (direction == PointerDirection.Top)
                {
                    projection.CenterOfRotationX = 0.5;
                    projection.CenterOfRotationY = 1.0;
                }
                else if (direction == PointerDirection.Left)
                {
                    projection.CenterOfRotationX = 1.0;
                    projection.CenterOfRotationY = 0.5;
                }
                else if (direction == PointerDirection.Right)
                {
                    projection.CenterOfRotationX = 0.0;
                    projection.CenterOfRotationY = 0.5;
                }
                Projection = projection;
            }
            return(timeline);
        }
Beispiel #29
0
        private static void OnTiltChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            FrameworkElement   targetElement  = d as FrameworkElement;
            double             tiltFactor     = MetroInMotion.GetTilt(d);
            PlaneProjection    projection     = new PlaneProjection();
            ScaleTransform     scale          = new ScaleTransform();
            TranslateTransform translate      = new TranslateTransform();
            TransformGroup     transformGroup = new TransformGroup();

            transformGroup.Children.Add((Transform)scale);
            transformGroup.Children.Add((Transform)translate);
            targetElement.Projection            = (Projection)projection;
            targetElement.RenderTransform       = (Transform)transformGroup;
            targetElement.RenderTransformOrigin = new Point(0.5, 0.5);
            MouseButtonEventHandler buttonEventHandler = (MouseButtonEventHandler)((s, e) =>
            {
                Point position = e.GetPosition((UIElement)targetElement);
                double num1 = Math.Max(targetElement.ActualWidth, targetElement.ActualHeight);
                if (num1 == 0.0)
                {
                    return;
                }
                double num2 = 2.0 * (targetElement.ActualWidth / 2.0 - position.X) / num1;
                projection.RotationY = num2 * MetroInMotion.TiltAngleFactor * tiltFactor;
                double num3 = 2.0 * (targetElement.ActualHeight / 2.0 - position.Y) / num1;
                projection.RotationX = -num3 * MetroInMotion.TiltAngleFactor * tiltFactor;
                double num4 = tiltFactor * (1.0 - Math.Sqrt(num2 * num2 + num3 * num3)) / MetroInMotion.ScaleFactor;
                scale.ScaleX = 1.0 - num4;
                scale.ScaleY = 1.0 - num4;
                FrameworkElement frameworkElement = Application.Current.RootVisual as FrameworkElement;
                double num5 = (targetElement.GetRelativePosition((UIElement)frameworkElement).Y - frameworkElement.ActualHeight / 2.0) / 2.0;
                translate.Y = -num5;
                projection.LocalOffsetY = num5;
            });
            EventHandler <ManipulationCompletedEventArgs> eventHandler = (EventHandler <ManipulationCompletedEventArgs>)((s, e) =>
            {
                new Storyboard()
                {
                    Children =
                    {
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(0.0), 0.1, "RotationY", (DependencyObject)projection),
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(0.0), 0.1, "RotationX", (DependencyObject)projection),
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(1.0), 0.1, "ScaleX",    (DependencyObject)scale),
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(1.0), 0.1, "ScaleY",    (DependencyObject)scale)
                    }
                }.Begin();
                translate.Y             = 0.0;
                projection.LocalOffsetY = 0.0;
            });

            targetElement.MouseLeftButtonDown   -= buttonEventHandler;
            targetElement.ManipulationCompleted -= eventHandler;
            if (tiltFactor <= 0.0)
            {
                return;
            }
            targetElement.MouseLeftButtonDown   += buttonEventHandler;
            targetElement.ManipulationCompleted += eventHandler;
        }
Beispiel #30
0
        /// <summary>
        /// Resets the tilt effect on the control, making it appear 'normal'
        /// again.
        /// </summary>
        /// <param name="element">The element to reset the tilt on.</param>
        /// <remarks>
        /// This method doesn't turn off the tilt effect or cancel any current
        /// manipulation; it just temporarily cancels the effect.
        /// </remarks>
        private static void ResetTiltEffect(FrameworkElement element)
        {
            PlaneProjection projection = element.Projection as PlaneProjection;

            projection.RotationY     = 0;
            projection.RotationX     = 0;
            projection.GlobalOffsetZ = 0;
        }
Beispiel #31
0
        private void RunHideStoryboard(FrameworkElement element, DialogService.AnimationTypes animation, Action completionCallback)
        {
            if (element == null)
            {
                return;
            }
            Storyboard storyboard = (Storyboard)null;

            switch (animation)
            {
            case DialogService.AnimationTypes.Slide:
                storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.Y)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.25\" Value=\"-150\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"1\" To=\"0\" Duration=\"0:0:0.25\">\r\n                <DoubleAnimation.EasingFunction>\r\n                    <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                </DoubleAnimation.EasingFunction>\r\n            </DoubleAnimation>\r\n        </Storyboard>") as Storyboard;
                break;

            case DialogService.AnimationTypes.SlideInversed:
                storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.Y)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.35\" Value=\"800\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n        </Storyboard>") as Storyboard;
                break;

            case DialogService.AnimationTypes.SlideHorizontal:
                storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.X)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.25\" Value=\"150\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"1\" To=\"0\" Duration=\"0:0:0.25\">\r\n                <DoubleAnimation.EasingFunction>\r\n                    <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                </DoubleAnimation.EasingFunction>\r\n            </DoubleAnimation>\r\n        </Storyboard>") as Storyboard;
                break;

            case DialogService.AnimationTypes.Swivel:
            case DialogService.AnimationTypes.SwivelHorizontal:
                storyboard = XamlReader.Load("<Storyboard xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.Projection).(PlaneProjection.RotationX)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.25\" Value=\"45\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.Opacity)\">\r\n                <DiscreteDoubleKeyFrame KeyTime=\"0\" Value=\"1\" />\r\n                <DiscreteDoubleKeyFrame KeyTime=\"0:0:0.267\" Value=\"0\" />\r\n            </DoubleAnimationUsingKeyFrames>\r\n        </Storyboard>") as Storyboard;
                FrameworkElement frameworkElement = element;
                PlaneProjection  planeProjection  = new PlaneProjection();
                planeProjection.RotationX = 0.0;
                double num = element.ActualHeight / 2.0;
                planeProjection.CenterOfRotationX = num;
                frameworkElement.Projection       = (Projection)planeProjection;
                break;

            case DialogService.AnimationTypes.Fade:
                storyboard = XamlReader.Load("<Storyboard xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimation \r\n\t\t\t\tDuration=\"0:0:0.267\"\r\n\t\t\t\tStoryboard.TargetProperty=\"(UIElement.Opacity)\" \r\n                To=\"0\"/>\r\n        </Storyboard>") as Storyboard;
                break;
            }
            try
            {
                if (storyboard != null)
                {
                    storyboard.Completed += (EventHandler)((s, e) => completionCallback());
                    foreach (Timeline child in (PresentationFrameworkCollection <Timeline>)storyboard.Children)
                    {
                        Storyboard.SetTarget(child, (DependencyObject)element);
                    }
                    storyboard.Begin();
                }
                else
                {
                    completionCallback();
                }
            }
            catch
            {
                completionCallback();
            }
        }
Beispiel #32
0
        public LightBoxView()
            : base()
        {
            this.projection = new PlaneProjection();

            this.timer = new DispatcherTimer();
            this.timer.Tick += new EventHandler(OnTick);
            this.image.Projection = new PlaneProjection();
        }
Beispiel #33
0
 public Star(ImageSource source, double size)
 {
     Image image = new Image();
     image.Source = source;
     image.Projection = new PlaneProjection();
     this.projection = (PlaneProjection)image.Projection;
     image.Opacity = GlobalValue.OPACITY;
     image.Width = size;
     image.Height = size;
     this.Children.Add(image);
 }
 private void SetProjection(double xAngle, double yAngle)
 {
     PlaneProjection projection = Projection as PlaneProjection;
     if (projection == null)
     {
         projection = new PlaneProjection();
         Projection = projection;
     }
     projection.RotationX = xAngle;
     projection.RotationY = yAngle;
 }
    /// <summary>
    /// CTOR
    /// </summary>
    public MemoSummaryControl()
    {
      _planeprojection = new PlaneProjection
      {
        CenterOfRotationX = 0.5,
        CenterOfRotationY = 0.5
      };
      this.Projection = _planeprojection;

      this.ManipulationStarted += new EventHandler<ManipulationStartedEventArgs>(OnManipStarted);
      this.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(OnManipDelta);
      this.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(OnManipulationCompleted);
    }
Beispiel #36
0
        /// <internalonly />
        protected internal override ProceduralAnimation CreateEffectAnimation(AnimationEffectDirection direction)
        {
            FrameworkElement target = GetTarget();

            if (_projection == null) {
                _projection = target.Projection as PlaneProjection;
                if (_projection == null) {
                    _projection = new PlaneProjection();
                    _projection.CenterOfRotationX = 0.5;
                    _projection.CenterOfRotationY = 0.5;
                    _projection.CenterOfRotationZ = 0.5;

                    target.Projection = _projection;
                }
            }

            DoubleAnimation zOffsetAnimation =
                new DoubleAnimation(_projection, PlaneProjection.GlobalOffsetZProperty, Duration,
                                    (direction == AnimationEffectDirection.Forward ? Distance : 0));
            zOffsetAnimation.Interpolation = GetEffectiveInterpolation();

            if (_shadowLength == 0) {
                zOffsetAnimation.AutoReverse = AutoReverse;

                return zOffsetAnimation;
            }

            if (_dropShadow == null) {
                _dropShadow = target.Effect as DropShadowEffect;
                if (_dropShadow == null) {
                    _dropShadow = new DropShadowEffect();
                    _dropShadow.BlurRadius = 0;
                    _dropShadow.ShadowDepth = 0;
                    _dropShadow.Color = Colors.Black;
                    _dropShadow.Opacity = 0.5;

                    target.Effect = _dropShadow;
                }
            }

            DoubleAnimation shadowAnimation =
                new DoubleAnimation(_dropShadow, DropShadowEffect.BlurRadiusProperty, Duration,
                                    (direction == AnimationEffectDirection.Forward ? _shadowLength : 0));
            shadowAnimation.Interpolation = GetEffectiveInterpolation();

            ProceduralAnimationSet animationSet = new ProceduralAnimationSet(zOffsetAnimation, shadowAnimation);
            animationSet.AutoReverse = AutoReverse;

            return animationSet;
        }
Beispiel #37
0
        // Load WelcomePromo user control
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.timer == null)
            {
                this.timer = new DispatcherTimer();
                this.timer.Interval = TimeSpan.FromMilliseconds(50);
                this.timer.Tick += new EventHandler(timer_Tick);
                this.timer.Start();
            }

            Reset(); // reset all rectangles

            this.curRectangle = GetCurrentRectangle();
            this.projection = (PlaneProjection)this.curRectangle.Projection;
        }
Beispiel #38
0
 public override void UpdateStateValue(BoxData newState)
 {
     state = newState;
     if (state._state == LightBox.ConcealState)
     {
         this.image.Source = GetLightBoxImage(state);
         this.image.Stretch = Stretch.UniformToFill;
     }
     else
     {
         this.projection = (PlaneProjection)this.image.Projection;
         this.projection.RotationX = 0;
         this.timer.Interval = TimeSpan.FromMilliseconds(50);
         this.timer.Start();
     }
 }
        /// <summary>
        /// Creates an Image pushpin
        /// </summary>
        /// <param name="imageUri">Uri of the image to use for the pushpin icon</param>
        /// <param name="width">Width of the pushpin</param>
        /// <param name="height">Height of the pushpin</param>
        /// <param name="offset">Offset distance for the pushpin so that the point of the 
        /// pin is aligned with the associated coordinate.</param>
        /// <returns></returns>
        public static UIElement CreateImagePushpin(Uri imageUri, double width, double height, int rotateTr, Point offset, PlaneProjection planeProjection)
        {
            //Source.RenderTransform.r
            //TransformGroup
            RotateTransform RotateTr = new RotateTransform();
            RotateTr.Angle = rotateTr;

            return new Image()
            {
                Source = new BitmapImage(imageUri),
                //RenderTransform = RotateTr,
                Width = width,
                Height = height,
                //Stretch = System.Windows.Media.Stretch.Uniform,
                //VerticalAlignment = VerticalAlignment.Center,
                //HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(offset.X, offset.Y, 0, 0),
                Projection = planeProjection,

            };
        }
Beispiel #40
0
        protected override Storyboard CreateStoryboard(FrameworkElement target)
        {
            Storyboard result = new Storyboard();
            if (target != null)
            {
                DoubleAnimation animation = new DoubleAnimation();
                animation.From = From;
                animation.To = To;
                if (Speed != -1)
                    animation.SpeedRatio = Speed;
                if (Duration != -1)
                {
                    animation.SpeedRatio = 1;
                    animation.Duration = TimeSpan.FromMilliseconds(Duration);
                }
                EasingFunction.EasingMode = Mode;
                PlaneProjection projection = new PlaneProjection();
                target.Projection = projection;
                animation.EasingFunction = EasingFunction;
                Storyboard.SetTarget(animation, projection);
                if(RotationCenter!=null){
                    projection.CenterOfRotationX=RotationCenter.X;
                    projection.CenterOfRotationY=RotationCenter.Y;
                }

                if (RotationAxe == null)
                {
                    RotationAxe = PlaneProjection.RotationYProperty;
                }
                Storyboard.SetTargetProperty(animation, new PropertyPath(RotationAxe));

                result.Children.Add(animation);
            }
            else
            {
                Debugger.Log(1, "animation", "target is null for RotateEffect");
            }
            return result;
        }
Beispiel #41
0
        public NookBoxView()
            : base()
        {
            this.projection = new PlaneProjection();

            this.image.Source =
                BlackboxImageUtils.Image(BlackboxImageType.NookBoxBackground);
            this.imageForeground.Source =
                BlackboxImageUtils.Image(BlackboxImageType.NookBoxForeground);
            this.imageForeground.Projection = new PlaneProjection();
            this.projection = (PlaneProjection)this.imageForeground.Projection;

            this.rotatedTimer = new DispatcherTimer();
            this.rotatedTimer.Interval = TimeSpan.FromMilliseconds(RotatedTimeSpane);
            this.rotatedTimer.Tick += new EventHandler(OnRotatedTimerTick);
            this.rotatedTimer.Start();
            this.speed = NormalSpeed;

            this.acceleratedTimer = new DispatcherTimer();
            this.acceleratedTimer.Interval = TimeSpan.FromMilliseconds(AcceleratedTimeSpan);
            this.acceleratedTimer.Tick += new EventHandler(OnAcceleratedTimerTick);
        }
Beispiel #42
0
        /// <summary>
        /// 由小到大显示Element
        /// </summary>
        /// <param name="Element">需要应用Storyboard的对象</param>
        /// <param name="seconds">动画处理时间</param>
        /// <returns>已经根据Element封装好的动画,返回的Storyboard直接使用Begin函数即可</returns>
        public static Storyboard PrepareGrowStoryBoard(FrameworkElement Element, double seconds)
        {
            PlaneProjection _planePrj = new PlaneProjection();
            Element.Projection = _planePrj;
            Storyboard _storyboard = new Storyboard();
            TransformGroup transGroup = new TransformGroup();
            ScaleTransform scaletrans = new ScaleTransform();
            transGroup.Children.Add(scaletrans);
            scaletrans.CenterX = 0.5;
            scaletrans.CenterY = 0.5;
            Element.RenderTransform = transGroup;
            Element.RenderTransformOrigin = new Point(0.5, 0.5);

            DoubleAnimation doubleX = new DoubleAnimation();
            doubleX.From = 0;
            doubleX.To = 1;
            doubleX.FillBehavior = FillBehavior.HoldEnd;
            _storyboard.Children.Add(doubleX);

            DoubleAnimation doubleY = new DoubleAnimation();
            doubleY.From = 0;
            doubleY.To = 1;
            doubleY.FillBehavior = FillBehavior.HoldEnd;
            _storyboard.Children.Add(doubleY);
            //调用封装透明度和旋转X轴方法
            AddDoubleAnimation(Element, seconds, _storyboard);

            Storyboard.SetTarget(doubleX, Element);
            Storyboard.SetTargetProperty(doubleX,
               new PropertyPath("(UIElement.RenderTransform).(transGroup.Children)[0].(ScaleTransform.ScaleX)"));
            Storyboard.SetTarget(doubleY, Element);
            Storyboard.SetTargetProperty(doubleY,
               new PropertyPath("(UIElement.RenderTransform).(transGroup.Children)[0].(ScaleTransform.ScaleY)"));
            _storyboard.Completed += (s, e) => { _storyboard.Stop(); };
            return _storyboard;
        }
        /// <summary>
        /// Prepares a framework element to be feathered by adding a plane projection
        /// and a composite transform to it.
        /// </summary>
        /// <param name="root">The root visual.</param>
        /// <param name="element">The framework element.</param>
        private static bool TryAttachProjectionAndTransform(PhoneApplicationFrame root, FrameworkElement element)
        {
            GeneralTransform generalTransform;

            try
            {
                generalTransform = element.TransformToVisual(root);
            }
            catch (ArgumentException)
            {
                return false;
            }

            Point coordinates = generalTransform.Transform(Origin);
            double y = coordinates.Y + element.ActualHeight / 2.0;
            double offset = (root.ActualHeight / 2.0) - y;

            // Cache original projection and transform.
            TurnstileFeatherEffect.SetOriginalProjection(element, element.Projection);
            TurnstileFeatherEffect.SetOriginalRenderTransform(element, element.RenderTransform);

            // Attach projection.
            PlaneProjection projection = new PlaneProjection();
            projection.GlobalOffsetY = offset * -1.0;
            projection.CenterOfRotationX = FeatheringCenterOfRotationX;
            element.Projection = projection;

            // Attach transform.
            Transform originalTransform = element.RenderTransform;
            TranslateTransform translateTransform = new TranslateTransform();
            translateTransform.Y = offset;
            TransformGroup transformGroup = new TransformGroup();
            transformGroup.Children.Add(originalTransform);
            transformGroup.Children.Add(translateTransform);
            element.RenderTransform = transformGroup;

            return true;
        }
Beispiel #44
0
        private void DisplayHandCards()
        {
            var element = new HandCardsElement(Player.HandCards,
            showFaces: true,
            rotationAngle: 0,
            displayCardCount: false)
                      {
                        CardWidth = myHandCardsElement.CardWidth,
                        CardHeight = myHandCardsElement.CardHeight,
                      };

              UIElement rootVisual = Application.Current.RootVisual;
              var startRect = myHandCardsElement.GetRect(rootVisual);
              var endRect = new Rect(0, 0, rootVisual.RenderSize.Width, rootVisual.RenderSize.Height);
              const double endXStep = 1.1;
              double endCardWidth = rootVisual.RenderSize.Width / (Player.HandCards.Count * endXStep + 2 * (endXStep - 1));
              double endCardHeight = myHandCardsElement.CardHeight * endCardWidth / myHandCardsElement.CardWidth;
              var projection = new PlaneProjection();
              element.Projection = projection;
              myHandCardsElement.Visibility = Visibility.Collapsed;
              myHandCardsElement.NavigationAction = null;
              Cursor = Cursors.Arrow;
              Action onClosed = delegate
                          {
                            myHandCardsElement.Visibility = Visibility.Visible;
                            Timer timer = null;
                            timer = new Timer(delegate
                                                {
                                                  myHandCardsElement.NavigationAction = DisplayHandCards;
                                                  timer.Dispose();
                                                },
                                                null, 500, int.MaxValue);
                          };
              UIManager.Instance.ShowInPopup(element, startRect, endRect, onClosed,
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.XStepProperty), myHandCardsElement.XStep, endXStep),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.MaxAngleProperty), myHandCardsElement.MaxAngle, 0),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.AngleStepProperty), myHandCardsElement.AngleStep, 0),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.CardWidthProperty), myHandCardsElement.CardWidth, endCardWidth),
                                     new AnimationInfo(element, new PropertyPath(HandCardsElement.CardHeightProperty), myHandCardsElement.CardHeight, endCardHeight),
                                     new AnimationInfo(projection, new PropertyPath(PlaneProjection.RotationXProperty), -45, 0));
        }
Beispiel #45
0
        /// <summary>
        /// Prepares a control to be tilted by setting up a plane projection and some event handlers
        /// </summary>
        /// <param name="element">The control that is to be tilted</param>
        /// <param name="centerDelta">Delta between the element's center and the tilt container's</param>
        /// <returns>true if successful; false otherwise</returns>
        /// <remarks>
        /// This method is pretty conservative; it will fail any attempt to tilt a control that already
        /// has a projection on it
        /// </remarks>
        static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta)
        {
            // Don't clobber any existing transforms
            if (element.Projection != null || (element.RenderTransform != null && element.RenderTransform.GetType() != typeof(MatrixTransform)))
                return false;

            TranslateTransform transform = new TranslateTransform();
            transform.X = centerDelta.X;
            transform.Y = centerDelta.Y;
            element.RenderTransform = transform;

            PlaneProjection projection = new PlaneProjection();
            projection.GlobalOffsetX = -1 * centerDelta.X;
            projection.GlobalOffsetY = -1 * centerDelta.Y;
            element.Projection = projection;

            element.ManipulationDelta += TiltEffect_ManipulationDelta;
            element.ManipulationCompleted += TiltEffect_ManipulationCompleted;

            return true;
        }
Beispiel #46
0
		private static Storyboard GetPeelBackAnimation(FrameworkElement element, double delay)
		{
			Storyboard sb;

			var projection = new PlaneProjection()
			{
				CenterOfRotationX = -0.1
			};
			element.Projection = projection;

			// compute the angle of rotation required to make this element appear
			// at a 90 degree angle at the edge of the screen.
			var width = element.ActualWidth;
			var targetAngle = Math.Atan(1000 / (width / 2));
			targetAngle = targetAngle * 180 / Math.PI;

			// animate the projection
			sb = new Storyboard();
			sb.BeginTime = TimeSpan.FromMilliseconds(delay);
			sb.Children.Add(CreateBackAnimation(0, -(180 - targetAngle), 0.3, "RotationY", projection));
			sb.Children.Add(CreateBackAnimation(0, 23, 0.3, "RotationZ", projection));
			sb.Children.Add(CreateBackAnimation(0, -23, 0.3, "GlobalOffsetZ", projection));
			return sb;
		}
Beispiel #47
0
		public void ElementName_MentorBased_AttachMentorAfterBinding()
		{
			var source = TestPanel;
			var target = new PlaneProjection();
			var binding = new Binding("Width") { ElementName = "source" };

			source.Name = "source";
			source.Width = 100;

			BindingOperations.SetBinding(target, PlaneProjection.RotationZProperty, binding);
			source.Projection = target;
			EnqueueCallback(() => Assert.AreEqual(source.Width, target.RotationZ, "#1"));
			EnqueueTestComplete();
		}
Beispiel #48
0
                public void Exit(System.Action onCompleted) {
                    storyboard.Stop();
                    storyboard.Children.Clear();

                    //exit animation
                    var projection = new PlaneProjection { CenterOfRotationY = 0.1 };
                    viewContainer.Projection = projection;
                    AddDoubleAnimation(projection, "RotationX", from:0, to:90, ms:250);
                    AddDoubleAnimation(maskingLayer, "Opacity", from:1, to:0, ms:350);

                    EventHandler handler = null;
                    handler = (o, e) => {
                        storyboard.Completed -= handler;
                        onCompleted();
                        currentPlacement = null;
                    };
                    storyboard.Completed += handler;
                    storyboard.Begin();
                }
Beispiel #49
0
		protected override void PrepareTarget(FrameworkElement animationElement)
		{
			PlaneProjection planeProjection = animationElement.Projection as PlaneProjection;
			if (planeProjection == null)
			{
				planeProjection = new PlaneProjection();
				planeProjection.RotationY = 90;
				animationElement.Projection = planeProjection;
			}
		}
        public override void Begin(Action completionAction)
        {
            Storyboard = new Storyboard();

            double liCounter = 0;
            var listBoxItems = ListBox.GetVisualDescendants().OfType<ListBoxItem>().Where(lbi => IsOnCurrentPage(lbi) && lbi.IsEnabled).ToList();
            
            if (HoldSelectedItem && Direction == Directions.Out && ListBox.SelectedItem != null)
            {
                //move selected container to end
                var selectedContainer = ListBox.ItemContainerGenerator.ContainerFromItem(ListBox.SelectedItem);
                listBoxItems.Remove(selectedContainer);
                listBoxItems.Add(selectedContainer);
            }

            foreach (ListBoxItem li in listBoxItems)
            {
                GeneralTransform gt = li.TransformToVisual(RootElement);
                Point globalCoords = gt.Transform(new Point(0, 0));
                double heightAdjustment = li.Content is FrameworkElement ? ((li.Content as FrameworkElement).ActualHeight / 2) : (li.ActualHeight / 2);
                //double yCoord = globalCoords.Y + ((((System.Windows.FrameworkElement)(((System.Windows.Controls.ContentControl)(li)).Content)).ActualHeight) / 2);
                double yCoord = globalCoords.Y + heightAdjustment;

                double offsetAmount = (RootElement.ActualHeight / 2) - yCoord;

                PlaneProjection pp = new PlaneProjection();
                pp.GlobalOffsetY = offsetAmount * -1;
                pp.CenterOfRotationX = 0;
                li.Projection = pp;

                CompositeTransform ct = new CompositeTransform();
                ct.TranslateY = offsetAmount;
                li.RenderTransform = ct;

                var beginTime = TimeSpan.FromMilliseconds((FeatherDelay * liCounter) + InitialDelay);

                if (Direction == Directions.In)
                {
                    li.Opacity = 0;

                    DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();

                    EasingDoubleKeyFrame edkf1 = new EasingDoubleKeyFrame();
                    edkf1.KeyTime = beginTime;
                    edkf1.Value = Angle;
                    daukf.KeyFrames.Add(edkf1);

                    EasingDoubleKeyFrame edkf2 = new EasingDoubleKeyFrame();
                    edkf2.KeyTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);
                    edkf2.Value = 0;

                    ExponentialEase ee = new ExponentialEase();
                    ee.EasingMode = EasingMode.EaseOut;
                    ee.Exponent = 6;

                    edkf2.EasingFunction = ee;
                    daukf.KeyFrames.Add(edkf2);

                    Storyboard.SetTarget(daukf, li);
                    Storyboard.SetTargetProperty(daukf, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
                    Storyboard.Children.Add(daukf);

                    DoubleAnimation da = new DoubleAnimation();
                    da.Duration = TimeSpan.FromMilliseconds(0);
                    da.BeginTime = beginTime;
                    da.To = 1;

                    Storyboard.SetTarget(da, li);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
                    Storyboard.Children.Add(da);
                }
                else
                {
                    li.Opacity = 1;

                    DoubleAnimation da = new DoubleAnimation();
                    da.BeginTime = beginTime;
                    da.Duration = TimeSpan.FromMilliseconds(Duration);
                    da.To = Angle;

                    ExponentialEase ee = new ExponentialEase();
                    ee.EasingMode = EasingMode.EaseIn;
                    ee.Exponent = 6;

                    da.EasingFunction = ee;

                    Storyboard.SetTarget(da, li);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
                    Storyboard.Children.Add(da);

                    da = new DoubleAnimation();
                    da.Duration = TimeSpan.FromMilliseconds(10);
                    da.To = 0;
                    da.BeginTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);

                    Storyboard.SetTarget(da, li);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
                    Storyboard.Children.Add(da);
                }

                liCounter++;
            }

            base.Begin(completionAction);
        }
Beispiel #51
0
                public void Enter(ElementPlacement initialPlacement) {
                    currentPlacement = initialPlacement;

                    //size
                    maskingLayer.Width = currentPlacement.Size.Width;
                    maskingLayer.Height = currentPlacement.Size.Height;

                    //position and orientation
                    maskingLayer.RenderTransform = currentPlacement.Transform;

                    //enter animation
                    var projection = new PlaneProjection { CenterOfRotationY = 0.1 };
                    viewContainer.Projection = projection;
                    AddDoubleAnimation(projection, "RotationX", from:-90, to:0, ms:400);
                    AddDoubleAnimation(maskingLayer, "Opacity", from:0, to:1, ms:400);

                    storyboard.Begin();
                }
        private Canvas DrawRightPage()
        {
            //Tworzę obiekt canvas
            Canvas cv = new Canvas();
            cv.Width = 100;
            cv.Height = 100;

            Random r = new Random();
            int liczba = r.Next(0, 2);

            info.Text = liczba.ToString();

            switch (liczba)
            {
                case 0:
                    {
                        //SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255));
                        ImageBrush ib = new ImageBrush();
                        ib.ImageSource = new BitmapImage(new Uri("/image/Moje.jpg", UriKind.Relative));
                        cv.Background = ib;
                        //cv.Background = sb;
                        break;
                    }
                case 1:
                    {
                        //SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255));
                        ImageBrush ib = new ImageBrush();
                        ib.ImageSource = new BitmapImage(new Uri("/image/samurai300.png", UriKind.Relative));
                        cv.Background = ib;
                        //cv.Background = sb;
                        break;
                    }
            }

            Canvas.SetLeft(cv, 150);
            Canvas.SetTop(cv, 100);

            //Projekcja
            PlaneProjection pp = new PlaneProjection();
            pp.LocalOffsetX = 50.0;
            cv.Projection = pp;

            //Dodaję canvas
            plutno.Children.Add(cv);

            //Tworzę animację
            stR = new Storyboard();
            DoubleAnimation db = new DoubleAnimation();
            db.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
            db.From = 0.0;
            db.To = 180.0;

            Storyboard.SetTarget(db, pp);
            Storyboard.SetTargetProperty(db, new PropertyPath(PlaneProjection.RotationYProperty));

            //Dodanie animacji do storyboarda
            stR.Children.Add(db);

            return cv;
        }
        private void ScaleAnimation(int boxNumber)
        {
            TransformGroup transformGroup = new TransformGroup();
            ScaleTransform scaleTransform = new ScaleTransform();
            PlaneProjection planeProjection = new PlaneProjection();
            scaleTransform.ScaleX = 1 + _scale10 / _step10;
            scaleTransform.ScaleY = 1 + _scale10 / _step10;

            TranslateTransform translateTransform = new TranslateTransform();
            translateTransform.X = _xIncrement * (_stepMax - _step10);
            translateTransform.Y = _yIncrement * (_stepMax - _step10);
            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(translateTransform);

            _namelist[boxNumber].RenderTransform = transformGroup;
            _namelist[boxNumber].Projection = planeProjection;
            planeProjection.RotationY = 15 * _step10;
        }
Beispiel #54
0
        private static void OnTiltChanged(DependencyObject d,
      DependencyPropertyChangedEventArgs args)
        {
            FrameworkElement targetElement = d as FrameworkElement;

              double tiltFactor = GetTilt(d);

              // create the required transformations
              var projection = new PlaneProjection();
              var scale = new ScaleTransform();
              var translate = new TranslateTransform();

              var transGroup = new TransformGroup();
              transGroup.Children.Add(scale);
              transGroup.Children.Add(translate);

              // associate with the target element
              targetElement.Projection = projection;
              targetElement.RenderTransform = transGroup;
              targetElement.RenderTransformOrigin = new Point(0.5, 0.5);

              targetElement.MouseLeftButtonDown += (s, e) =>
            {
              var clickPosition = e.GetPosition(targetElement);

              // find the maximum of width / height
              double maxDimension = Math.Max(targetElement.ActualWidth, targetElement.ActualHeight);

              // compute the normalised horizontal distance from the centre
              double distanceFromCenterX = targetElement.ActualWidth / 2 - clickPosition.X;
              double normalisedDistanceX = 2 * distanceFromCenterX / maxDimension;

              // rotate around the Y axis
              projection.RotationY = normalisedDistanceX * TiltAngleFactor * tiltFactor;

              // compute the normalised vertical distance from the centre
              double distanceFromCenterY = targetElement.ActualHeight / 2 - clickPosition.Y;
              double normalisedDistanceY = 2 * distanceFromCenterY / maxDimension;

              // rotate around the X axis,
              projection.RotationX = -normalisedDistanceY * TiltAngleFactor * tiltFactor;

              // find the distance to centre
              double distanceToCentre = Math.Sqrt(normalisedDistanceX * normalisedDistanceX
            + normalisedDistanceY * normalisedDistanceY);

              // scale accordingly
              double scaleVal = tiltFactor * (1 - distanceToCentre) / ScaleFactor;
              scale.ScaleX = 1 - scaleVal;
              scale.ScaleY = 1 - scaleVal;

              // offset the plane transform
              var rootElement = Application.Current.RootVisual as FrameworkElement;
              var relativeToCentre = (targetElement.GetRelativePosition(rootElement).Y - rootElement.ActualHeight / 2) / 2;
              translate.Y = -relativeToCentre;
              projection.LocalOffsetY = +relativeToCentre;

            };

              targetElement.ManipulationCompleted += (s, e) =>
            {
              var sb = new Storyboard();
              sb.Children.Add(CreateAnimation(null, 0, 0.1, "RotationY", projection));
              sb.Children.Add(CreateAnimation(null, 0, 0.1, "RotationX", projection));
              sb.Children.Add(CreateAnimation(null, 1, 0.1, "ScaleX", scale));
              sb.Children.Add(CreateAnimation(null, 1, 0.1, "ScaleY", scale));
              sb.Begin();

              translate.Y = 0;
              projection.LocalOffsetY = 0;
            };
        }
 private void SetupListItems(double degree)
 {
     // Add a projection for each list item and turn it to -90 (rotationX) so it is hidden.
     for (int x = 0; x < Picker.Items.Count; x++)
     {
         FrameworkElement item = (FrameworkElement)Picker.ItemContainerGenerator.ContainerFromIndex(x);
         if (null != item)
         {
             PlaneProjection p = (PlaneProjection)item.Projection;
             if (null == p)
             {
                 p = new PlaneProjection();
                 item.Projection = p;
             }
             p.RotationX = degree;
         }
     }
 }
Beispiel #56
0
        protected override Size MeasureOverride(Size availableSize)
        {
            var newelements = (from element in Children
                               join existing in elements on element equals existing into joined
                               from item in joined.DefaultIfEmpty()
                               where item == null
                               select element).ToList();

            var oldelements = (from element in elements
                               join current in Children on element equals current into joined
                               from item in joined.DefaultIfEmpty()
                               where item == null
                               select element).ToList();

            newelements.ForEach((element) =>
                {
                    PlaneProjection projection = element.Projection as PlaneProjection;
                    if (projection == null)
                    {
                        projection = new PlaneProjection();
                        element.Projection = projection;
                    }
                });
            elements.AddRange(newelements);
            oldelements.ForEach((element) => { elements.Remove(element); });
            foreach (var item in Children)
            {
                item.Measure(availableSize);
            }
            if (double.IsPositiveInfinity(availableSize.Width) || double.IsPositiveInfinity(availableSize.Height))
            {
                return new Size(1000000, 1000000);
            }
            else
            {
                return availableSize;
            }
        }
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            OrientationChanged += OnOrientationChanged;
            lastOrientation = Orientation;

            // Customize the ApplicationBar Buttons by providing the right text
            if (null != ApplicationBar)
            {
                foreach (object obj in ApplicationBar.Buttons)
                {
                    IApplicationBarIconButton button = obj as IApplicationBarIconButton;
                    if (null != button)
                    {
                        if ("DONE" == button.Text)
                        {
                            button.Text = LocalizedResources.ControlResources.DateTimePickerDoneText;
                            button.Click += OnDoneButtonClick;
                        }
                        else if ("CANCEL" == button.Text)
                        {
                            button.Text = LocalizedResources.ControlResources.DateTimePickerCancelText;
                            button.Click += OnCancelButtonClick;
                        }
                    }
                }
            }

            SetupListItems(-90);

            PlaneProjection headerProjection = (PlaneProjection)HeaderTitle.Projection;
            if (null == headerProjection)
            {
                headerProjection = new PlaneProjection();
                HeaderTitle.Projection = headerProjection;
            }
            headerProjection.RotationX = -90;

            Picker.Opacity = 1;

            Dispatcher.BeginInvoke(() =>
                {
                    IsOpen = true;
                });
                
        }
Beispiel #58
0
 /*
  * Initializez Canvas-ul meniului
  * Folosit si pentru a reseta Canvas-ul
  * */
 void initialize()
 {
     myMeniuPicksCanvas = new Canvas();
     myMeniuPicksCanvas.Width = width;
     myMeniuPicksCanvas.Height = height;
     myMeniuPicksCanvas.Background = new SolidColorBrush(Colors.Transparent);
     PlaneProjection ff = new PlaneProjection();
     ff.RotationY = 180;
     myMeniuPicksCanvas.Projection = ff;
     myMeniuPicksCanvas.Opacity = opacity;
     parent.Children.Add(myMeniuPicksCanvas);
     Canvas.SetLeft(myMeniuPicksCanvas, left);
     Canvas.SetTop(myMeniuPicksCanvas, top);
     #region butoninainte
     polygonInainte = new Polygon();
     polygonInainte.Opacity = 0.9;
     polygonInainte.Points = new PointCollection() { new Point(30, 50), new Point(40, 40), new Point(37, 50), new Point(40, 60), };
     polygonInainte.Fill = new SolidColorBrush(Colors.Yellow);
     polygonInainte.StrokeThickness = 2;
     polygonInainte.MouseLeftButtonDown += new MouseButtonEventHandler(polygon_MouseLeftButtonDown);
     //polygonInainte.MouseEnter += new MouseEventHandler(polygonInainte_MouseEnter);
     polygonInainte.Stroke = new SolidColorBrush(Colors.Gray);
     myMeniuPicksCanvas.Children.Add(polygonInainte);
     #endregion
     #region butoninapoi
     polygonInapoi = new Polygon();
     polygonInapoi.Opacity = 0.5;
     polygonInapoi.Points = new PointCollection() { new Point(640, 50), new Point(630, 40), new Point(633, 50), new Point(630, 60), };
     polygonInapoi.Fill = new SolidColorBrush(Colors.Red);
     polygonInapoi.StrokeThickness = 2;
     polygonInapoi.MouseLeftButtonDown += new MouseButtonEventHandler(polygonInapoi_MouseLeftButtonDown);
     polygonInapoi.Stroke = new SolidColorBrush(Colors.Gray);
     myMeniuPicksCanvas.Children.Add(polygonInapoi);
     #endregion
 }
Beispiel #59
0
        /// <summary>
        /// Prepares a control to be tilted by setting up a plane projection and
        /// some event handlers.
        /// </summary>
        /// <param name="element">The control that is to be tilted.</param>
        /// <param name="centerDelta">Delta between the element's center and the
        /// tilt container's.</param>
        /// <returns>true if successful; false otherwise.</returns>
        /// <remarks>
        /// This method is conservative; it will fail any attempt to tilt a 
        /// control that already has a projection on it.
        /// </remarks>
        static bool PrepareControlForTilt(FrameworkElement element, Point centerDelta)
        {
            // Prevents interference with any existing transforms
            if (element.Projection != null || (element.RenderTransform != null && element.RenderTransform.GetType() != typeof(MatrixTransform)))
            {
                return false;
            }

            _originalCacheMode[element] = element.CacheMode;
            element.CacheMode = new BitmapCache();

            TranslateTransform transform = new TranslateTransform();
            transform.X = centerDelta.X;
            transform.Y = centerDelta.Y;
            element.RenderTransform = transform;

            PlaneProjection projection = new PlaneProjection();
            projection.GlobalOffsetX = -1 * centerDelta.X;
            projection.GlobalOffsetY = -1 * centerDelta.Y;
            element.Projection = projection;

            element.ManipulationDelta += TiltEffect_ManipulationDelta;
            element.ManipulationCompleted += TiltEffect_ManipulationCompleted;

            return true;
        }
Beispiel #60
0
        public static void EaseValue(PlaneProjection current, PlaneProjection startValue, PlaneProjection endValue, double percent)
        {
            if (current.RotationX != endValue.RotationX) current.RotationX = EaseHelper.EaseValue(startValue.RotationX, endValue.RotationX, percent);
            if (current.RotationY != endValue.RotationY) current.RotationY = EaseHelper.EaseValue(startValue.RotationY, endValue.RotationY, percent);
            if (current.RotationZ != endValue.RotationZ) current.RotationZ = EaseHelper.EaseValue(startValue.RotationZ, endValue.RotationZ, percent);
            if (current.LocalOffsetX != endValue.LocalOffsetX) current.LocalOffsetX = EaseHelper.EaseValue(startValue.LocalOffsetX, endValue.LocalOffsetX, percent);
            if (current.LocalOffsetY != endValue.LocalOffsetY) current.LocalOffsetY = EaseHelper.EaseValue(startValue.LocalOffsetY, endValue.LocalOffsetY, percent);
            if (current.LocalOffsetZ != endValue.LocalOffsetZ) current.LocalOffsetZ = EaseHelper.EaseValue(startValue.LocalOffsetZ, endValue.LocalOffsetZ, percent);
            if (current.GlobalOffsetX != endValue.GlobalOffsetX) current.GlobalOffsetX = EaseHelper.EaseValue(startValue.GlobalOffsetX, endValue.GlobalOffsetX, percent);
            if (current.GlobalOffsetY != endValue.GlobalOffsetY) current.GlobalOffsetY = EaseHelper.EaseValue(startValue.GlobalOffsetY, endValue.GlobalOffsetY, percent);
            if (current.GlobalOffsetZ != endValue.GlobalOffsetZ) current.GlobalOffsetZ = EaseHelper.EaseValue(startValue.GlobalOffsetZ, endValue.GlobalOffsetZ, percent);
            if (current.CenterOfRotationX != endValue.CenterOfRotationX) current.CenterOfRotationX = EaseHelper.EaseValue(startValue.CenterOfRotationX, endValue.CenterOfRotationX, percent);
            if (current.CenterOfRotationY != endValue.CenterOfRotationY) current.CenterOfRotationY = EaseHelper.EaseValue(startValue.CenterOfRotationY, endValue.CenterOfRotationY, percent);
            if (current.CenterOfRotationZ != endValue.CenterOfRotationZ) current.CenterOfRotationZ = EaseHelper.EaseValue(startValue.CenterOfRotationZ, endValue.CenterOfRotationZ, percent);

            //  NOT TEST
            //if (current.ProjectionMatrix != endValue.ProjectionMatrix) EaseValue(current.ProjectionMatrix, startValue.ProjectionMatrix, endValue.ProjectionMatrix, percent);
        }