Beispiel #1
0
        public void WriteCompositor(Compositor comp)
        {
            _writer.WriteLine("%PDF-1.4");
            int itemCount = 0;
            foreach (IndirectObject indirectObject in comp.Objects) {
                indirectObject.Offset = _writer.Position;
                Write(indirectObject);
                itemCount += 1;
            }

            int xrefOffset = _writer.Position;
            _writer.WriteLine("xref");
            _writer.WriteLine("{0}  {1}", comp.StartID, itemCount + 1);
            _writer.WriteLine("0000000000 65535 f");
            foreach (IndirectObject indirectObject in comp.Objects) {
                _writer.WriteLine("{0:0000000000} {1:00000} n", indirectObject.Offset, indirectObject.Reference.Generation);
            }
            _writer.WriteLine("trailer");
            WriteObject(new DictionaryObject()
                .Set("Size", new IntegerNumberObject(itemCount))
                .Set("Root", comp.CatalogReference)
            );
            _writer.WriteLine();
            _writer.WriteLine("startxref");
            _writer.WriteLine(xrefOffset);
            _writer.WriteLine("%%EOF");
        }
Beispiel #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;
        }
Beispiel #3
0
        public void Transform(IEnumerable<Element> elements, Stream output)
        {
            Compositor compositor = new Compositor();
            var root = compositor.RootPageCollection
                .MediaBox(0, 0, (int)PageSettings.InPoints(_settings.PageWidth), (int)PageSettings.InPoints(_settings.PageHeight))
                .AddResources()
                    .AddSimpeType1Font("Courier", out _courier)
                    .AddSimpeType1Font("Courier-Bold", out _courierBold)
                    .AddSimpeType1Font("Courier-Oblique", out _courierItalic)
                    .AddSimpeType1Font("Courier-BoldOblique", out _courierBoldItalic)
                .End();

            _page = NewPage(root);

            WriteTitleElement(elements.FirstOrDefault() as TitleElement);

            foreach (var element in elements) {
                bool found = Write(element as DialogGroupElement)
                    || Write(element as ActionElement)
                    || Write(element as HeadingElement)
                    || Write(element as TransitionElement)
                    || Write(element as CenteredTextElement)
                    || Write(element as BoneyardElement)
                    || Write(element as NoteBlockElement)
                    || Write(element as SectionElement);

                if (!found)
                    Console.WriteLine("NOT FOUND: {0}", element.Type);
            }

            TextWriter w = new StreamWriter(output);
            PdfOutput pdfOutput = new PdfOutput(w);
            pdfOutput.WriteCompositor(compositor);
            w.Flush();
        }
        public void SetupDestinationEffect(Compositor compositor)
        {
            // Create SpriteVisual for blur effect
            _destVisual = compositor.CreateSpriteVisual();
            _destVisual.Size = new Vector2(0, 0);

            // Create graphics effect for blur
            var graphicsEffect = new GaussianBlurEffect
            {
                Name = "GB",
                Source = new CompositionEffectSourceParameter("destinationSource"),
                BlurAmount = 10f,
                BorderMode = EffectBorderMode.Hard,
                Optimization = EffectOptimization.Balanced

            };

            var effectFactory = compositor.CreateEffectFactory(graphicsEffect);

            var blurEffect = effectFactory.CreateBrush();
            var destinationBrush = compositor.CreateBackdropBrush();

            blurEffect.SetSourceParameter("destinationSource", destinationBrush);

            // Set the SpriteVisual's brush as blur effect
            _destVisual.Brush = blurEffect;

            // Insert the destination visual as child of the BlurRect UIElement.
            // Since the BlurRect is between the text of the flyout and the content of the page,
            // the destination visual will blur the content of the page.
            ElementCompositionPreview.SetElementChildVisual(BlurRect, _destVisual);
        }
Beispiel #5
0
        public CompositionDevice(Adapter1 adapter, Device2D device2D)
        {
            Contract.Requires(device2D != null);

            _DxgiFactory = new Lazy<Factory1>();

            Adapter1 newAdapter = adapter;

            if(adapter == null)
            {
                newAdapter = _DxgiFactory.Value.GetAdapter1(0);
            }
            #if DEBUG
            _Device3D = new Device1(
                newAdapter, DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug, FeatureLevel.Level_10_0);
            #else
            _Device3D = new Device1(
                newAdapter,
                DeviceCreationFlags.BgraSupport,
                FeatureLevel.Level_10_0);
            #endif
            if(adapter == null)
            {
                newAdapter.Dispose();
            }

            _Compositor = new Compositor(_Device3D, device2D);

            device2D.Resources.RegisterEffect<ColorOutputEffect>();
            device2D.Resources.RegisterEffect<GaussianBlurEffect>();
            device2D.Resources.RegisterEffect<DropShadowEffect>();
            device2D.Resources.RegisterEffect<BoxBlurEffect>();
        }
Beispiel #6
0
        private void InitializeComposition()
        {
            // setup compositor and root visual
            this.compositor = new Compositor();
            this.root = this.compositor.CreateContainerVisual();

            // associate with the CoreWindow
            this.compositionTarget = this.compositor.CreateTargetForCurrentView();
            this.compositionTarget.Root = this.root;

            // add a solid color background
            this.background = this.compositor.CreateSpriteVisual();
            this.background.Brush = this.compositor.CreateColorBrush(Colors.LightGreen);
            this.root.Children.InsertAtBottom(this.background);

            // create green square
            var colorVisual = this.compositor.CreateSpriteVisual();
            colorVisual.Brush = this.compositor.CreateColorBrush(Colors.Green);
            colorVisual.Size = new Vector2(150.0f, 150.0f);
            colorVisual.CenterPoint = new Vector3(75.0f, 75.0f, 0.0f);
            this.target = colorVisual;
            this.root.Children.InsertAtTop(this.target);

            // animate square
            Animate(this.target);

            UpdateSize();
        }
 private static KeyFrameAnimation createOffsetAnimation(Compositor compositor)
 {
     Vector3KeyFrameAnimation kf = compositor.CreateVector3KeyFrameAnimation();
     kf.InsertExpressionKeyFrame(1.0f, "FinalValue");
     kf.Duration = TimeSpan.FromSeconds(0.9);
     return kf;
 }
