Skip to content

Commit b774cf4

Browse files
niels9001Arlodotexe
authored andcommitted
Init
1 parent 56dff69 commit b774cf4

17 files changed

+1097
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@ECHO OFF
2+
3+
powershell ..\..\tooling\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
WinUI 2 under UWP uses TargetFramework uap10.0.*
3+
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
4+
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.
5+
6+
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
7+
8+
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
9+
For UWP / WinAppSDK / Uno packages, place the package references here.
10+
-->
11+
<Project>
12+
<!-- WinUI 2 / UWP -->
13+
<ItemGroup Condition="'$(IsUwp)' == 'true'">
14+
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
15+
</ItemGroup>
16+
17+
<!-- WinUI 2 / Uno -->
18+
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
19+
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
20+
</ItemGroup>
21+
22+
<!-- WinUI 3 / WinAppSdk -->
23+
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
24+
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
25+
</ItemGroup>
26+
27+
<!-- WinUI 3 / Uno -->
28+
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
29+
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
30+
</ItemGroup>
31+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
2+
<PropertyGroup>
3+
<ToolkitComponentName>LayoutTransformControl</ToolkitComponentName>
4+
</PropertyGroup>
5+
6+
<!-- Sets this up as a toolkit component's sample project -->
7+
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" />
8+
</Project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: LayoutTransformControl
3+
author: odonno
4+
description: The LayoutTransformControl is a control that support transformations on FrameworkElement as if applied by LayoutTransform.
5+
keywords: LayoutTransformControl, Control, Layout, RenderTransform, RotateTransform, ScaleTransform, SkewTransform, Transform
6+
dev_langs:
7+
- csharp
8+
category: Controls
9+
subcategory: Layout
10+
discussion-id: 0
11+
issue-id: 0
12+
---
13+
14+
# LayoutTransformControl
15+
16+
The [LayoutTransformControl](/dotnet/api/microsoft.toolkit.uwp.ui.controls.layouttransformcontrol) is a control that applies Matrix transformations on any `FrameworkElement` of your application.
17+
18+
The transformations that can be applied are one of the following:
19+
20+
* [RotateTransform](/uwp/api/windows.ui.xaml.media.rotatetransform)
21+
* [ScaleTransform](/uwp/api/windows.ui.xaml.media.scaletransform)
22+
* [SkewTransform](/uwp/api/windows.ui.xaml.media.skewtransform)
23+
* [MatrixTransform](/uwp/api/windows.ui.xaml.media.matrixtransform)
24+
* [TransformGroup](/uwp/api/windows.ui.xaml.media.transformgroup)
25+
26+
> [!Sample LayoutTransformControlSample]
27+
28+
## Syntax
29+
30+
```xaml
31+
<controls:LayoutTransformControl Background="Black"
32+
HorizontalAlignment="Center"
33+
VerticalAlignment="Center"
34+
RenderTransformOrigin="0.5,0.5">
35+
<controls:LayoutTransformControl.Transform>
36+
<RotateTransform Angle="90" />
37+
</controls:LayoutTransformControl.Transform>
38+
39+
<Border HorizontalAlignment="Center"
40+
VerticalAlignment="Center"
41+
BorderBrush="Red"
42+
BorderThickness="5">
43+
<Grid>
44+
<TextBlock Padding="10" Foreground="White" Text="This is a test message." />
45+
</Grid>
46+
</Border>
47+
</controls:LayoutTransformControl>
48+
```
49+
50+
## Properties
51+
52+
| Property | Type | Description |
53+
| -- | -- | -- |
54+
| Child | FrameworkElement | The content of the control that will receive matrix transformations |
55+
| Transform | Transform | The transformations to apply on the `Content`. It can be a single transformation like `RotateTransform`, `ScaleTransform` or `SkewTransform` or it can be a combo of multiple transformations using `TransformGroup` |
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<!-- 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. -->
2+
<Page x:Class="LayoutTransformControlExperiment.Samples.LayoutTransformControlSample"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:local="using:LayoutTransformControlExperiment.Samples"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d">
10+
11+
<Grid ColumnSpacing="24" RowSpacing="24">
12+
<Grid.Resources>
13+
<Style x:Key="BorderCardStyle"
14+
TargetType="Border">
15+
<Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
16+
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
17+
<Setter Property="BorderThickness" Value="1" />
18+
<Setter Property="Padding" Value="12" />
19+
<Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
20+
</Style>
21+
</Grid.Resources>
22+
<Grid.RowDefinitions>
23+
<RowDefinition />
24+
<RowDefinition />
25+
</Grid.RowDefinitions>
26+
<Grid.ColumnDefinitions>
27+
<ColumnDefinition />
28+
<ColumnDefinition />
29+
</Grid.ColumnDefinitions>
30+
31+
<!-- Layout Transform Fixed Size -->
32+
<controls:LayoutTransformControl>
33+
<controls:LayoutTransformControl.Transform>
34+
<TransformGroup>
35+
<RotateTransform Angle="{x:Bind Angle, Mode=OneWay}" />
36+
<ScaleTransform ScaleX="{x:Bind ScaleX, Mode=OneWay}" ScaleY="{x:Bind ScaleY, Mode=OneWay}" />
37+
<SkewTransform AngleX="{x:Bind SkewX, Mode=OneWay}" AngleY="{x:Bind SkewY, Mode=OneWay}" />
38+
</TransformGroup>
39+
</controls:LayoutTransformControl.Transform>
40+
<Border Width="200"
41+
Height="50"
42+
Style="{StaticResource BorderCardStyle}">
43+
<TextBlock Text="Layout Fixed Size." />
44+
</Border>
45+
</controls:LayoutTransformControl>
46+
47+
<!-- Layout Transform Full Size -->
48+
<controls:LayoutTransformControl Grid.Column="1">
49+
<controls:LayoutTransformControl.Transform>
50+
<TransformGroup>
51+
<RotateTransform Angle="{x:Bind Angle, Mode=OneWay}" />
52+
<ScaleTransform ScaleX="{x:Bind ScaleX, Mode=OneWay}" ScaleY="{x:Bind ScaleY, Mode=OneWay}" />
53+
<SkewTransform AngleX="{x:Bind SkewX, Mode=OneWay}" AngleY="{x:Bind SkewY, Mode=OneWay}" />
54+
</TransformGroup>
55+
</controls:LayoutTransformControl.Transform>
56+
<Border Style="{StaticResource BorderCardStyle}">
57+
<TextBlock Text="Layout Full Frame." />
58+
</Border>
59+
</controls:LayoutTransformControl>
60+
61+
<!-- Render Transform Fixed Size -->
62+
<Border Grid.Row="1"
63+
Width="200"
64+
Height="50"
65+
RenderTransformOrigin="0.5,0.5"
66+
Style="{StaticResource BorderCardStyle}">
67+
<Border.RenderTransform>
68+
<TransformGroup>
69+
<RotateTransform Angle="{x:Bind Angle, Mode=OneWay}" />
70+
<ScaleTransform ScaleX="{x:Bind ScaleX, Mode=OneWay}" ScaleY="{x:Bind ScaleY, Mode=OneWay}" />
71+
<SkewTransform AngleX="{x:Bind SkewX, Mode=OneWay}" AngleY="{x:Bind SkewY, Mode=OneWay}" />
72+
</TransformGroup>
73+
</Border.RenderTransform>
74+
75+
<TextBlock Text="Render Fixed Size." />
76+
</Border>
77+
78+
<!-- Render Transform Full Size -->
79+
<Border Grid.Row="1"
80+
Grid.Column="1"
81+
RenderTransformOrigin="0.5,0.5"
82+
Style="{StaticResource BorderCardStyle}">
83+
<Border.RenderTransform>
84+
<TransformGroup>
85+
<RotateTransform Angle="{x:Bind Angle, Mode=OneWay}" />
86+
<ScaleTransform ScaleX="{x:Bind ScaleX, Mode=OneWay}" ScaleY="{x:Bind ScaleY, Mode=OneWay}" />
87+
<SkewTransform AngleX="{x:Bind SkewX, Mode=OneWay}" AngleY="{x:Bind SkewY, Mode=OneWay}" />
88+
</TransformGroup>
89+
</Border.RenderTransform>
90+
91+
<TextBlock Text="Render Full Frame." />
92+
</Border>
93+
</Grid>
94+
</Page>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.WinUI.Controls;
6+
7+
namespace LayoutTransformControlExperiment.Samples;
8+
9+
/// <summary>
10+
/// An example sample page of a custom control inheriting from Panel.
11+
/// </summary>
12+
[ToolkitSampleNumericOption("Angle", 0, -180.0, 180.0, 1, false, Title = "Angle")]
13+
[ToolkitSampleNumericOption("ScaleX", 1, 0.0, 5.0, 1, false, Title = "ScaleX")]
14+
[ToolkitSampleNumericOption("ScaleY", 1, 0.0, 5.0, 1, false, Title = "ScaleY")]
15+
[ToolkitSampleNumericOption("SkewX", 0, -180.0, 180.0, 1, false, Title = "SkewX")]
16+
[ToolkitSampleNumericOption("SkewY", 0, -180.0, 180.0, 1, false, Title = "SkewY")]
17+
18+
[ToolkitSample(id: nameof(LayoutTransformControlSample), "LayoutTransformControl", description: $"A sample for showing how to create and use a {nameof(LayoutTransformControl)}.")]
19+
public sealed partial class LayoutTransformControlSample : Page
20+
{
21+
public LayoutTransformControlSample()
22+
{
23+
this.InitializeComponent();
24+
}
25+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.CompilerServices;
6+
7+
// These `InternalsVisibleTo` calls are intended to make it easier for
8+
// for any internal code to be testable in all the different test projects
9+
// used with the Labs infrastructure.
10+
[assembly: InternalsVisibleTo("LayoutTransformControl.Tests.Uwp")]
11+
[assembly: InternalsVisibleTo("LayoutTransformControl.Tests.WinAppSdk")]
12+
[assembly: InternalsVisibleTo("CommunityToolkit.Tests.Uwp")]
13+
[assembly: InternalsVisibleTo("CommunityToolkit.Tests.WinAppSdk")]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">
2+
<PropertyGroup>
3+
<ToolkitComponentName>LayoutTransformControl</ToolkitComponentName>
4+
<Description>This package contains LayoutTransformControl.</Description>
5+
<Version>0.0.1</Version>
6+
7+
<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 -->
8+
<RootNamespace>CommunityToolkit.WinUI.Controls.LayoutTransformControlRns</RootNamespace>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="$(ToolkitExtensionSourceProject)"/>
13+
</ItemGroup>
14+
15+
<!-- Sets this up as a toolkit component's source project -->
16+
<Import Project="$(ToolingDirectory)\ToolkitComponent.SourceProject.props" />
17+
</Project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
WinUI 2 under UWP uses TargetFramework uap10.0.*
3+
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
4+
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.
5+
6+
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.
7+
8+
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
9+
For UWP / WinAppSDK / Uno packages, place the package references here.
10+
-->
11+
<Project>
12+
<!-- WinUI 2 / UWP -->
13+
<ItemGroup Condition="'$(IsUwp)' == 'true'">
14+
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
15+
</ItemGroup>
16+
17+
<!-- WinUI 2 / Uno -->
18+
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
19+
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
20+
</ItemGroup>
21+
22+
<!-- WinUI 3 / WinAppSdk -->
23+
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
24+
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
25+
</ItemGroup>
26+
27+
<!-- WinUI 3 / Uno -->
28+
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
29+
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
30+
</ItemGroup>
31+
</Project>

0 commit comments

Comments
 (0)