Ejemplo n.º 1
0
 internal void CopyPropertiesFrom(CALayerXaml fromLayer)
 {
     Set("opacity", fromLayer.Get("opacity"));
     Set("position", fromLayer.Get("position"));
     Set("size", fromLayer.Get("size"));
     Set("anchorPoint", fromLayer.Get("anchorPoint"));
 }
Ejemplo n.º 2
0
 static internal void HandleMoveInput(CALayerXaml layer, PointerRoutedEventArgs e)
 {
     CALayerXaml rootLayer = layer;
     while (rootLayer.Parent is CALayerXaml)
     {
         rootLayer = (rootLayer.Parent as CALayerXaml);
     }
     Windows.UI.Input.PointerPoint point = e.GetCurrentPoint(rootLayer);
     InputEventHandler.PointerMoved((float)point.Position.X, (float)point.Position.Y, point.PointerId, point.Timestamp);
 }
Ejemplo n.º 3
0
 public CALayerXamlAutomationPeer(CALayerXaml owner) : base(owner) {
 }
Ejemplo n.º 4
0
            public void Animate(CALayerXaml layer, String propertyName, Object from, Object to)
            {
                DoubleAnimation timeline = new DoubleAnimation();
                timeline.Duration = _container.Duration;
                timeline.EasingFunction = _AnimationEase;

                CALayerXaml.animatableProperties[propertyName].Animate(layer, _container, timeline, from, to);
            }
Ejemplo n.º 5
0
            static internal void HandleDownInput(CALayerXaml layer, PointerRoutedEventArgs e)
            {
                CALayerXaml rootLayer = layer;
                while (rootLayer.Parent is CALayerXaml)
                {
                    rootLayer = (rootLayer.Parent as CALayerXaml);
                }
                Windows.UI.Input.PointerPoint point = e.GetCurrentPoint(rootLayer);
                InputEventHandler.PointerDown((float)point.Position.X, (float)point.Position.Y, point.PointerId, point.Timestamp);

                if (DummyFocus == null) {
                    DummyFocus = new UserControl();
                    DummyFocus.Width = 0;
                    DummyFocus.Height = 0;
                    DummyFocus.IsTabStop = true;
                    ((Panel)rootLayer.Parent).Children.Add(DummyFocus);
                }
                DummyFocus.Focus(FocusState.Keyboard);
            }
Ejemplo n.º 6
0
 static public void DestroyLayer(CALayerXaml layer)
 {
     layer.DiscardContent();
     _LayerContentCache.PushCacheableObject(layer);
 }
Ejemplo n.º 7
0
            async private Task<int> DoAddTransition(CALayerXaml layer, String type, String subtype)
            {
                RenderTargetBitmap copiedLayer = new RenderTargetBitmap();
                double scale = CALayerXaml.screenScale;
                await copiedLayer.RenderAsync(layer, (int)(layer.CurrentWidth * scale), 0);

                CALayerXaml newLayer = CALayerXaml.CreateLayer();
                newLayer.CopyPropertiesFrom(layer);
                int width = copiedLayer.PixelWidth;
                int height = copiedLayer.PixelHeight;

                newLayer.setContentImage(copiedLayer, (float)width, (float)height, (float)scale);
                newLayer.SetContentGravity(ContentGravity.ResizeAspectFill);

                if (type == "kCATransitionFlip")
                {
                    _container.Duration = new Duration(TimeSpan.FromSeconds(0.75));
                    Panel parent = (Panel)VisualTreeHelper.GetParent(layer);
                    int idx = parent.Children.IndexOf(layer);
                    parent.Children.Insert(idx + 1, newLayer);
                    parent.InvalidateArrange();
                    layer.Opacity = 0;

                    bool flipToLeft = true;
                    if (subtype != "kCATransitionFromLeft")
                    {
                        flipToLeft = false;
                    }

                    CreateFlip(newLayer, flipToLeft, false, true);
                    CreateFlip(layer, flipToLeft, true, false);
                }
                else
                {
                    _container.Duration = new Duration(TimeSpan.FromSeconds(0.5));
                    Panel parent = (Panel)VisualTreeHelper.GetParent(layer);
                    int idx = parent.Children.IndexOf(layer);

                    bool fromRight = true;
                    if (subtype == "kCATransitionFromLeft")
                    {
                        fromRight = false;
                    }

                    if (fromRight)
                    {
                        parent.Children.Insert(idx, newLayer);
                        parent.InvalidateArrange();
                        CreateWoosh(newLayer, fromRight, true, true);
                        CreateWoosh(layer, fromRight, false, false);
                    }
                    else
                    {
                        parent.Children.Insert(idx + 1, newLayer);
                        parent.InvalidateArrange();
                        CreateWoosh(newLayer, fromRight, false, true);
                        CreateWoosh(layer, fromRight, true, false);
                    }
                }

                return 0;
            }