Beispiel #8
0
        public void Parallax_Expression()
        {
            _compositor = new Compositor();
            _root = ElementCompositionPreview.GetElementVisual(Container);
            _compositor = _root.Compositor;

            // Create the Blue Square
            var blueSquareVisual = _compositor.CreateSpriteVisual();
            blueSquareVisual.Brush = _compositor.CreateColorBrush(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.CreateSpriteVisual();
            greenSquareVisual.Brush = _compositor.CreateColorBrush(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
            ContainerVisual mainContainer = _compositor.CreateContainerVisual();
            ElementCompositionPreview.SetElementChildVisual(Container, mainContainer);
            mainContainer.Children.InsertAtTop(blueSquareVisual);
            mainContainer.Children.InsertAtTop(greenSquareVisual);

            _foreground = greenSquareVisual;
            _background = blueSquareVisual;
        }
        public DetailsPage()
        {
            this.InitializeComponent();

           _mainGridVisual = ElementCompositionPreview.GetElementVisual(Window.Current.Content) as ContainerVisual;
            _compositor = _mainGridVisual.Compositor;
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ThumbnailList.ItemsSource = Model.Items;

            // Populate the Effect combobox
            IList<ComboBoxItem> effectList = new List<ComboBoxItem>();
            foreach (EffectTypes type in Enum.GetValues(typeof(EffectTypes)))
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Tag = type;
                item.Content = type.ToString();
                effectList.Add(item);
            }

            EffectSelection.ItemsSource = effectList;
            EffectSelection.SelectedIndex = 0;

            // Get the current compositor
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            // Create the destinatio sprite, sized to cover the entire list
            _destinationSprite = _compositor.CreateSpriteVisual();
            _destinationSprite.Size = new Vector2((float)ThumbnailList.ActualWidth, (float)ThumbnailList.ActualHeight);

            // Start out with the destination layer invisible to avoid any cost until necessary
            _destinationSprite.IsVisible = false;

            ElementCompositionPreview.SetElementChildVisual(ThumbnailList, _destinationSprite);

            // Update the effect to set the appropriate brush 
            UpdateEffect();

        }
        public ConnectedAnimationSample()
        {
            InitializeComponent();

            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            CustomParametersCheckBox.IsChecked = _usingCustomParameters;
        }
        private void Clock_Loaded(object sender, RoutedEventArgs e)
        {
            _root = Container.GetVisual();
            _compositor = _root.Compositor;

            // Background
            _background = _compositor.CreateSpriteVisual();
            _background.Size = new Vector2(200.0f, 200.0f);
            var _imageFactory = CompositionImageFactory.CreateCompositionImageFactory(_compositor);
            CompositionImageOptions options = new CompositionImageOptions()
            {
                DecodeWidth = 400,
                DecodeHeight = 400,
            };
            var _image = _imageFactory.CreateImageFromUri(FaceImage, options);
            _background.Brush = _compositor.CreateSurfaceBrush(_image.Surface);
            _root.Children.InsertAtTop(_background);

            // Hour Hand
            options = new CompositionImageOptions()
            {
                DecodeWidth = 72,
                DecodeHeight = 240,
            };

            _hourhand = _compositor.CreateSpriteVisual();
            _hourhand.Size = new Vector2(24.0f, 80.0f);
            _image = _imageFactory.CreateImageFromUri(HourHandImage, options);
            _hourhand.Brush = _compositor.CreateSurfaceBrush(_image.Surface);
            _hourhand.CenterPoint = new Vector3(12.0f, 70.0f, 0);
            _hourhand.Offset = new Vector3(88.0f, 30.0f, 0);
            _root.Children.InsertAtTop(_hourhand);

            // Minute Hand
            options = new CompositionImageOptions()
            {
                DecodeWidth = 48,
                DecodeHeight = 270,
            };
            _image = _imageFactory.CreateImageFromUri(MinuteHandImage, options);
            _minutehand = _compositor.CreateSpriteVisual();
            _minutehand.Size = new Vector2(16.0f, 90.0f);
            _minutehand.Brush = _compositor.CreateSurfaceBrush(_image.Surface);
            _minutehand.CenterPoint = new Vector3(8.0f, 85.0f, 0);
            _minutehand.Offset = new Vector3(92.0f, 15.0f, 0);
            _root.Children.InsertAtTop(_minutehand);

            SetHoursAndMinutes();

            // Second Hand
            _secondhand = _compositor.CreateSpriteVisual();
            _secondhand.Size = new Vector2(1.0f, 90.0f);
            _secondhand.Brush = _compositor.CreateColorBrush(Colors.Red);
            _secondhand.CenterPoint = new Vector3(0.5f, 90.0f, 0);
            _secondhand.Offset = new Vector3(99.5f, 10.0f, 0);
            _root.Children.InsertAtTop(_secondhand);
            _secondhand.RotationAngleInDegrees = (float)(int)DateTime.Now.TimeOfDay.TotalSeconds * 6;

            _timer.Start();
        }
        private void SamplePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Get backing visual from shadow container and interop compositor
            _shadowContainer = ElementCompositionPreview.GetElementVisual(ShadowContainer);
            _compositor = _shadowContainer.Compositor;

            // Get CompositionImage, its sprite visual
            _image = VisualTreeHelperExtensions.GetFirstDescendantOfType<CompositionImage>(ShadowContainer);
            _imageVisual = _image.SpriteVisual;

            // Load mask asset onto surface using helpers in SamplesCommon
            _imageLoader = ImageLoaderFactory.CreateImageLoader(_compositor);
            _imageMaskSurface = _imageLoader.CreateCircleSurface(200, Colors.White);

            // Create surface brush for mask
            CompositionSurfaceBrush mask = _compositor.CreateSurfaceBrush();
            mask.Surface = _imageMaskSurface.Surface;
            
            // Get surface brush from composition image
            CompositionSurfaceBrush source = _image.SurfaceBrush as CompositionSurfaceBrush;

            // Create mask brush for toggle mask functionality
            _maskBrush = _compositor.CreateMaskBrush();
            _maskBrush.Mask = mask;
            _maskBrush.Source = source;

            // Initialize toggle mask
            _isMaskEnabled = false;
        }
