本文整理汇总了C#中CanvasDevice.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasDevice.Dispose方法的具体用法?C# CanvasDevice.Dispose怎么用?C# CanvasDevice.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CanvasDevice
的用法示例。
在下文中一共展示了CanvasDevice.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStructureChanged
private static async Task OnStructureChanged(DependencyObject d)
{
var c = (Rating)d;
if (c.EmptyImage == null)
{
c.EmptyImage = new Uri("ms-appx:///XamlBrewer.Uwp.Rating/Assets/defaultStar_empty.png");
}
if (c.FilledImage == null)
{
c.FilledImage = new Uri("ms-appx:///XamlBrewer.Uwp.Rating/Assets/defaultStar_full.png");
}
if ((c.StepFrequency <= 0) || (c.StepFrequency > 1))
{
c.StepFrequency = 1;
}
var panel = c.GetTemplateChild(ItemsPartName) as StackPanel;
if (panel != null)
{
// Load images.
var root = panel.GetVisual();
var compositor = root.Compositor;
var canvasDevice = new CanvasDevice();
var compositionDevice = CanvasComposition.CreateCompositionGraphicsDevice(compositor, canvasDevice);
var rightPadding = c.ItemPadding;
c.Clips.Clear();
for (int i = 0; i < c.Maximum; i++)
{
if (i == c.Maximum - 1)
{
rightPadding = 0;
}
// Create grid.
var grid = new Grid
{
Height = c.ItemHeight,
Width = c.ItemHeight,
Margin = new Thickness(0, 0, rightPadding, 0)
};
panel.Children.Add(grid);
var gridRoot = grid.GetVisual();
// Empty image.
var surface = await LoadFromUri(canvasDevice, compositionDevice, c.EmptyImage, new Size(c.ItemHeight, c.ItemHeight));
var emptyBrush = compositor.CreateSurfaceBrush(surface);
var spriteVisual = compositor.CreateSpriteVisual();
spriteVisual.Size = new Vector2(c.ItemHeight, c.ItemHeight);
gridRoot.Children.InsertAtTop(spriteVisual);
spriteVisual.Brush = emptyBrush;
// Filled image.
surface = await LoadFromUri(canvasDevice, compositionDevice, c.FilledImage, new Size(c.ItemHeight, c.ItemHeight));
var fullBrush = compositor.CreateSurfaceBrush(surface);
spriteVisual = compositor.CreateSpriteVisual();
spriteVisual.Size = new Vector2(c.ItemHeight, c.ItemHeight);
var clip = compositor.CreateInsetClip();
c.Clips.Add(clip);
spriteVisual.Clip = clip;
gridRoot.Children.InsertAtTop(spriteVisual);
spriteVisual.Brush = fullBrush;
}
compositionDevice.Dispose();
canvasDevice.Dispose();
}
OnValueChanged(c);
}