Skip to content

Commit 8ac9c11

Browse files
authored
Merge branch 'master' into add-textbox-selectall-behavior
2 parents 96ccfe1 + a2ed6aa commit 8ac9c11

File tree

151 files changed

+3512
-3040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+3512
-3040
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
// This extension is restricted to the .NET 5 because it shares the same BCL
6+
// across all targets, ensuring that the layout of our Nullable<T> mapping type
7+
// will be correct. Exposing this API on older targets (especially .NET Standard)
8+
// is not guaranteed to be correct and could result in invalid memory accesses.
9+
#if NET5_0
10+
11+
using System;
12+
using System.Runtime.CompilerServices;
13+
14+
namespace Microsoft.Toolkit.HighPerformance.Extensions
15+
{
16+
/// <summary>
17+
/// Helpers for working with the <see cref="Nullable{T}"/> type.
18+
/// </summary>
19+
public static class NullableExtensions
20+
{
21+
/// <summary>
22+
/// Returns a reference to the value of the input <see cref="Nullable{T}"/> instance, regardless of whether
23+
/// the <see cref="Nullable{T}.HasValue"/> property is returning <see langword="true"/> or not. If that is not
24+
/// the case, this method will still return a reference to the underlying <see langword="default"/> value.
25+
/// </summary>
26+
/// <typeparam name="T">The type of the underlying value</typeparam>
27+
/// <param name="value">The <see cref="Nullable{T}"/></param>
28+
/// <returns>A reference to the underlying value from the input <see cref="Nullable{T}"/> instance.</returns>
29+
/// <remarks>
30+
/// Note that attempting to mutate the returned reference will not change the value returned by <see cref="Nullable{T}.HasValue"/>.
31+
/// That means that reassigning the value of an empty instance will not make <see cref="Nullable{T}.HasValue"/> return <see langword="true"/>.
32+
/// </remarks>
33+
public static ref T DangerousGetValueOrDefaultReference<T>(this ref T? value)
34+
where T : struct
35+
{
36+
return ref Unsafe.As<T?, RawNullableData<T>>(ref value).Value;
37+
}
38+
39+
/// <summary>
40+
/// Mapping type that reflects the internal layout of the <see cref="Nullable{T}"/> type.
41+
/// See https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Nullable.cs.
42+
/// </summary>
43+
/// <typeparam name="T">The value type wrapped by the current instance.</typeparam>
44+
private struct RawNullableData<T>
45+
where T : struct
46+
{
47+
#pragma warning disable CS0649 // Unassigned fields
48+
public bool HasValue;
49+
public T Value;
50+
#pragma warning restore CS0649
51+
}
52+
}
53+
}
54+
55+
#endif

Microsoft.Toolkit.Uwp.DeveloperTools/FocusTracker/FocusTracker.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using Windows.System;
1011
using Windows.UI.Xaml;
1112
using Windows.UI.Xaml.Automation;
1213
using Windows.UI.Xaml.Controls;
@@ -45,7 +46,7 @@ private static void OnIsActiveChanged(DependencyObject d, DependencyPropertyChan
4546
}
4647
}
4748