Beispiel #14
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            _image = ElementCompositionPreview.GetElementVisual(Clock);
            _root = ElementCompositionPreview.GetElementVisual(Root);
            _compositor = _image.Compositor;

            ConfigureInteractionTracker();
        }
 private static KeyFrameAnimation CreateOffsetAnimation(Compositor compositor, TimeSpan duration)
 {
     Vector3KeyFrameAnimation kf = compositor.CreateVector3KeyFrameAnimation();
     kf.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
     kf.Duration = duration;
     kf.Target = "Offset";
     return kf;
 }
        private void CompImage_Loading(FrameworkElement sender, object args)
        {
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            _sprite = _compositor.CreateSpriteVisual();
            _sprite.Size = new Vector2((float)ActualWidth, (float)ActualHeight);

            ElementCompositionPreview.SetElementChildVisual(this, _sprite);
        }
Beispiel #17
0
 public void Initialize(Compositor compositor)
 {
     _compositor = compositor;
     _drawingLock = new object();
     _isDeviceCreator = true;
     DisplayInformation.DisplayContentsInvalidated += OnDisplayContentsInvalidated;
     CreateDevice();
 }
        public ZoomWithPerspective()
        {
            Model = new LocalDataSource();
            this.InitializeComponent();

            // Get the current compositor
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
        }
 public static KeyFrameAnimation CreateOpacityAnimation(Compositor compositor, TimeSpan duration)
 {
     ScalarKeyFrameAnimation kf = compositor.CreateScalarKeyFrameAnimation();
     kf.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
     kf.Duration = duration;
     kf.Target = "Opacity";
     return kf;
 }
 public virtual void Now()
 {
     if (UIElement == null) throw new ArgumentNullException("Must specify an UIElement.");
     var root = ElementCompositionPreview.GetElementVisual(UIElement);
     var compositor = root.Compositor;
     this.RootVisual = root;
     this.Compositor = compositor;
 }
        public DrawingSurfaceRenderer(Compositor compositor, CompositionGraphicsDevice compositionGraphicsDevice)
        {
            drawingSurfaceVisual = compositor.CreateSpriteVisual();
            drawingSurface = compositionGraphicsDevice.CreateDrawingSurface(new Size(256, 256), DirectXPixelFormat.B8G8R8A8UIntNormalized, DirectXAlphaMode.Premultiplied);
            drawingSurfaceVisual.Brush = compositor.CreateSurfaceBrush(drawingSurface);
            DrawDrawingSurface();

            compositionGraphicsDevice.RenderingDeviceReplaced += CompositionGraphicsDevice_RenderingDeviceReplaced;
        }
        public TransitionLibrary(Compositor compositor, LayoutManager layoutManager)
        {
            _layoutManager = layoutManager;
            _windowWidth = 640;
            _windowHeight = 480;
            _zoomScale = 3.0f;
            _random = new Random();

            CreateAnimationTemplates(compositor);
        }
Beispiel #23
0
        static public void Initialize(Compositor compositor)
        {
            Debug.Assert(!_intialized);

            _compositor = compositor;
            _canvasDevice = new CanvasDevice();
            _compositionDevice = CanvasComposition.CreateCompositionGraphicsDevice(_compositor, _canvasDevice);

            _intialized = true;
        }
