本文整理汇总了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();
}
示例2: DetailsPage
public DetailsPage()
{
this.InitializeComponent();
_mainGridVisual = ElementCompositionPreview.GetElementVisual(Window.Current.Content) as ContainerVisual;
_compositor = _mainGridVisual.Compositor;
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例9: ConnectedAnimationSample
public ConnectedAnimationSample()
{
InitializeComponent();
_compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
CustomParametersCheckBox.IsChecked = _usingCustomParameters;
}
示例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");
}
示例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();
}
示例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>();
}
示例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;
}
示例14: Page_Loaded
private void Page_Loaded(object sender, RoutedEventArgs e)
{
_image = ElementCompositionPreview.GetElementVisual(Clock);
_root = ElementCompositionPreview.GetElementVisual(Root);
_compositor = _image.Compositor;
ConfigureInteractionTracker();
}
示例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);
}