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.
|
|
|
|
|
2018-09-13 18:31:53 +03:00
|
|
|
using System;
|
|
|
|
using System.Windows;
|
|
|
|
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
|
2018-10-21 07:03:54 +03:00
|
|
|
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
2018-11-27 09:56:15 +03:00
|
|
|
using windows = Windows;
|
2018-09-13 18:31:53 +03:00
|
|
|
|
|
|
|
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"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </summary>
|
2019-01-04 04:52:26 +03:00
|
|
|
#pragma warning disable CA1812 // Avoid uninstantiated internal classes
|
2018-10-25 01:42:30 +03:00
|
|
|
internal class SwapChainPanel : WindowsXamlHostBase
|
2019-01-04 04:52:26 +03:00
|
|
|
#pragma warning restore CA1812 // Avoid uninstantiated internal classes
|
2018-09-13 18:31:53 +03:00
|
|
|
{
|
2018-11-27 09:56:15 +03:00
|
|
|
internal windows.UI.Xaml.Controls.SwapChainPanel UwpControl => ChildInternal as windows.UI.Xaml.Controls.SwapChainPanel;
|
2018-09-13 18:31:53 +03:00
|
|
|
|
|
|
|
/// <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"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </summary>
|
|
|
|
public SwapChainPanel()
|
2018-11-27 09:56:15 +03:00
|
|
|
: this(typeof(windows.UI.Xaml.Controls.SwapChainPanel).FullName)
|
2018-09-13 18:31:53 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <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"/>.
|
2018-09-13 18:31:53 +03:00
|
|
|
/// 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);
|
2018-09-13 18:31:53 +03:00
|
|
|
|
|
|
|
// 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);
|
2018-09-13 18:31:53 +03:00
|
|
|
UwpControl.CompositionScaleChanged += OnCompositionScaleChanged;
|
|
|
|
|
|
|
|
base.OnInitialized(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2018-11-27 09:56:15 +03:00
|
|
|
/// Gets <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleXProperty"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </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"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </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"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </summary>
|
|
|
|
/// <returns>CoreIndependentInputSource</returns>
|
2018-11-27 09:56:15 +03:00
|
|
|
public CoreIndependentInputSource CreateCoreIndependentInputSource(CoreInputDeviceTypes deviceTypes) => UwpControl.CreateCoreIndependentInputSource((windows.UI.Core.CoreInputDeviceTypes)deviceTypes);
|
2018-09-13 18:31:53 +03:00
|
|
|
|
|
|
|
/// <summary>
|
2018-11-27 09:56:15 +03:00
|
|
|
/// Gets <see cref="windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleX"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </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"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </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"/>
|
2018-09-13 18:31:53 +03:00
|
|
|
/// </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)
|
2018-09-13 18:31:53 +03:00
|
|
|
{
|
|
|
|
this.CompositionScaleChanged?.Invoke(this, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|