Beispiel #24
0
        // Define and setup the Green Square Visual that will be animated 
        public void SetupVisual()
        {
            // Intialize the Compositor
            _compositor = new Compositor();
            _root = (ContainerVisual)ElementCompositionPreview.GetElementVisual(Container);
            _compositor = _root.Compositor;

            _linear = _compositor.CreateLinearEasingFunction();

            // Create Green Square
            var colorVisual = _compositor.CreateSpriteVisual();
            colorVisual.Brush = _compositor.CreateColorBrush(Colors.Green);
            colorVisual.Size = new Vector2(150.0f, 150.0f);
            colorVisual.Offset = new Vector3(250.0f, 50.0f, 0.0f);
            colorVisual.CenterPoint = new Vector3(75.0f, 75.0f, 0.0f);
            _target = colorVisual;

            // Create Blue Square
            var colorVisual2 = _compositor.CreateSpriteVisual();
            colorVisual2.Brush = _compositor.CreateColorBrush(Colors.Aqua);
            colorVisual2.Size = new Vector2(200.0f, 150.0f);
            colorVisual2.Offset = new Vector3(25.0f, 50.0f, 0.0f);
            colorVisual2.IsVisible = false; 
            _target2 = colorVisual2;

            // Add the Blue and Green square visuals to the tree
            _mainContainer = _compositor.CreateContainerVisual();
            ElementCompositionPreview.SetElementChildVisual(Container, _mainContainer);
            _mainContainer.Children.InsertAtTop(_target);
            _mainContainer.Children.InsertAtTop(_target2);

            // Create Scoped batch for animations
            _batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            // Add Animation1 to the batch
            Animation1(_target);

            // Suspend the batch to exclude an animation
            _batch.Suspend();

            // Exluding Animation2 from batch
            Animation2(_target);

            // Resuming the batch to collect additional animations
            _batch.Resume();

            // Add Animation3 to the batch
            Animation3(_target);

            // Batch is ended an no objects can be added
            _batch.End();

            // Method triggered when batch completion event fires
            _batch.Completed += OnBatchCompleted;
        }
        private void SamplePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // Acquire Compositor and set up basic visual tree structure
            _xamlRoot = ElementCompositionPreview.GetElementVisual(MainGrid);
            _compositor = _xamlRoot.Compositor;
            _root = _compositor.CreateContainerVisual();
            _mainImage = Image.SpriteVisual;

            ElementCompositionPreview.SetElementChildVisual(ImageContainer, _root);
            _root.Children.InsertAtTop(_mainImage);


            // Add visual indicators to show the position of AnchorPoint and CenterPoint
            _indicatorContainer = _compositor.CreateContainerVisual();

            _apIndicator = _compositor.CreateSpriteVisual();
            _apIndicator.Size = new Vector2(10, 10);
            _apIndicator.AnchorPoint = new Vector2(0.5f, 0.5f);
            _apIndicator.Brush = _compositor.CreateColorBrush(Windows.UI.Colors.Red);

            _cpIndicator = _compositor.CreateSpriteVisual();
            _cpIndicator.Size = new Vector2(10, 10);
            _cpIndicator.AnchorPoint = new Vector2(0.5f, 0.5f);
            _cpIndicator.Brush = _compositor.CreateColorBrush(Windows.UI.Colors.Green);

            _root.Children.InsertAtTop(_indicatorContainer);
            _indicatorContainer.Children.InsertAtTop(_cpIndicator);
            _indicatorContainer.Children.InsertAtTop(_apIndicator);


            // Specify a clip to prevent image from overflowing into the sliders list
            Visual containerGrid = ElementCompositionPreview.GetElementVisual(ContentGrid);
            containerGrid.Size = new Vector2((float)ContentGrid.ActualWidth, (float)ContentGrid.ActualHeight);
            ContentGrid.SizeChanged += (s, a) =>
            {
                containerGrid.Size = new Vector2((float)ContentGrid.ActualWidth, (float)ContentGrid.ActualHeight);
            };
            containerGrid.Clip = _compositor.CreateInsetClip();


            // Create list of properties to add as sliders
            var list = new List<TransformPropertyModel>();
            list.Add(new TransformPropertyModel(AnchorPointXAction) { PropertyName = "AnchorPoint - X (Red)", MinValue = -1, MaxValue = 2, StepFrequency = 0.01f, Value = _mainImage.AnchorPoint.X });
            list.Add(new TransformPropertyModel(AnchorPointYAction) { PropertyName = "AnchorPoint - Y (Red)", MinValue = -1, MaxValue = 2, StepFrequency = 0.01f, Value = _mainImage.AnchorPoint.Y });
            list.Add(new TransformPropertyModel(CenterPointXAction) { PropertyName = "CenterPoint - X (Green)", MinValue = -600, MaxValue = 600, StepFrequency = 1f, Value = _mainImage.CenterPoint.X });
            list.Add(new TransformPropertyModel(CenterPointYAction) { PropertyName = "CenterPoint - Y (Green)", MinValue = -600, MaxValue = 600, StepFrequency = 1f, Value = _mainImage.CenterPoint.Y });
            list.Add(new TransformPropertyModel(RotationAction) { PropertyName = "Rotation (in Degrees)", MinValue = 0, MaxValue = 360, StepFrequency = 1f, Value = _mainImage.RotationAngleInDegrees });
            list.Add(new TransformPropertyModel(ScaleXAction) { PropertyName = "Scale - X", MinValue = 0, MaxValue = 3, StepFrequency = 0.01f, Value = _mainImage.Scale.X });
            list.Add(new TransformPropertyModel(ScaleYAction) { PropertyName = "Scale - Y", MinValue = 0, MaxValue = 3, StepFrequency = 0.01f, Value = _mainImage.Scale.Y });
            list.Add(new TransformPropertyModel(OffsetXAction) { PropertyName = "Offset - X", MinValue = -200, MaxValue = 200, StepFrequency = 1f, Value = _mainImage.Offset.X });
            list.Add(new TransformPropertyModel(OffsetYAction) { PropertyName = "Offset - Y", MinValue = -200, MaxValue = 200, StepFrequency = 1f, Value = _mainImage.Offset.Y });

            XamlItemsControl.ItemsSource = list;

        }
        void InitNewComposition()
        {
            _compositor = new Compositor();

            _root = _compositor.CreateContainerVisual();

            _compositionTarget = _compositor.CreateTargetForCurrentView();
            _compositionTarget.Root = _root;

            CreateChildElement();
        }
Beispiel #27
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();
        }
        public PerspectivePanel()
        {
            m_rootVisual = ElementCompositionPreview.GetElementVisual(this as UIElement);
            m_compositor = m_rootVisual.Compositor;

            m_rootVisual.Properties.InsertScalar(PerspectiveDepthProperty, 0);
            m_rootVisual.Properties.InsertVector2(PerspectiveOriginPercentProperty, new Vector2(0.5f, 0.5f));

            this.Loading += OnLoading;
            this.Unloaded += OnUnloaded;
        }
        public virtual void InitializeComposition(Vector2 bounds)
        {
            Visual = MainElement.GetContainerVisual();
            Compositor = Visual.Compositor;

            float halfwidth = (float)MainElement.Width / 2.0f;
            float halfheight = (float)MainElement.Height / 2.0f;

            Visual.CenterPoint = new Vector3(halfwidth, halfwidth, 0);
            UpdateComposition(bounds);
        }
        public void SetupBlur()
        {
            _rootVisual = ElementCompositionPreview.GetElementVisual(this as UIElement);
            _compositor = _rootVisual.Compositor;

            // If the Compositor.CreateBackdropBrush method exists, then set up the blur.
            if (ApiInformation.IsMethodPresent(_compositor.GetType().ToString(), "CreateBackdropBrush"))
            {
                _destinationEffectsPresent = true;
                SetupDestinationEffect(_compositor);
            }
        }
