Skip to content

Commit befa674

Browse files
HHChaosmichael-hawker
authored andcommitted
Initial port of code from TransitionHelper PR CommunityToolkit/WindowsCommunityToolkit#4338
(Still not compiling)
1 parent 710ba64 commit befa674

37 files changed

+2434
-682
lines changed

Windows.Toolkit.Common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
1010
<PackageProjectUrl>https://github.com/CommunityToolkit/Labs-Windows</PackageProjectUrl>
1111
<PackageReleaseNotes>https://github.com/CommunityToolkit/Labs-Windows/releases</PackageReleaseNotes>
12-
<PackageIcon>Icon.png</PackageIcon>
12+
<!--<PackageIcon>Icon.png</PackageIcon>-->
1313
<PackageIconUrl>https://raw.githubusercontent.com/CommunityToolkit/Labs-Windows/main/nuget.png</PackageIconUrl>
1414
<!-- TODO: Remove when closing https://github.com/CommunityToolkit/Labs-Windows/issues/256 -->
1515
<NoWarn>$(NoWarn);NU1505;NU1504</NoWarn>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.Numerics;
6+
using Microsoft.Toolkit.Uwp.UI;
7+
using Microsoft.Toolkit.Uwp.UI.Animations.Helpers;
8+
9+
namespace TransitionHelperExperiment.Samples;
10+
11+
public sealed class CustomTextScalingCalculator : IScalingCalculator
12+
{
13+
/// <inheritdoc/>
14+
public Vector2 GetScaling(UIElement source, UIElement target)
15+
{
16+
var sourceTextElement = source?.FindDescendantOrSelf<TextBlock>();
17+
var targetTextElement = target?.FindDescendantOrSelf<TextBlock>();
18+
if (sourceTextElement is not null && targetTextElement is not null)
19+
{
20+
var scale = targetTextElement.FontSize / sourceTextElement.FontSize;
21+
return new Vector2((float)scale);
22+
}
23+
24+
return new Vector2(1);
25+
}
26+
}

labs/TransitionHelper/samples/TransitionHelper.Samples/TransitionHelper.Samples.csproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,34 @@
1414
<RootNamespace>TransitionHelperExperiment.Samples</RootNamespace>
1515
<AssemblyName>TransitionHelperExperiment.Samples</AssemblyName>
1616
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<Compile Remove="CustomTextScalingCalculator.cs" />
20+
<Compile Remove="TransitionHelperFullExample.xaml.cs" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<Content Remove="TransitionHelperFullExample.xaml" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<None Remove="TransitionHelperFullExample.xaml" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<UpToDateCheckInput Remove="TransitionHelperFullExample.xaml" />
33+
</ItemGroup>
1734

1835
<!-- Sample XAML Pages and Markdown files are automatically included, and don't need to be specified here. -->
1936

2037
<ItemGroup>
2138
<ProjectReference Include="..\..\src\CommunityToolkit.Labs.WinUI.TransitionHelper.csproj" />
2239
</ItemGroup>
40+
41+
<ItemGroup>
42+
<Page Update="TransitionHelperFullExample.xaml">
43+
<SubType>Designer</SubType>
44+
<Generator>MSBuild:Compile</Generator>
45+
</Page>
46+
</ItemGroup>
2347
</Project>
Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: TransitionHelper
33
author: githubaccount
4-
description: TODO: Your experiment's description here
4+
description: An animation helper that morphs between two controls.
55
keywords: TransitionHelper, Control, Layout
66
dev_langs:
77
- csharp
@@ -11,54 +11,11 @@ discussion-id: 0
1111
issue-id: 0
1212
---
1313

14-
<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->
15-
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
16-
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
17-
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
18-
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->
19-
20-
<!-- Be sure to update the discussion/issue numbers above with your Labs discussion/issue id numbers in order for UI links to them from the sample app to work. -->
21-
2214
# TransitionHelper
2315

24-
TODO: Fill in information about this experiment and how to get started here...
25-
26-
## Custom Control
27-
28-
You can inherit from an existing component as well, like `Panel`, this example shows a control without a
29-
XAML Style that will be more light-weight to consume by an app developer:
30-
31-
> [!Sample TransitionHelperCustomSample]
32-
33-
## Templated Controls
34-
35-
The Toolkit is built with templated controls. This provides developers a flexible way to restyle components
36-
easily while still inheriting the general functionality a control provides. The examples below show
37-
how a component can use a default style and then get overridden by the end developer.
38-
39-
TODO: Two types of templated control building methods are shown. Delete these if you're building a custom component.
40-
Otherwise, pick one method for your component and delete the files related to the unchosen `_ClassicBinding` or `_xBind`
41-
classes (and the custom non-suffixed one as well). Then, rename your component to just be your component name.
42-
43-
The `_ClassicBinding` class shows the traditional method used to develop components with best practices.
44-
45-
### Implict style
46-
47-
> [!SAMPLE TransitionHelperTemplatedSample]
48-
49-
### Custom style
50-
51-
> [!SAMPLE TransitionHelperTemplatedStyleCustomSample]
52-
53-
## Templated Controls with x:Bind
54-
55-
This is an _experimental_ new way to define components which allows for the use of x:Bind within the style.
56-
57-
### Implict style
58-
59-
> [!SAMPLE TransitionHelperXbindBackedSample]
16+
An animation helper that morphs between two controls.
6017

61-
### Custom style
18+
### Example
6219

63-
> [!SAMPLE TransitionHelperXbindBackedStyleCustomSample]
20+
> [!SAMPLE TransitionHelperFullExample]
6421

labs/TransitionHelper/samples/TransitionHelper.Samples/TransitionHelperCustomSample.xaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

labs/TransitionHelper/samples/TransitionHelper.Samples/TransitionHelperCustomSample.xaml.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)