Ejemplo n.º 8
0
 public IAsyncOperation<int> AddTransition(CALayerXaml layer, String type, String subtype)
 {
     return DoAddTransition(layer, type, subtype).AsAsyncOperation<int>();
 }
Ejemplo n.º 9
0
            internal void CreateWoosh(CALayerXaml layer, bool fromRight, bool invert, bool removeFromParent)
            {
                if (layer.Projection == null)
                {
                    layer.Projection = new PlaneProjection();
                }

                DoubleAnimation rotateAnim = new DoubleAnimation();
                rotateAnim.Duration = _container.Duration;
                rotateAnim.EasingFunction = new PowerEase();
                rotateAnim.EasingFunction.EasingMode = EasingMode.EaseOut;

                if (!invert)
                {
                    if (fromRight)
                    {
                        rotateAnim.From = layer.CurrentWidth;
                        rotateAnim.To = 0.01;
                    }
                    else
                    {
                        rotateAnim.From = 0.01;
                        rotateAnim.To = layer.CurrentWidth;
                    }
                }
                else
                {
                    if (fromRight)
                    {
                        rotateAnim.From = 0.01;
                        rotateAnim.To = -layer.CurrentWidth / 4;
                    }
                    else
                    {
                        rotateAnim.From = -layer.CurrentWidth / 4;
                        rotateAnim.To = 0.01;
                    }
                }

                Storyboard.SetTargetProperty(rotateAnim, "(UIElement.Projection).(PlaneProjection.LocalOffsetX)");
                Storyboard.SetTarget(rotateAnim, layer);

                if (removeFromParent)
                {
                    rotateAnim.Completed += (Object sender, Object args) =>
                    {
                        VisualTreeHelper.DisconnectChildrenRecursive(layer);
                        //CALayerXaml.DestroyLayer(layer);
                    };
                }

                _container.Children.Add(rotateAnim);
            }
Ejemplo n.º 10
0
            internal void CreateFlip(CALayerXaml layer, bool flipRight, bool invert, bool removeFromParent)
            {
                if (layer.Projection == null)
                {
                    layer.Projection = new PlaneProjection();
                }

                DoubleAnimation rotateAnim = new DoubleAnimation();
                rotateAnim.Duration = _container.Duration;

                if (!invert)
                {
                    rotateAnim.From = 0.01;
                    if (!flipRight)
                    {
                        rotateAnim.To = 180;
                    }
                    else
                    {
                        rotateAnim.To = -180;
                    }
                }
                else
                {
                    if (!flipRight)
                    {
                        rotateAnim.From = 180;
                        rotateAnim.To = 360;
                    }
                    else
                    {
                        rotateAnim.From = -180;
                        rotateAnim.To = -360;
                    }
                }

                ((PlaneProjection)layer.Projection).CenterOfRotationX = layer.CurrentWidth / 2;
                ((PlaneProjection)layer.Projection).CenterOfRotationY = layer.CurrentHeight / 2;
                Storyboard.SetTargetProperty(rotateAnim, "(UIElement.Projection).(PlaneProjection.RotationY)");
                Storyboard.SetTarget(rotateAnim, layer);
                _container.Children.Add(rotateAnim);

                DoubleAnimation moveAnim = new DoubleAnimation();
                moveAnim.Duration = _container.Duration;
                moveAnim.From = 0.01;
                moveAnim.To = -160;
                moveAnim.SpeedRatio = 2.0;
                moveAnim.AutoReverse = true;

                Storyboard.SetTarget(moveAnim, layer);
                Storyboard.SetTargetProperty(moveAnim, "(UIElement.Projection).(PlaneProjection.GlobalOffsetZ)");
                _container.Children.Add(moveAnim);

                DoubleAnimation fade1 = new DoubleAnimation();
                Storyboard.SetTarget(fade1, layer);
                Storyboard.SetTargetProperty(fade1, "(UIElement.Opacity)");

                if (!invert)
                {
                    fade1.Duration = TimeSpan.FromSeconds(_container.Duration.TimeSpan.TotalSeconds / 2.0);
                    fade1.From = 1.0;
                    fade1.To = 0.5;
                    fade1.FillBehavior = FillBehavior.HoldEnd;
                }
                else
                {
                    fade1.Duration = TimeSpan.FromSeconds(_container.Duration.TimeSpan.TotalSeconds / 2.0);
                    fade1.BeginTime = TimeSpan.FromSeconds(_container.Duration.TimeSpan.TotalSeconds / 2.0);
                    fade1.From = 0.5;
                    fade1.To = 1.0;
                    fade1.FillBehavior = FillBehavior.HoldEnd;

                    fade1.Completed += (Object sender, Object args) =>
                    {
                        layer.Opacity = 1.0;
                    };
                }

                if (removeFromParent)
                {
                    fade1.Completed += (Object sender, Object args) =>
                    {
                        VisualTreeHelper.DisconnectChildrenRecursive(layer);
                        //CALayerXaml.DestroyLayer(layer);
                    };
                }

                _container.Children.Add(fade1);
            }