Beispiel #31
0
 public BarBrushHelper(Compositor c)
 {
     compositor = c;
     rand       = new Random();
 }
        /// <summary>
        /// Creates a CompositionExpression expression for 'c =&gt; c.FinalValue' for the given type
        /// </summary>
        /// <typeparam name="T">Type of the CompositionExpression Expression</typeparam>
        /// <param name="compositor">Compositor</param>
        /// <returns>Expression&lt;CompositionExpression&lt;T&gt;&gt;</returns>
        public static Expression <CompositionExpression <T> > CreateFinalValueExpression <T>(this Compositor compositor)
        {
            Expression <CompositionExpression <T> > expression = c => c.FinalValue;

            return(expression);
        }
Beispiel #33
0
 private void InitializeCompositor()
 {
     _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
 }
        public DialogPage()
        {
            InitializeComponent();
            DataContext = UnigramContainer.Current.ResolveType <DialogViewModel>();

            //NavigationCacheMode = NavigationCacheMode.Required;

            ViewModel.TextField = TextField;

            CheckMessageBoxEmpty();

            ViewModel.PropertyChanged += OnPropertyChanged;

            TextField.LostFocus += TextField_LostFocus;

            lvDialogs.RegisterPropertyChangedCallback(ListViewBase.SelectionModeProperty, List_SelectionModeChanged);

            _messageVisual = ElementCompositionPreview.GetElementVisual(TextField);
            _ellipseVisual = ElementCompositionPreview.GetElementVisual(Ellipse);
            _elapsedVisual = ElementCompositionPreview.GetElementVisual(ElapsedPanel);
            _slideVisual   = ElementCompositionPreview.GetElementVisual(SlidePanel);
            _rootVisual    = ElementCompositionPreview.GetElementVisual(TextArea);
            _compositor    = _slideVisual.Compositor;

            _ellipseVisual.CenterPoint = new Vector3(48);
            _ellipseVisual.Scale       = new Vector3(0);

            _rootVisual.Clip = _compositor.CreateInsetClip(0, -100, 0, 0);

            _elapsedTimer          = new DispatcherTimer();
            _elapsedTimer.Interval = TimeSpan.FromMilliseconds(100);
            _elapsedTimer.Tick    += (s, args) =>
            {
                ElapsedLabel.Text = btnVoiceMessage.Elapsed.ToString("m\\:ss\\.ff");
            };

            //if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "SetImplicitShowAnimation"))
            //{
            //    var visual = ElementCompositionPreview.GetElementVisual(Header);
            //    visual.Clip = Window.Current.Compositor.CreateInsetClip();

            //    var showShowAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
            //    showShowAnimation.InsertKeyFrame(0.0f, new Vector3(0, -48, 0));
            //    showShowAnimation.InsertKeyFrame(1.0f, new Vector3());
            //    showShowAnimation.Target = nameof(Visual.Offset);
            //    showShowAnimation.Duration = TimeSpan.FromMilliseconds(400);

            //    var showHideAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
            //    showHideAnimation.InsertKeyFrame(0.0f, new Vector3());
            //    showHideAnimation.InsertKeyFrame(1.0f, new Vector3(0, 48, 0));
            //    showHideAnimation.Target = nameof(Visual.Offset);
            //    showHideAnimation.Duration = TimeSpan.FromMilliseconds(400);

            //    var hideHideAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
            //    hideHideAnimation.InsertKeyFrame(0.0f, new Vector3());
            //    hideHideAnimation.InsertKeyFrame(1.0f, new Vector3(0, -48, 0));
            //    hideHideAnimation.Target = nameof(Visual.Offset);
            //    hideHideAnimation.Duration = TimeSpan.FromMilliseconds(400);

            //    var hideShowAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
            //    hideShowAnimation.InsertKeyFrame(0.0f, new Vector3(0, 48, 0));
            //    hideShowAnimation.InsertKeyFrame(1.0f, new Vector3());
            //    hideShowAnimation.Target = nameof(Visual.Offset);
            //    hideShowAnimation.Duration = TimeSpan.FromMilliseconds(400);

            //    ElementCompositionPreview.SetImplicitShowAnimation(ManagePanel, showShowAnimation);
            //    ElementCompositionPreview.SetImplicitHideAnimation(ManagePanel, hideHideAnimation);
            //    ElementCompositionPreview.SetImplicitShowAnimation(InfoPanel, hideShowAnimation);
            //    ElementCompositionPreview.SetImplicitHideAnimation(InfoPanel, showHideAnimation);
            //}
        }
 public PointLightFollowTechnique(Compositor compositor) : base(compositor)
 {
 }
