Ejemplo n.º 1
0
        public void Parallax_Expression()
        {
            _compositor = new Compositor();
            _root       = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(Container);
            _compositor = _root.Compositor;

            // Create the Blue Square
            var blueSquareVisual = _compositor.CreateSolidColorVisual();

            blueSquareVisual.Color  = Colors.Blue;
            blueSquareVisual.Size   = new System.Numerics.Vector2(100.0f, 100.0f);
            blueSquareVisual.Offset = new Vector3(100.00f, 50.00f, 0.00f);

            // Create the Green Square
            var greenSquareVisual = _compositor.CreateSolidColorVisual();

            greenSquareVisual.Color  = Colors.Green;
            greenSquareVisual.Size   = new System.Numerics.Vector2(50.0f, 50.0f);
            greenSquareVisual.Offset = new Vector3(100.00f, 50.00f, 0.00f);


            // Add the Blue and Green square visuals to the tree
            _root.Children.InsertAtTop(blueSquareVisual);
            _root.Children.InsertAtTop(greenSquareVisual);

            _foreground = greenSquareVisual;
            _background = blueSquareVisual;
        }
Ejemplo n.º 2
0
        public void SetupVisuals()
        {
            // Intialize the Compositor
            _compositor = new Compositor();
            _root       = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(Container);
            _compositor = _root.Compositor;

            // Create the Blue Square
            var blueSquareVisual = _compositor.CreateSolidColorVisual();

            blueSquareVisual.Color  = Colors.Blue;
            blueSquareVisual.Size   = new System.Numerics.Vector2(50.0f, 50.0f);
            blueSquareVisual.Offset = new Vector3(100.00f, 50.00f, 0.00f);

            // Create the Green Square with 20% opacity
            var greenSquareVisual = _compositor.CreateSolidColorVisual();

            greenSquareVisual.Color   = Colors.Green;
            greenSquareVisual.Size    = new System.Numerics.Vector2(50.0f, 50.0f);
            greenSquareVisual.Offset  = new Vector3(150.00f, 100.00f, 0.00f);
            greenSquareVisual.Opacity = 0.20f;

            // Add the Visuals to the tree
            _root.Children.InsertAtTop(greenSquareVisual);
            _root.Children.InsertAtTop(blueSquareVisual);

            _source = greenSquareVisual;
            _target = blueSquareVisual;
        }
Ejemplo n.º 3
0
        private void Host_Loaded(object sender, RoutedEventArgs e)
        {
            this.container  = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(this.Host);
            this.compositor = container.Compositor;

            this.background       = this.compositor.CreateSolidColorVisual();
            this.background.Color = Colors.LightGreen;

            this.container.Children.InsertAtBottom(background);
            UpdateSize();
        }
Ejemplo n.º 4
0
        // Define and setup the Green Square Visual that will be animated
        public void SetupVisual()
        {
            // Intialize the Compositor
            _compositor = new Compositor();
            _root       = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(Container);
            _compositor = _root.Compositor;

            // Generate the Green Square
            var colorVisual = _compositor.CreateSolidColorVisual();

            colorVisual.Color  = Colors.Green;
            colorVisual.Size   = new Vector2(150.0f, 150.0f);
            colorVisual.Offset = new Vector3(25.0f, 50.0f, 0.0f);

            // Add the image to the tree
            _root.Children.InsertAtTop(colorVisual);

            _target = colorVisual;
        }
Ejemplo n.º 5
0
        // Define and setup the Green square visual that will be later animated
        private void ShowVisual_Click(object sender, RoutedEventArgs e)
        {
            // Initialize the Compositor
            _compositor = new Compositor();
            _root       = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(root);
            _compositor = _root.Compositor;

            // Generate the Green Square
            var colorVisual = _compositor.CreateSolidColorVisual();

            colorVisual.Color  = Colors.Green;
            colorVisual.Size   = new Vector2(150.0f, 150.0f);
            colorVisual.Offset = new Vector3(50.0f, 150.0f, 0.0f);

            // Add the image to the tree
            _root.Children.InsertAtBottom(colorVisual);

            _target = colorVisual;
        }
Ejemplo n.º 6
0
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // Create Container Visual from Grid to be used as root of Visual Tree
            _root       = ElementCompositionPreview.GetContainerVisual(Placeholder) as ContainerVisual;
            _compositor = _root.Compositor;

            // Create Solid Color Visual and insert into Visual Tree
            _mainVisual             = _compositor.CreateSolidColorVisual();
            _mainVisual.Size        = new Vector2(RectangleWidth, RectangleHeight);
            _mainVisual.Color       = Windows.UI.Colors.Blue;
            _mainVisual.CenterPoint = new Vector3(RectangleWidth / 2, RectangleHeight / 2, 0);

            float rectPositionX = (float)(-RectangleWidth / 2);
            float rectPositionY = (float)(-RectangleHeight / 2);

            _mainVisual.Offset = new Vector3(rectPositionX, rectPositionY, 0);

            _root.Children.InsertAtTop(_mainVisual);
        }
Ejemplo n.º 7
0
        // Defines the Visual to be animated in this sample and adds it to the Visual Tree
        public void SetupVisual()
        {
            // Intialize the Compositor
            _compositor = new Compositor();
            _root       = (ContainerVisual)ElementCompositionPreview.GetContainerVisual(Container);
            _compositor = _root.Compositor;

            // Create the Blue Square
            var colorVisual = _compositor.CreateSolidColorVisual();

            colorVisual.Color = Colors.Blue;

            colorVisual.Size   = new System.Numerics.Vector2(150.0f, 150.0f);
            colorVisual.Offset = new Vector3(100.00f, 50.00f, 0.00f);

            // Add the Visual to the tree
            _root.Children.InsertAtTop(colorVisual);

            _target = colorVisual;
        }
Ejemplo n.º 8
0
 private static ContainerVisual GetVisual(UIElement element)
 {
     return((ContainerVisual)ElementCompositionPreview.GetContainerVisual(element));
 }
 private void InitializeCompositior()
 {
     _rootVisual = ElementCompositionPreview.GetContainerVisual(followersHost) as ContainerVisual;
     _compositor = _rootVisual.Compositor;
 }