48-
private DispatcherTimer updateTimer;
49+
private DispatcherQueueTimer updateTimer;
4950
private TextBlock controlName;
5051
private TextBlock controlType;
5152
private TextBlock controlAutomationName;
@@ -72,7 +73,7 @@ private void Start()
7273
{
7374
if (updateTimer == null)
7475
{
75-
updateTimer = new DispatcherTimer();
76+
updateTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
7677
updateTimer.Tick += UpdateTimer_Tick;
7778
}
7879

Microsoft.Toolkit.Uwp.Input.GazeInteraction/GazePointer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Windows.Devices.Input.Preview;
1212
using Windows.Foundation;
1313
using Windows.Foundation.Collections;
14+
using Windows.System;
1415
using Windows.UI;
1516
using Windows.UI.Core;
1617
using Windows.UI.Xaml;
@@ -354,7 +355,7 @@ private GazePointer()
354355
_gazeCursor = new GazeCursor();
355356

356357
// timer that gets called back if there gaze samples haven't been received in a while
357-
_eyesOffTimer = new DispatcherTimer();
358+
_eyesOffTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
358359
_eyesOffTimer.Tick += OnEyesOff;
359360

360361
// provide a default of GAZE_IDLE_TIME microseconds to fire eyes off
@@ -860,7 +861,7 @@ private void OnDeviceRemoved(GazeDeviceWatcherPreview sender, GazeDeviceWatcherR
860861

861862
private readonly List<int> _roots = new List<int>();
862863

863-
private readonly DispatcherTimer _eyesOffTimer;
864+
private readonly DispatcherQueueTimer _eyesOffTimer;
864865

865866
private readonly GazeCursor _gazeCursor;
866867

Microsoft.Toolkit.Uwp.SampleApp/App.xaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
55
RequiresPointerMode="Auto">
66

7-
<Application.Resources>
8-
<ResourceDictionary>
9-
<!-- Color Resources -->
10-
<ResourceDictionary.MergedDictionaries>
11-
<ResourceDictionary Source="ms-appx:///Styles/Themes.xaml" />
12-
<ResourceDictionary Source="ms-appx:///Styles/Generic.xaml" />
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<!-- Color Resources -->
10+
<ResourceDictionary.MergedDictionaries>
11+
<ResourceDictionary Source="ms-appx:///Styles/Themes.xaml" />
12+
<ResourceDictionary Source="ms-appx:///Styles/Generic.xaml" />
1313

14-
<!-- WinUI -->
15-
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
16-
</ResourceDictionary.MergedDictionaries>
14+
<!-- WinUI -->
15+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
16+
</ResourceDictionary.MergedDictionaries>
1717

18-
<!-- Converters -->
19-
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
18+
<!-- Converters -->
19+
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
2020

21-
<converters:EmptyStringToObjectConverter x:Key="EmptyStringToObject"
22-
EmptyValue="Collapsed"
23-
NotEmptyValue="Visible" />
21+
<converters:EmptyStringToObjectConverter x:Key="EmptyStringToObject"
22+
EmptyValue="Collapsed"
23+
NotEmptyValue="Visible" />
2424

25-
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
26-
</ResourceDictionary>
27-
</Application.Resources>
25+
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
26+
</ResourceDictionary>
27+
</Application.Resources>
2828
</Application>

Microsoft.Toolkit.Uwp.SampleApp/Controls/CodeRenderer.xaml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
<ResourceDictionary
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:controls="using:Microsoft.Toolkit.Uwp.SampleApp.Controls"
5-
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Controls">
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:controls="using:Microsoft.Toolkit.Uwp.SampleApp.Controls"
4+
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.Controls">
65

76
<Style TargetType="controls:CodeRenderer">
87
<Setter Property="Template">
@@ -14,25 +13,24 @@
1413
<RowDefinition Height="Auto" />
1514
</Grid.RowDefinitions>
1615
<Grid x:Name="Container"
17-
Grid.RowSpan="2"
18-
Opacity="0" />
19-
<ScrollViewer
20-
Grid.Row="0"
21-
HorizontalScrollMode="Auto"
22-
HorizontalScrollBarVisibility="Auto">
16+
Grid.RowSpan="2"
17+
Opacity="0" />
18+
<ScrollViewer Grid.Row="0"
19+
HorizontalScrollBarVisibility="Auto"
20+
HorizontalScrollMode="Auto">
2321
<RichTextBlock Name="codeView"
24-
FontFamily="Consolas"
25-
Padding="10" />
22+
Padding="10"
23+
FontFamily="Consolas" />
2624
</ScrollViewer>
2725
<StackPanel Grid.Row="1"
28-
HorizontalAlignment="Center"
29-
Orientation="Horizontal">
26+
HorizontalAlignment="Center"
27+
Orientation="Horizontal">
3028
<Button x:Name="CopyButton"
31-
Margin="5"
32-
Content="Copy" />
29+
Margin="5"
30+
Content="Copy" />
3331
<Button x:Name="PrintButton"
34-
Margin="5"
35-
Content="Print" />
32+
Margin="5"
33+
Content="Print" />
3634
</StackPanel>
3735
</Grid>
3836
</ControlTemplate>

Microsoft.Toolkit.Uwp.SampleApp/Data/PhotoDataItem.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ public class PhotoDataItem
1111
public string Category { get; set; }
1212

1313
public string Thumbnail { get; set; }
14+
15+
public override string ToString()
16+
{
17+
return Title;
18+
}
1419
}
1520
}

Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@
272272
<Content Include="Icons\More.png" />
273273
<Content Include="Icons\Notifications.png" />
274274
<Content Include="Icons\Services.png" />
275+
<Content Include="SamplePages\Animations\Effects\EffectAnimations.png">
276+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
277+
</Content>
278+
<Content Include="SamplePages\Graph\LoginButton.png" />
279+
<Content Include="SamplePages\Graph\PeoplePicker.png" />
280+
<Content Include="SamplePages\Graph\PersonView.png" />
281+
<Content Include="SamplePages\Primitives\SwitchPresenter.png" />
275282
<Content Include="SamplePages\TabbedCommandBar\TabbedCommandBar.png" />
276283
<Content Include="SamplePages\Animations\Effects\FadeBehavior.png" />
277284
<Content Include="SamplePages\ColorPicker\ColorPicker.png" />
@@ -492,12 +499,8 @@
492499
<DependentUpon>AutoSelectBehaviorPage.xaml</DependentUpon>
493500
</Compile>
494501
<Compile Include="SamplePages\CanvasPathGeometry\GeometryStreamReader.cs" />
495-
<Compile Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml.cs">
496-
<DependentUpon>ColorPickerButtonPage.xaml</DependentUpon>
497-
</Compile>
498-
<Compile Include="SamplePages\ColorPicker\ColorPickerPage.xaml.cs">
499-
<DependentUpon>ColorPickerPage.xaml</DependentUpon>
500-
</Compile>
502+
<Compile Include="SamplePages\EnumValuesExtension\Animal.cs" />
503+
<Compile Include="SamplePages\EnumValuesExtension\AnimalToColorConverter.xaml.cs" />
501504
<Compile Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml.cs">
502505
<DependentUpon>EnumValuesExtensionPage.xaml</DependentUpon>
503506
</Compile>
@@ -617,7 +620,12 @@
617620
<Content Include="SamplePages\Animations\Behaviors\RotateBehaviorXaml.bind" />
618621
<Content Include="SamplePages\Animations\Effects\EffectAnimations.bind" />
619622
<Content Include="SamplePages\VisualEffectFactory\VisualEffectFactory.bind" />
623+
<Content Include="SamplePages\Animations\Activities\InvokeActionsActivityCode.bind" />
624+
<Content Include="SamplePages\Animations\Activities\StartAnimationActivityCode.bind" />
620625
<Content Include="SamplePages\AutoSelectBehavior\AutoSelectBehaviorXaml.bind" />
626+
<Content Include="SamplePages\Graph\LoginButtonXaml.bind" />
627+
<Content Include="SamplePages\Graph\PeoplePickerXaml.bind" />
628+
<Content Include="SamplePages\Graph\PersonViewXaml.bind" />
621629
</ItemGroup>
622630
<ItemGroup>
623631
<Compile Include="App.xaml.cs">
@@ -899,9 +907,6 @@
899907
<Compile Include="SamplePages\RadialGauge\RadialGaugePage.xaml.cs">
900908
<DependentUpon>RadialGaugePage.xaml</DependentUpon>
901909
</Compile>
902-
<Compile Include="SamplePages\RangeSelector\RangeSelectorPage.xaml.cs">
903-
<DependentUpon>RangeSelectorPage.xaml</DependentUpon>
904-
</Compile>
905910
<Compile Include="SamplePages\WrapPanel\WrapPanelPage.xaml.cs">
906911
<DependentUpon>WrapPanelPage.xaml</DependentUpon>
907912
</Compile>
@@ -959,14 +964,6 @@
959964
<Generator>MSBuild:Compile</Generator>
960965
<SubType>Designer</SubType>
961966
</Page>
962-
<Page Include="SamplePages\ColorPicker\ColorPickerButtonPage.xaml">
963-
<Generator>MSBuild:Compile</Generator>
964-
<SubType>Designer</SubType>
965-
</Page>
966-
<Page Include="SamplePages\ColorPicker\ColorPickerPage.xaml">
967-
<Generator>MSBuild:Compile</Generator>
968-
<SubType>Designer</SubType>
969-
</Page>
970967
<Page Include="SamplePages\EnumValuesExtension\EnumValuesExtensionPage.xaml">
971968
<Generator>MSBuild:Compile</Generator>
972969
<SubType>Designer</SubType>
@@ -982,6 +979,9 @@
982979
<SubType>Designer</SubType>
983980
<Generator>MSBuild:Compile</Generator>
984981
</Page>
982+
<Content Include="SamplePages\Primitives\SwitchPresenter.bind">
983+
<SubType>Designer</SubType>
984+
</Content>
985985
<Page Include="SamplePages\TilesBrush\TilesBrushPage.xaml">
986986
<Generator>MSBuild:Compile</Generator>
987987
<SubType>Designer</SubType>
@@ -1349,10 +1349,6 @@
13491349
<Generator>MSBuild:Compile</Generator>
13501350
<SubType>Designer</SubType>
13511351
</Page>
1352-
<Page Include="SamplePages\RangeSelector\RangeSelectorPage.xaml">
1353-
<Generator>MSBuild:Compile</Generator>
1354-
<SubType>Designer</SubType>
1355-
</Page>
13561352
<Page Include="SamplePages\WrapLayout\WrapLayoutPage.xaml">
13571353
<SubType>Designer</SubType>
13581354
<Generator>MSBuild:Compile</Generator>

Microsoft.Toolkit.Uwp.SampleApp/Models/GitHubRelease.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class GitHubRelease
2121
[JsonPropertyName("name")]
2222
public string Name { get; set; }
2323

24-
public string FullName => $"Version {Name.Replace("v", string.Empty)} notes";
24+
public string FullName => $"Version {Name.Substring(1)} notes"; // Skip the initial 'v' we put at the front. If we replace all 'v's then we hit 'preview'.
2525

2626
[JsonPropertyName("draft")]
2727
public bool IsDraft { get; set; }

0 commit comments

Comments
 (0)