Beispiel #36
0
        public static CompositionTarget CreateDesktopWindowTarget(this Compositor compositor, IntPtr hwnd, bool isTopmost)
        {
            var desktopInterop = (ICompositorDesktopInterop)((object)compositor);

            return(desktopInterop.CreateDesktopWindowTarget(hwnd, isTopmost));
        }
 /// <summary>
 /// Creates a CompositionExpression expression for 'c =&gt; c.FinalValue' for the type Color
 /// </summary>
 /// <param name="compositor">Compositor</param>
 /// <returns>Expression&lt;CompositionExpression&lt;Color&gt;&gt;</returns>
 public static Expression <CompositionExpression <Color> > CreateColorFinalValueExpression(this Compositor compositor)
 {
     return(compositor.CreateFinalValueExpression <Color>());
 }
        public void Start(UIElement newParent, CompositionImage targetImage, ScrollViewer scrollViewer, UIElement animationTarget)
        {
            Visual transitionVisual = ElementCompositionPreview.GetElementChildVisual(_parent);

            ElementCompositionPreview.SetElementChildVisual(_parent, null);


            //
            // We need to reparent the transition visual under the new parent.  This is important to ensure
            // it's propertly clipped, etc.
            //

            GeneralTransform coordinate = newParent.TransformToVisual(_parent);
            Point            position   = coordinate.TransformPoint(new Point(0, 0));

            Vector3 currentOffset = transitionVisual.Offset;

            currentOffset.X        -= (float)position.X;
            currentOffset.Y        -= (float)position.Y;
            transitionVisual.Offset = currentOffset;

            _parent      = newParent;
            _targetImage = targetImage;

            // Move the transition visual to it's new parent
            ElementCompositionPreview.SetElementChildVisual(_parent, transitionVisual);

            // Hide the target Image now since the handoff visual is still transitioning
            targetImage.Opacity = 0f;

            // Load image if necessary
            _imageLoaded = targetImage.IsContentLoaded;
            if (!_imageLoaded)
            {
                targetImage.ImageOpened += CompositionImage_ImageOpened;
            }

            //
            // Create a scoped batch around the animations.  When the batch completes, we know the animations
            // have finished and we can cleanup the transition related objects.
            //

            Compositor compositor = transitionVisual.Compositor;

            _scopeBatch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            //
            // Determine the offset between the parent and the target UIElement.  This will be used to calculate the
            // target position we are animating to.
            //

            coordinate = targetImage.TransformToVisual(_parent);
            position   = coordinate.TransformPoint(new Point(0, 0));

            TimeSpan totalDuration = TimeSpan.FromMilliseconds(1000);
            Vector3KeyFrameAnimation offsetAnimation = compositor.CreateVector3KeyFrameAnimation();

            if (scrollViewer != null)
            {
                CompositionPropertySet scrollProperties = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);

                // Include the scroller offset as that is a factor
                position.X += scrollViewer.HorizontalOffset;
                position.Y += scrollViewer.VerticalOffset;


                //
                // Since the target position is relative to the target UIElement which can move, we need to construct
                // an expression to bind the target's position to the end position of our animation.
                //

                string expression = "Vector3(scrollingProperties.Translation.X, scrollingProperties.Translation.Y, 0) + itemOffset";
                offsetAnimation.InsertExpressionKeyFrame(1f, expression);
                offsetAnimation.SetReferenceParameter("scrollingProperties", scrollProperties);
                offsetAnimation.SetVector3Parameter("itemOffset", new Vector3((float)position.X, (float)position.Y, 0));
                offsetAnimation.Duration = totalDuration;
            }
            else
            {
                offsetAnimation.InsertKeyFrame(1, new Vector3((float)position.X, (float)position.Y, 0));
                offsetAnimation.Duration = totalDuration;
            }

            // Create size animation to change size of the visual
            Vector2KeyFrameAnimation sizeAnimation = compositor.CreateVector2KeyFrameAnimation();

            sizeAnimation.InsertKeyFrame(1f, new Vector2((float)targetImage.ActualWidth, (float)targetImage.ActualHeight));
            sizeAnimation.Duration = totalDuration;

            // Create the fade in animation for the other page content
            if (animationTarget != null)
            {
                Visual fadeVisual = ElementCompositionPreview.GetElementVisual(animationTarget);
                ScalarKeyFrameAnimation fadeIn = compositor.CreateScalarKeyFrameAnimation();
                fadeIn.InsertKeyFrame(0f, 0.0f);
                fadeIn.InsertKeyFrame(1f, 1.0f);
                fadeIn.Duration = totalDuration;
                fadeVisual.StartAnimation("Opacity", fadeIn);
            }

            //Start Animations
            _sprite.StartAnimation("Size", sizeAnimation);
            _sprite.StartAnimation("Offset", offsetAnimation);

            //Scoped batch completed event
            _scopeBatch.Completed += ScopeBatch_Completed;
            _scopeBatch.End();

            // Clear the flag
            _animationCompleted = false;
        }
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            _compositor    = ElementCompositionPreview.GetElementVisual(this).Compositor;
            _generator     = CompositionGeneratorFactory.GetCompositionGenerator(_compositor);
            _backdropBrush = _compositor.CreateBackdropBrush();

            _width  = 300f;
            _height = 300f;
            // Create the combined geometry
            var ellipse1 = CanvasGeometry.CreateEllipse(_generator.Device, _width / 2, _height / 2, 0.45f * _width, 0.225f * _height);
            var ellipse2 = CanvasGeometry.CreateEllipse(_generator.Device, _width / 2, _height / 2, 0.225f * _width, 0.45f * _height);

            _combinedGeometry = ellipse1.CombineWith(ellipse2, Matrix3x2.Identity, CanvasGeometryCombine.Union);

            // Create the container to host the visuals
            var container1 = _compositor.CreateContainerVisual();

            container1.Size = new Vector2(CompositionGrid1.ActualWidth.Single(), CompositionGrid1.ActualHeight.Single());

            // Background Visual
            _bgVisual1        = _compositor.CreateSpriteVisual();
            _bgVisual1.Size   = new Vector2(_width * 0.45f, _height * 0.45f);
            _bgVisual1.Offset = new Vector3(((CompositionGrid1.ActualWidth - _width) / 2).Single(),
                                            ((CompositionGrid1.ActualHeight - _height) / 2).Single(), 0);

            _bgVisual1.Brush = _compositor.CreateColorBrush(Colors.DarkOrange);

            container1.Children.InsertAtBottom(_bgVisual1);

            // Create custom shaped visual using CompositionMaskBrush
            _visual1        = _compositor.CreateSpriteVisual();
            _visual1.Size   = new Vector2(_width, _height);
            _visual1.Offset = new Vector3(((CompositionGrid1.ActualWidth - _width) / 2).Single(),
                                          ((CompositionGrid1.ActualHeight - _height) / 2).Single(), 0);
            // Create the CompositionMask
            var ellipseGeometry = CanvasGeometry.CreateEllipse(_generator.Device, _width / 2, _height / 2, 0.4f * _width, 0.4f * _height);
            var compositionMask = _generator.CreateMask(_visual1.Size.ToSize(), ellipseGeometry);

            // Create Masked BackdropBrush from CompositionMask
            _visual1.Brush = _compositor.CreateMaskedBackdropBrush(compositionMask, Colors.AntiqueWhite, 30f, _backdropBrush);

            container1.Children.InsertAtTop(_visual1);

            ElementCompositionPreview.SetElementChildVisual(CompositionGrid1, container1);

            // Initialize the visuals for the Animated Canvas
            // Create the container to host the visuals
            var container2 = _compositor.CreateContainerVisual();

            container2.Size = new Vector2(CompositionGrid2.ActualWidth.Single(), CompositionGrid2.ActualHeight.Single());

            // Background Visual
            _bgVisual2        = _compositor.CreateSpriteVisual();
            _bgVisual2.Size   = new Vector2(_width * Factor, _height * Factor);
            _bgVisual2.Offset = new Vector3(((CompositionGrid2.ActualWidth - (_width * Factor)) / 2).Single(),
                                            ((CompositionGrid2.ActualHeight - (_height * Factor)) / 2).Single(), 0);

            //var radians = ((45f * Math.PI) / 180).Single();
            //var bgGeometry = _combinedGeometry.Transform(Matrix3x2.CreateRotation(radians, new Vector2(_width / 2, _height / 2)));
            //var bgMask = await _generator.CreateMaskAsync(_bgVisual2.Size.ToSize(), bgGeometry, Colors.DarkRed);
            //_bgVisual2.Brush = _compositor.CreateSurfaceBrush(bgMask.Surface);
            _bgVisual2.Brush = _compositor.CreateColorBrush(Colors.LawnGreen);

            container2.Children.InsertAtBottom(_bgVisual2);

            // Animated Visual
            _animatedVisual        = _compositor.CreateSpriteVisual();
            _animatedVisual.Size   = new Vector2(_width, _height);
            _animatedVisual.Offset = new Vector3(((CompositionGrid2.ActualWidth - _width) / 2).Single(),
                                                 ((CompositionGrid2.ActualHeight - _height) / 2).Single(), 0);
            // Create the Excluded geometry
            _outerGeometry = CanvasGeometry.CreateRectangle(_generator.Device, 0, 0, _width, _height);
            var excludedGeometry = _outerGeometry.CombineWith(_combinedGeometry, Matrix3x2.Identity, CanvasGeometryCombine.Exclude);

            // Create the CompositionMask
            _animatedCompositionMask = _generator.CreateMask(_animatedVisual.Size.ToSize(), excludedGeometry);
            var animBrush = _compositor.CreateMaskedBackdropBrush(_animatedCompositionMask, Colors.AntiqueWhite, 10f, _backdropBrush);

            _animatedVisual.Brush = animBrush;

            container2.Children.InsertAtTop(_animatedVisual);

            ElementCompositionPreview.SetElementChildVisual(CompositionGrid2, container2);
        }
 /// <inheritdoc/>
 protected override KeyFrameAnimation GetTypedAnimationFromCompositor(Compositor compositor)
 {
     return(compositor.CreateScalarKeyFrameAnimation());
 }
