Microsoft.Toolkit.Win32/Microsoft.Toolkit.Wpf.UI.Co.../SwapChainPanel/SwapChainPanel.cs

111 строки
5.8 KiB
C#
Исходник Обычный вид История

2019-02-23 02:50:03 +03:00
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Windows;
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
using Microsoft.Toolkit.Wpf.UI.XamlHost;
2018-11-27 09:56:15 +03:00
using windows = Windows;
namespace Microsoft.Toolkit.Wpf.UI.Controls
{
/// <summary>
2018-11-27 09:56:15 +03:00
/// Wpf-enabled wrapper for <see cref="windows.UI.Xaml.Controls.SwapChainPanel"/>
/// </summary>
#pragma warning disable CA1812 // Avoid uninstantiated internal classes
2018-10-25 01:42:30 +03:00
internal class SwapChainPanel : WindowsXamlHostBase
#pragma warning restore CA1812 // Avoid uninstantiated internal classes
{
2018-11-27 09:56:15 +03:00
internal windows.UI.Xaml.Controls.SwapChainPanel UwpControl => ChildInternal as windows.UI.Xaml.Controls.SwapChainPanel;
/// <summary>
/// Initializes a new instance of the <see cref="SwapChainPanel"/> class, a
2018-11-27 09:56:15 +03:00
/// Wpf-enabled wrapper for <see cref="windows.UI.Xaml.Controls.SwapChainPanel"/>
/// </summary>
public SwapChainPanel()
2018-11-27 09:56:15 +03:00
: this(typeof(windows.UI.Xaml.Controls.SwapChainPanel).FullName)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SwapChainPanel"/> class, a
2018-11-27 09:56:15 +03:00
/// Wpf-enabled wrapper for <see cref="windows.UI.Xaml.Controls.SwapChainPanel"/>.
/// Intended for internal framework use only.
/// </summary>
public SwapChainPanel(string typeName)
: base(typeName)
{
}
protected override void OnInitialized(EventArgs e)
{
// Bind dependency properties across controls
// properties of FrameworkElement
2018-11-27 09:56:15 +03:00
Bind(nameof(Style), StyleProperty, windows.UI.Xaml.Controls.SwapChainPanel.StyleProperty);
Bind(nameof(MaxHeight), MaxHeightProperty, windows.UI.Xaml.Controls.SwapChainPanel.MaxHeightProperty);
Bind(nameof(FlowDirection), FlowDirectionProperty, windows.UI.Xaml.Controls.SwapChainPanel.FlowDirectionProperty);
Bind(nameof(Margin), MarginProperty, windows.UI.Xaml.Controls.SwapChainPanel.MarginProperty);
Bind(nameof(HorizontalAlignment), HorizontalAlignmentProperty, windows.UI.Xaml.Controls.SwapChainPanel.HorizontalAlignmentProperty);
Bind(nameof(VerticalAlignment), VerticalAlignmentProperty, windows.UI.Xaml.Controls.SwapChainPanel.VerticalAlignmentProperty);
Bind(nameof(MinHeight), MinHeightProperty, windows.UI.Xaml.Controls.SwapChainPanel.MinHeightProperty);
Bind(nameof(Height), HeightProperty, windows.UI.Xaml.Controls.SwapChainPanel.HeightProperty);
Bind(nameof(MinWidth), MinWidthProperty, windows.UI.Xaml.Controls.SwapChainPanel.MinWidthProperty);
Bind(nameof(MaxWidth), MaxWidthProperty, windows.UI.Xaml.Controls.SwapChainPanel.MaxWidthProperty);
Bind(nameof(UseLayoutRounding), UseLayoutRoundingProperty, windows.UI.Xaml.Controls.SwapChainPanel.UseLayoutRoundingProperty);
Bind(nameof(Name), NameProperty, windows.UI.Xaml.Controls.SwapChainPanel.NameProperty);
Bind(nameof(Tag), TagProperty, windows.UI.Xaml.Controls.SwapChainPanel.TagProperty);
Bind(nameof(DataContext), DataContextProperty, windows.UI.Xaml.Controls.SwapChainPanel.DataContextProperty);
Bind(nameof(Width), WidthProperty, windows.UI.Xaml.Controls.SwapChainPanel.WidthProperty);
// SwapChainPanel specific properties
2018-11-27 09:56:15 +03:00
Bind(nameof(CompositionScaleX), CompositionScaleXProperty, windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleXProperty);
Bind(nameof(CompositionScaleY), CompositionScaleYProperty, windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleYProperty);
UwpControl.CompositionScaleChanged += OnCompositionScaleChanged;
base.OnInitialized(e);
}
/// <summary>
2018-11-27 09:56:15 +03:00
/// Gets <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleXProperty"/>
/// </summary>
public static DependencyProperty CompositionScaleXProperty { get; } = DependencyProperty.Register(nameof(CompositionScaleX), typeof(float), typeof(SwapChainPanel));
/// <summary>
2018-11-27 09:56:15 +03:00
/// Gets <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleYProperty"/>
/// </summary>
public static DependencyProperty CompositionScaleYProperty { get; } = DependencyProperty.Register(nameof(CompositionScaleY), typeof(float), typeof(SwapChainPanel));
/// <summary>
2018-11-27 09:56:15 +03:00
/// <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CreateCoreIndependentInputSource"/>
/// </summary>
/// <returns>CoreIndependentInputSource</returns>
2018-11-27 09:56:15 +03:00
public CoreIndependentInputSource CreateCoreIndependentInputSource(CoreInputDeviceTypes deviceTypes) => UwpControl.CreateCoreIndependentInputSource((windows.UI.Core.CoreInputDeviceTypes)deviceTypes);
/// <summary>
2018-11-27 09:56:15 +03:00
/// Gets <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleX"/>
/// </summary>
public float CompositionScaleX
{
get => (float)GetValue(CompositionScaleXProperty);
}
/// <summary>
2018-11-27 09:56:15 +03:00
/// Gets <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleY"/>
/// </summary>
public float CompositionScaleY
{
get => (float)GetValue(CompositionScaleYProperty);
}
/// <summary>
2018-11-27 09:56:15 +03:00
/// <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleChanged"/>
/// </summary>
public event EventHandler<object> CompositionScaleChanged = (sender, args) => { };
2018-11-27 09:56:15 +03:00
private void OnCompositionScaleChanged(windows.UI.Xaml.Controls.SwapChainPanel sender, object args)
{
this.CompositionScaleChanged?.Invoke(this, args);
}
}
}