本文整理汇总了C#中Compositor.CreateInsetClip方法的典型用法代码示例。如果您正苦于以下问题:C# Compositor.CreateInsetClip方法的具体用法?C# Compositor.CreateInsetClip怎么用?C# Compositor.CreateInsetClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compositor
的用法示例。
在下文中一共展示了Compositor.CreateInsetClip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SamplePage_Loaded
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;
}