Beispiel #41
0
 private void InitializeComposition()
 {
     _compositor       = ElementCompositionPreview.GetElementVisual(this).Compositor;
     _drawerVisual     = ElementCompositionPreview.GetElementVisual(_drawerContentPresenter);
     _drawerMaskVisual = ElementCompositionPreview.GetElementVisual(_drawerMaskBorder);
 }
 /// <summary>
 /// Creates a CompositionExpression expression for 'c =&gt; c.FinalValue' for the type Vector4
 /// </summary>
 /// <param name="compositor">Compositor</param>
 /// <returns>Expression&lt;CompositionExpression&lt;Vector4&gt;&gt;</returns>
 public static Expression <CompositionExpression <Vector4> > CreateVector4FinalValueExpression(this Compositor compositor)
 {
     return(compositor.CreateFinalValueExpression <Vector4>());
 }
 /// <summary>
 /// Creates a CompositionExpression expression for 'c =&gt; c.FinalValue' for the type Scalar
 /// </summary>
 /// <param name="compositor">Compositor</param>
 /// <returns>Expression&lt;CompositionExpression&lt;Scalar&gt;&gt;</returns>
 public static Expression <CompositionExpression <float> > CreateScalarFinalValueExpression(this Compositor compositor)
 {
     return(compositor.CreateFinalValueExpression <float>());
 }
 public ICompositionSurface CreateSurface(Compositor compositor)
 {
     return(CanvasComposition.CreateCompositionSurfaceForSwapChain(compositor, _swapChain));
 }
Beispiel #45
0
 public IAnimatedVisual TryCreateAnimatedVisual(Compositor compositor, out object diagnostics)
 {
     diagnostics = new object(); return(null);
 }
