当前位置: 首页>>代码示例>>C#>>正文


C# Compositor类代码示例

本文整理汇总了C#中Compositor的典型用法代码示例。如果您正苦于以下问题:C# Compositor类的具体用法?C# Compositor怎么用?C# Compositor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Compositor类属于命名空间,在下文中一共展示了Compositor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transform

        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();
        }
开发者ID:mrdrbob,项目名称:NFountain,代码行数:35,代码来源:PdfWriter.cs

示例2: DetailsPage

        public DetailsPage()
        {
            this.InitializeComponent();

           _mainGridVisual = ElementCompositionPreview.GetElementVisual(Window.Current.Content) as ContainerVisual;
            _compositor = _mainGridVisual.Compositor;
        }
开发者ID:HimanshPal,项目名称:composition,代码行数:7,代码来源:DetailsPage.xaml.cs

示例3: Clock_Loaded

        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();
        }
开发者ID:x01673,项目名称:UWP-Composition-API-Clock,代码行数:60,代码来源:ImageClock.xaml.cs

示例4: Page_Loaded

        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();

        }
开发者ID:chenjianwp,项目名称:WindowsUIDevLabs,代码行数:33,代码来源:ForegroundFocusEffects.xaml.cs

示例5: SetupDestinationEffect

        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);
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:32,代码来源:Scenario2_Conditional.xaml.cs

示例6: SamplePage_Loaded

        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;
        }
开发者ID:clarkezone,项目名称:composition,代码行数:29,代码来源:ShadowPlayground.xaml.cs

示例7: createOffsetAnimation

 private static KeyFrameAnimation createOffsetAnimation(Compositor compositor)
 {
     Vector3KeyFrameAnimation kf = compositor.CreateVector3KeyFrameAnimation();
     kf.InsertExpressionKeyFrame(1.0f, "FinalValue");
     kf.Duration = TimeSpan.FromSeconds(0.9);
     return kf;
 }
开发者ID:clarkezone,项目名称:composition,代码行数:7,代码来源:UIElementExtensionMethods.cs

示例8: Parallax_Expression

        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;
        }
开发者ID:RudyChen,项目名称:composition,代码行数:28,代码来源:MainPage.xaml.cs

示例9: ConnectedAnimationSample

        public ConnectedAnimationSample()
        {
            InitializeComponent();

            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            CustomParametersCheckBox.IsChecked = _usingCustomParameters;
        }
开发者ID:chenjianwp,项目名称:WindowsUIDevLabs,代码行数:7,代码来源:ConnectedAnimationSample.xaml.cs

示例10: WriteCompositor

        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");
        }
开发者ID:mrdrbob,项目名称:NFountain,代码行数:27,代码来源:PdfOutput.cs

示例11: InitializeComposition

        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();
        }
开发者ID:blinds52,项目名称:intense,代码行数:28,代码来源:MainView.cs

示例12: CompositionDevice

        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>();
        }
开发者ID:fealty,项目名称:Frost,代码行数:33,代码来源:CompositionDevice.cs

示例13: SetupVisuals

        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;
        }
开发者ID:RudyChen,项目名称:composition,代码行数:27,代码来源:MainPage.xaml.cs

示例14: Page_Loaded

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            _image = ElementCompositionPreview.GetElementVisual(Clock);
            _root = ElementCompositionPreview.GetElementVisual(Root);
            _compositor = _image.Compositor;

            ConfigureInteractionTracker();
        }
开发者ID:flying19880517,项目名称:composition,代码行数:8,代码来源:Curtain.cs

示例15: CompImage_Loading

        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);
        }
开发者ID:HimanshPal,项目名称:composition,代码行数:8,代码来源:CompositionImage.cs


注:本文中的Compositor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。