-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/lhak/Windows
- Loading branch information
Showing
44 changed files
with
1,651 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@ECHO OFF | ||
|
||
powershell ..\..\tooling\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %* |
16 changes: 16 additions & 0 deletions
16
components/DeveloperTools/samples/AlignmentGridSample.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- 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. --> | ||
<Page x:Class="DeveloperToolsExperiment.Samples.AlignmentGridSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:developerTools="using:CommunityToolkit.WinUI.DeveloperTools" | ||
xmlns:local="using:DeveloperToolsExperiment.Samples" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<developerTools:AlignmentGrid HorizontalStep="{x:Bind HorizontalStep, Mode=OneWay}" | ||
Opacity="{x:Bind OpacitySetting, Mode=OneWay}" | ||
VerticalStep="{x:Bind VerticalStep, Mode=OneWay}" /> | ||
</Grid> | ||
</Page> |
20 changes: 20 additions & 0 deletions
20
components/DeveloperTools/samples/AlignmentGridSample.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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 CommunityToolkit.WinUI.DeveloperTools; | ||
|
||
namespace DeveloperToolsExperiment.Samples; | ||
|
||
[ToolkitSampleNumericOption("OpacitySetting", 0.2, 0.1, 1.0, 0.1, false, Title = "Opacity")] | ||
[ToolkitSampleNumericOption("HorizontalStep", 20, 5, 100, 1, false, Title = "HorizontalStep")] | ||
[ToolkitSampleNumericOption("VerticalStep", 20, 5, 100, 1, false, Title = "VerticalStep")] | ||
|
||
[ToolkitSample(id: nameof(AlignmentGridSample), "AlignmentGrid", description: $"A sample for showing how to create and use a {nameof(AlignmentGrid)}.")] | ||
public sealed partial class AlignmentGridSample : Page | ||
{ | ||
public AlignmentGridSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
WinUI 2 under UWP uses TargetFramework uap10.0.* | ||
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.* | ||
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework. | ||
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you. | ||
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio. | ||
For UWP / WinAppSDK / Uno packages, place the package references here. | ||
--> | ||
<Project> | ||
<!-- WinUI 2 / UWP --> | ||
<ItemGroup Condition="'$(IsUwp)' == 'true'"> | ||
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> --> | ||
</ItemGroup> | ||
|
||
<!-- WinUI 2 / Uno --> | ||
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'"> | ||
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> --> | ||
</ItemGroup> | ||
|
||
<!-- WinUI 3 / WinAppSdk --> | ||
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'"> | ||
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> --> | ||
</ItemGroup> | ||
|
||
<!-- WinUI 3 / Uno --> | ||
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'"> | ||
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> --> | ||
</ItemGroup> | ||
</Project> |
8 changes: 8 additions & 0 deletions
8
components/DeveloperTools/samples/DeveloperTools.Samples.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="MSBuild.Sdk.Extras/3.0.23"> | ||
<PropertyGroup> | ||
<ToolkitComponentName>DeveloperTools</ToolkitComponentName> | ||
</PropertyGroup> | ||
|
||
<!-- Sets this up as a toolkit component's sample project --> | ||
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: Developer Tools | ||
author: nmetulev | ||
description: The FocusTracker and AlignmentGrid help you to get more information about and aligning UI elements. | ||
keywords: DeveloperTools, FocusTracker, AlignmentGrid, dev tools, controls | ||
dev_langs: | ||
- csharp | ||
category: Xaml | ||
subcategory: Layout | ||
discussion-id: 0 | ||
issue-id: 0 | ||
--- | ||
|
||
# AlignmentGrid XAML Control | ||
|
||
The [AlignmentGrid Control](/dotnet/api/microsoft.toolkit.uwp.developertools.alignmentgrid) can be used to display a grid to help with aligning controls. | ||
|
||
You can control the grid's steps with `HorizontalStep` and `VerticalStep` properties. Line color can be defined with `LineBrush` property. | ||
|
||
> [!Sample AlignmentGridSample] | ||
## Properties | ||
|
||
| Property | Type | Description | | ||
| -- | -- | -- | | ||
| HorizontalStep | double | Gets or sets the step to use horizontally | | ||
| LineBrush | Brush | Gets or sets line Brush | | ||
| VerticalStep | double | Gets or sets the step to use vertically | | ||
|
||
|
||
# FocusTracker | ||
|
||
The [FocusTracker Control](/dotnet/api/microsoft.toolkit.uwp.developertools.focustracker) can be used to display information about the current focused XAML element (if any). | ||
|
||
FocusTracker will display the following information (when available) about the current focused XAML element: | ||
|
||
- Name | ||
- Type | ||
- AutomationProperties.Name | ||
- Name of the first parent in hierarchy with a name | ||
|
||
> [!Sample FocusTrackerSample] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- 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. --> | ||
<Page x:Class="DeveloperToolsExperiment.Samples.FocusTrackerSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:developerTools="using:CommunityToolkit.WinUI.DeveloperTools" | ||
xmlns:local="using:DeveloperToolsExperiment.Samples" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<StackPanel Spacing="12"> | ||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Style="{StaticResource CaptionTextBlockStyle}" | ||
Text="Use the TAB key or mouse to set the focus on a UI element, and see the result in the Focus tracker below" /> | ||
<developerTools:FocusTracker IsActive="{x:Bind IsActive, Mode=OneWay}" /> | ||
</StackPanel> | ||
</Page> |
18 changes: 18 additions & 0 deletions
18
components/DeveloperTools/samples/FocusTrackerSample.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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 CommunityToolkit.WinUI.DeveloperTools; | ||
|
||
namespace DeveloperToolsExperiment.Samples; | ||
|
||
[ToolkitSampleBoolOption("IsActive", true, Title = "IsActive")] | ||
|
||
[ToolkitSample(id: nameof(FocusTrackerSample), "FocusTracker", description: $"A sample for showing how to create and use a {nameof(FocusTracker)}.")] | ||
public sealed partial class FocusTrackerSample : Page | ||
{ | ||
public FocusTrackerSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 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.Runtime.CompilerServices; | ||
|
||
// These `InternalsVisibleTo` calls are intended to make it easier for | ||
// for any internal code to be testable in all the different test projects | ||
// used with the Labs infrastructure. | ||
[assembly: InternalsVisibleTo("DeveloperTools.Tests.Uwp")] | ||
[assembly: InternalsVisibleTo("DeveloperTools.Tests.WinAppSdk")] | ||
[assembly: InternalsVisibleTo("CommunityToolkit.Tests.Uwp")] | ||
[assembly: InternalsVisibleTo("CommunityToolkit.Tests.WinAppSdk")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// 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. | ||
|
||
#if WINAPPSDK | ||
using Microsoft.UI.Xaml.Shapes; | ||
#else | ||
using Windows.UI.Xaml.Shapes; | ||
#endif | ||
|
||
namespace CommunityToolkit.WinUI.DeveloperTools; | ||
/// <summary> | ||
/// AlignmentGrid is used to display a grid to help aligning controls | ||
/// </summary> | ||
public partial class AlignmentGrid : ContentControl | ||
{ | ||
/// <summary> | ||
/// Identifies the <see cref="LineBrush"/> dependency property. | ||
/// </summary> | ||
public static readonly DependencyProperty LineBrushProperty = DependencyProperty.Register(nameof(LineBrush), typeof(Brush), typeof(AlignmentGrid), new PropertyMetadata(null, OnPropertyChanged)); | ||
|
||
/// <summary> | ||
/// Identifies the <see cref="HorizontalStep"/> dependency property. | ||
/// </summary> | ||
public static readonly DependencyProperty HorizontalStepProperty = DependencyProperty.Register(nameof(HorizontalStep), typeof(double), typeof(AlignmentGrid), new PropertyMetadata(20.0, OnPropertyChanged)); | ||
|
||
/// <summary> | ||
/// Identifies the <see cref="VerticalStep"/> dependency property. | ||
/// </summary> | ||
public static readonly DependencyProperty VerticalStepProperty = DependencyProperty.Register(nameof(VerticalStep), typeof(double), typeof(AlignmentGrid), new PropertyMetadata(20.0, OnPropertyChanged)); | ||
|
||
private static void OnPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) | ||
{ | ||
var alignmentGrid = dependencyObject as AlignmentGrid; | ||
alignmentGrid?.Rebuild(); | ||
} | ||
|
||
private readonly Canvas containerCanvas = new Canvas(); | ||
|
||
/// <summary> | ||
/// Gets or sets the step to use horizontally. | ||
/// </summary> | ||
public Brush LineBrush | ||
{ | ||
get { return (Brush)GetValue(LineBrushProperty); } | ||
set { SetValue(LineBrushProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the step to use horizontally. | ||
/// </summary> | ||
public double HorizontalStep | ||
{ | ||
get { return (double)GetValue(HorizontalStepProperty); } | ||
set { SetValue(HorizontalStepProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the step to use horizontally. | ||
/// </summary> | ||
public double VerticalStep | ||
{ | ||
get { return (double)GetValue(VerticalStepProperty); } | ||
set { SetValue(VerticalStepProperty, value); } | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AlignmentGrid"/> class. | ||
/// </summary> | ||
public AlignmentGrid() | ||
{ | ||
SizeChanged += AlignmentGrid_SizeChanged; | ||
|
||
IsHitTestVisible = false; | ||
IsTabStop = false; | ||
Opacity = 0.5; | ||
|
||
HorizontalContentAlignment = HorizontalAlignment.Stretch; | ||
VerticalContentAlignment = VerticalAlignment.Stretch; | ||
Content = containerCanvas; | ||
} | ||
|
||
private void Rebuild() | ||
{ | ||
containerCanvas.Children.Clear(); | ||
var horizontalStep = HorizontalStep; | ||
var verticalStep = VerticalStep; | ||
var brush = LineBrush ?? (Brush)Application.Current.Resources["AccentFillColorDefaultBrush"]; | ||
|
||
if (horizontalStep > 0) | ||
{ | ||
for (double x = 0; x < ActualWidth; x += horizontalStep) | ||
{ | ||
var line = new Rectangle | ||
{ | ||
Width = 1, | ||
Height = ActualHeight, | ||
Fill = brush | ||
}; | ||
Canvas.SetLeft(line, x); | ||
|
||
containerCanvas.Children.Add(line); | ||
} | ||
} | ||
|
||
if (verticalStep > 0) | ||
{ | ||
for (double y = 0; y < ActualHeight; y += verticalStep) | ||
{ | ||
var line = new Rectangle | ||
{ | ||
Width = ActualWidth, | ||
Height = 1, | ||
Fill = brush | ||
}; | ||
Canvas.SetTop(line, y); | ||
|
||
containerCanvas.Children.Add(line); | ||
} | ||
} | ||
} | ||
|
||
private void AlignmentGrid_SizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
Rebuild(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
components/DeveloperTools/src/CommunityToolkit.WinUI.DeveloperTools.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="MSBuild.Sdk.Extras/3.0.23"> | ||
<PropertyGroup> | ||
<ToolkitComponentName>DeveloperTools</ToolkitComponentName> | ||
<Description>This package contains DeveloperTools.</Description> | ||
<Version>8.0.0-beta.1</Version> | ||
|
||
<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 --> | ||
<RootNamespace>CommunityToolkit.WinUI.DeveloperToolsRns</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<!-- Sets this up as a toolkit component's source project --> | ||
<Import Project="$(ToolingDirectory)\ToolkitComponent.SourceProject.props" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
WinUI 2 under UWP uses TargetFramework uap10.0.* | ||
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.* | ||
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework. | ||
MSBuild doesn't play nicely with this out of the box, so we've made it easy for you. | ||
For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio. | ||
For UWP / WinAppSDK / Uno packages, place the package references here. | ||
--> | ||
<Project> | ||
<!-- WinUI 2 / UWP --> | ||
<ItemGroup Condition="'$(IsUwp)' == 'true'"> | ||
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> --> | ||
</ItemGroup> | ||
|
||
<!-- WinUI 2 / Uno --> | ||
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'"> | ||
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> --> | ||
</ItemGroup> | ||
|
||
<!-- WinUI 3 / WinAppSdk --> | ||
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'"> | ||
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> --> | ||
</ItemGroup> | ||
|
||
<!-- WinUI 3 / Uno --> | ||
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'"> | ||
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> --> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.