Beispiel #46
0
        public VoIPPage(IProtoService protoService, ICacheService cacheService, IEventAggregator aggregator, Call call, VoIPControllerWrapper controller, DateTime started)
        {
            this.InitializeComponent();

            _protoService = protoService;
            _cacheService = cacheService;
            _aggregator   = aggregator;

            _durationTimer          = new DispatcherTimer();
            _durationTimer.Interval = TimeSpan.FromMilliseconds(500);
            _durationTimer.Tick    += DurationTimer_Tick;

            _debugTimer          = new DispatcherTimer();
            _debugTimer.Interval = TimeSpan.FromMilliseconds(500);
            _debugTimer.Tick    += DebugTimer_Tick;

            #region Reset

            LargeEmoji0.Source = null;
            LargeEmoji1.Source = null;
            LargeEmoji2.Source = null;
            LargeEmoji3.Source = null;

            #endregion

            #region Composition

            _descriptionVisual = ElementCompositionPreview.GetElementVisual(DescriptionLabel);
            _largeVisual       = ElementCompositionPreview.GetElementVisual(LargePanel);
            _compositor        = _largeVisual.Compositor;

            var graphicsEffect = new GaussianBlurEffect
            {
                Name       = "Blur",
                BlurAmount = 0,
                BorderMode = EffectBorderMode.Hard,
                Source     = new CompositionEffectSourceParameter("backdrop")
            };

            var effectFactory = _compositor.CreateEffectFactory(graphicsEffect, new[] { "Blur.BlurAmount" });
            var effectBrush   = effectFactory.CreateBrush();
            var backdrop      = _compositor.CreateBackdropBrush();
            effectBrush.SetSourceParameter("backdrop", backdrop);

            _blurBrush        = effectBrush;
            _blurVisual       = _compositor.CreateSpriteVisual();
            _blurVisual.Brush = _blurBrush;

            // Why does this crashes due to an access violation exception on certain devices?
            ElementCompositionPreview.SetElementChildVisual(BlurPanel, _blurVisual);

            #endregion

            var titleBar = ApplicationView.GetForCurrentView().TitleBar;
            titleBar.ButtonBackgroundColor         = Colors.Transparent;
            titleBar.ButtonForegroundColor         = Colors.White;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            titleBar.ButtonInactiveForegroundColor = Colors.White;

            Window.Current.SetTitleBar(BlurPanel);

            if (call != null)
            {
                Update(call, started);
            }

            if (controller != null)
            {
                Connect(controller);
            }
        }
Beispiel #47
0
        public static ICompositionSurface CreateCompositionSurfaceForSwapChain(this Compositor compositor, SharpDX.DXGI.SwapChain1 swapChain)
        {
            var interop = (ICompositorInterop)(object)compositor;

            return(interop.CreateCompositionSurfaceForSwapChain(swapChain.NativePointer));
        }
Beispiel #48
0
 /// <summary>
 /// Gets a <see cref="CompositionAnimation"/> that can be used on the Composition layer
 /// </summary>
 /// <param name="compositor">The <see cref="Compositor"/> to use to create the animation</param>
 /// <returns><see cref="CompositionAnimation"/></returns>
 public abstract CompositionAnimation GetCompositionAnimation(Compositor compositor);
 public ImageListControl()
 {
     this.InitializeComponent();
     this._compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
     this._listVisual = ElementCompositionPreview.GetElementVisual(ImageGridView);
 }
 /// <summary>
 /// Creates a CompositionExpression expression for 'c =&gt; c.StartingValue' for the type Color
 /// </summary>
 /// <param name="compositor">Compositor</param>
 /// <returns>Expression&lt;CompositionExpression&lt;Color&gt;&gt;</returns>
 public static Expression <CompositionExpression <Color> > CreateColorStartingValueExpression(this Compositor compositor)
 {
     return(compositor.CreateStartingValueExpression <Color>());
 }
Beispiel #51
0
        public UWPShell(LayoutSetting layoutSetting, ITextStreamProvider gameProvider, LocaleSetting localeSetting, ILocalizationService localizationService, Compositor compositor)
            : base(localizationService, compositor)
        {
            this.layoutSetting       = layoutSetting;
            this.gameProvider        = gameProvider;
            this.localizationService = localizationService;

            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = localeSetting.Language.Value;
        }
 public SpotLightTechnique(Compositor compositor) : base(compositor)
 {
 }
 public DesaturateTechnique(Compositor compositor) : base(compositor)
 {
 }
 public ExposureTechnique(Compositor compositor) : base(compositor)
 {
 }
 public EffectTechniques(Compositor compositor)
 {
     _compositor = compositor;
 }
 /// <summary>
 /// Creates a CompositionExpression expression for 'c =&gt; c.StartingValue' for the type Vector3
 /// </summary>
 /// <param name="compositor">Compositor</param>
 /// <returns>Expression&lt;CompositionExpression&lt;Vector3&gt;&gt;</returns>
 public static Expression <CompositionExpression <Vector3> > CreateVector3StartingValueExpression(this Compositor compositor)
 {
     return(compositor.CreateStartingValueExpression <Vector3>());
 }
 public BlurTechnique(Compositor compositor) : base(compositor)
 {
 }
 protected override void OnConnected()
 {
     _compositor = Window.Current.Compositor;
     BuildBrush();
 }
 /// <summary>
 /// Creates a CompositionExpression expression for 'c =&gt; c.FinalValue' for the type Quaternion
 /// </summary>
 /// <param name="compositor">Compositor</param>
 /// <returns>Expression&lt;CompositionExpression&lt;Quaternion&gt;&gt;</returns>
 public static Expression <CompositionExpression <Quaternion> > CreateQuaternionFinalValueExpression(this Compositor compositor)
 {
     return(compositor.CreateFinalValueExpression <Quaternion>());
 }
 public BlurPlayground()
 {
     _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
     this.InitializeComponent();
 }