Merge branch 'master' into winui

This commit is contained in:
Alexandre Zollinger Chohfi 2020-11-10 11:55:17 -08:00
Родитель 448706cccb 1ef0ab2cd5
Коммит cb9e7794d6
66 изменённых файлов: 2218 добавлений и 59 удалений

Просмотреть файл

@ -78,7 +78,7 @@ namespace Microsoft.Toolkit.HighPerformance
ThrowInvalidCastExceptionForGetFrom();
}
return Unsafe.As<Box<T>>(obj);
return Unsafe.As<Box<T>>(obj)!;
}
/// <summary>
@ -94,7 +94,7 @@ namespace Microsoft.Toolkit.HighPerformance
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Box<T> DangerousGetFrom(object obj)
{
return Unsafe.As<Box<T>>(obj);
return Unsafe.As<Box<T>>(obj)!;
}
/// <summary>
@ -108,7 +108,7 @@ namespace Microsoft.Toolkit.HighPerformance
{
if (obj.GetType() == typeof(T))
{
box = Unsafe.As<Box<T>>(obj);
box = Unsafe.As<Box<T>>(obj)!;
return true;
}
@ -145,7 +145,7 @@ namespace Microsoft.Toolkit.HighPerformance
// manually be implemented in the Box<T> type. For instance, boxing a float
// and calling ToString() on it directly, on its boxed object or on a Box<T>
// reference retrieved from it will produce the same result in all cases.
return Unsafe.As<Box<T>>(value);
return Unsafe.As<Box<T>>(value)!;
}
/// <inheritdoc/>

Просмотреть файл

@ -422,11 +422,11 @@ namespace Microsoft.Toolkit.HighPerformance.Buffers
/// <param name="value">The input <see cref="string"/> instance to cache.</param>
/// <param name="hashcode">The precomputed hashcode for <paramref name="value"/>.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Add(string value, int hashcode)
public void Add(string value, int hashcode)
{
ref string target = ref TryGet(value.AsSpan(), hashcode);
if (Unsafe.AreSame(ref target, ref Unsafe.AsRef<string>(null)))
if (Unsafe.IsNullRef(ref target))
{
Insert(value, hashcode);
}
@ -443,11 +443,11 @@ namespace Microsoft.Toolkit.HighPerformance.Buffers
/// <param name="hashcode">The precomputed hashcode for <paramref name="value"/>.</param>
/// <returns>A <see cref="string"/> instance with the contents of <paramref name="value"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe string GetOrAdd(string value, int hashcode)
public string GetOrAdd(string value, int hashcode)
{
ref string result = ref TryGet(value.AsSpan(), hashcode);
if (!Unsafe.AreSame(ref result, ref Unsafe.AsRef<string>(null)))
if (!Unsafe.IsNullRef(ref result))
{
return result;
}
@ -464,11 +464,11 @@ namespace Microsoft.Toolkit.HighPerformance.Buffers
/// <param name="hashcode">The precomputed hashcode for <paramref name="span"/>.</param>
/// <returns>A <see cref="string"/> instance with the contents of <paramref name="span"/>, cached if possible.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe string GetOrAdd(ReadOnlySpan<char> span, int hashcode)
public string GetOrAdd(ReadOnlySpan<char> span, int hashcode)
{
ref string result = ref TryGet(span, hashcode);
if (!Unsafe.AreSame(ref result, ref Unsafe.AsRef<string>(null)))
if (!Unsafe.IsNullRef(ref result))
{
return result;
}
@ -488,11 +488,11 @@ namespace Microsoft.Toolkit.HighPerformance.Buffers
/// <param name="value">The resulting cached <see cref="string"/> instance, if present</param>
/// <returns>Whether or not the target <see cref="string"/> instance was found.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe bool TryGet(ReadOnlySpan<char> span, int hashcode, [NotNullWhen(true)] out string? value)
public bool TryGet(ReadOnlySpan<char> span, int hashcode, [NotNullWhen(true)] out string? value)
{
ref string result = ref TryGet(span, hashcode);
if (!Unsafe.AreSame(ref result, ref Unsafe.AsRef<string>(null)))
if (!Unsafe.IsNullRef(ref result))
{
value = result;
@ -527,7 +527,7 @@ namespace Microsoft.Toolkit.HighPerformance.Buffers
private unsafe ref string TryGet(ReadOnlySpan<char> span, int hashcode)
{
ref MapEntry mapEntriesRef = ref this.mapEntries.DangerousGetReference();
ref MapEntry entry = ref Unsafe.AsRef<MapEntry>(null);
ref MapEntry entry = ref Unsafe.NullRef<MapEntry>();
int
length = this.buckets.Length,
bucketIndex = hashcode & (length - 1);
@ -547,7 +547,7 @@ namespace Microsoft.Toolkit.HighPerformance.Buffers
}
}
return ref Unsafe.AsRef<string>(null);
return ref Unsafe.NullRef<string>();
}
/// <summary>

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
public static ref T DangerousGetReference<T>(this T[] array)
{
#if NETCORE_RUNTIME
var arrayData = Unsafe.As<RawArrayData>(array);
var arrayData = Unsafe.As<RawArrayData>(array)!;
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
return ref r0;
@ -55,7 +55,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
public static ref T DangerousGetReferenceAt<T>(this T[] array, int i)
{
#if NETCORE_RUNTIME
var arrayData = Unsafe.As<RawArrayData>(array);
var arrayData = Unsafe.As<RawArrayData>(array)!;
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
ref T ri = ref Unsafe.Add(ref r0, (nint)(uint)i);

Просмотреть файл

@ -33,7 +33,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
public static ref T DangerousGetReference<T>(this T[,] array)
{
#if NETCORE_RUNTIME
var arrayData = Unsafe.As<RawArray2DData>(array);
var arrayData = Unsafe.As<RawArray2DData>(array)!;
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
return ref r0;
@ -63,7 +63,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
public static ref T DangerousGetReferenceAt<T>(this T[,] array, int i, int j)
{
#if NETCORE_RUNTIME
var arrayData = Unsafe.As<RawArray2DData>(array);
var arrayData = Unsafe.As<RawArray2DData>(array)!;
nint offset = ((nint)(uint)i * (nint)(uint)arrayData.Width) + (nint)(uint)j;
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
ref T ri = ref Unsafe.Add(ref r0, offset);

Просмотреть файл

@ -32,7 +32,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
public static ref T DangerousGetReference<T>(this T[,,] array)
{
#if NETCORE_RUNTIME
var arrayData = Unsafe.As<RawArray3DData>(array);
var arrayData = Unsafe.As<RawArray3DData>(array)!;
ref T r0 = ref Unsafe.As<byte, T>(ref arrayData.Data);
return ref r0;
@ -63,7 +63,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
public static ref T DangerousGetReferenceAt<T>(this T[,,] array, int i, int j, int k)
{
#if NETCORE_RUNTIME
var arrayData = Unsafe.As<RawArray3DData>(array);
var arrayData = Unsafe.As<RawArray3DData>(array)!;
nint offset =
((nint)(uint)i * (nint)(uint)arrayData.Height * (nint)(uint)arrayData.Width) +
((nint)(uint)j * (nint)(uint)arrayData.Width) + (nint)(uint)k;

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IntPtr DangerousGetObjectDataByteOffset<T>(this object obj, ref T data)
{
var rawObj = Unsafe.As<RawObjectData>(obj);
var rawObj = Unsafe.As<RawObjectData>(obj)!;
ref byte r0 = ref rawObj.Data;
ref byte r1 = ref Unsafe.As<T, byte>(ref data);
@ -55,7 +55,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T DangerousGetObjectDataReferenceAt<T>(this object obj, IntPtr offset)
{
var rawObj = Unsafe.As<RawObjectData>(obj);
var rawObj = Unsafe.As<RawObjectData>(obj)!;
ref byte r0 = ref rawObj.Data;
ref byte r1 = ref Unsafe.AddByteOffset(ref r0, offset);
ref T r2 = ref Unsafe.As<byte, T>(ref r1);

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
#if NETCOREAPP3_1
return ref Unsafe.AsRef(text.GetPinnableReference());
#elif NETCOREAPP2_1
var stringData = Unsafe.As<RawStringData>(text);
var stringData = Unsafe.As<RawStringData>(text)!;
return ref stringData.Data;
#else
@ -53,7 +53,7 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
#if NETCOREAPP3_1
ref char r0 = ref Unsafe.AsRef(text.GetPinnableReference());
#elif NETCOREAPP2_1
ref char r0 = ref Unsafe.As<RawStringData>(text).Data;
ref char r0 = ref Unsafe.As<RawStringData>(text)!.Data;
#else
ref char r0 = ref MemoryMarshal.GetReference(text.AsSpan());
#endif

Просмотреть файл

@ -772,7 +772,7 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
}
else if (typeof(T) == typeof(char) && this.instance.GetType() == typeof(string))
{
string text = Unsafe.As<string>(this.instance);
string text = Unsafe.As<string>(this.instance)!;
int index = text.AsSpan().IndexOf(in text.DangerousGetObjectDataReferenceAt<char>(this.offset));
ReadOnlyMemory<char> temp = text.AsMemory(index, (int)Length);
@ -786,16 +786,13 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
}
else if (this.instance is MemoryManager<T> memoryManager)
{
unsafe
{
// If the object is a MemoryManager<T>, just slice it as needed
memory = memoryManager.Memory.Slice((int)(void*)this.offset, this.height * this.width);
}
// If the object is a MemoryManager<T>, just slice it as needed
memory = memoryManager.Memory.Slice((int)(nint)this.offset, this.height * this.width);
}
else if (this.instance.GetType() == typeof(T[]))
{
// If it's a T[] array, also handle the initial offset
T[] array = Unsafe.As<T[]>(this.instance);
T[] array = Unsafe.As<T[]>(this.instance)!;
int index = array.AsSpan().IndexOf(ref array.DangerousGetObjectDataReferenceAt<T>(this.offset));
memory = array.AsMemory(index, this.height * this.width);

Просмотреть файл

@ -794,7 +794,7 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
// difference between the start of the Span<char> (which directly wraps just the actual character data
// within the string), and the input reference, which we can get from the byte offset in use. The result
// is the character index which we can use to create the final Memory<char> instance.
string text = Unsafe.As<string>(this.instance);
string text = Unsafe.As<string>(this.instance)!;
int index = text.AsSpan().IndexOf(in text.DangerousGetObjectDataReferenceAt<char>(this.offset));
ReadOnlyMemory<char> temp = text.AsMemory(index, (int)Length);
@ -802,16 +802,13 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
}
else if (this.instance is MemoryManager<T> memoryManager)
{
unsafe
{
// If the object is a MemoryManager<T>, just slice it as needed
memory = memoryManager.Memory.Slice((int)(void*)this.offset, this.height * this.width);
}
// If the object is a MemoryManager<T>, just slice it as needed
memory = memoryManager.Memory.Slice((int)(nint)this.offset, this.height * this.width);
}
else if (this.instance.GetType() == typeof(T[]))
{
// If it's a T[] array, also handle the initial offset
T[] array = Unsafe.As<T[]>(this.instance);
T[] array = Unsafe.As<T[]>(this.instance)!;
int index = array.AsSpan().IndexOf(ref array.DangerousGetObjectDataReferenceAt<T>(this.offset));
memory = array.AsMemory(index, this.height * this.width);

Просмотреть файл

@ -41,7 +41,7 @@
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
@ -51,14 +51,14 @@
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<ItemGroup>
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
<PropertyGroup>
@ -76,6 +76,9 @@
</PropertyGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
<PropertyGroup>
<!-- NETCORE_RUNTIME: to avoid issues with APIs that assume a specific memory layout, we define a
@ -89,7 +92,7 @@
</When>
<When Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
<PropertyGroup>
<DefineConstants>SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants>

Просмотреть файл

@ -37,4 +37,20 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<!--
Required workaround for ProjectReference inclusion of the Controls package
The UWP project system is including the Controls resources in the pri file because
it doesn't know it'll be an independent package later during packing.
Therefore, we need to remove these extra resources in the PRI pipeline so the
Markdown pri file is properly generated and doesn't include duplicate references to Control resources.
-->
<Target Name="RemoveUnwantedPri" AfterTargets="GetPackagingOutputs">
<!--<Message Text="Files Before: @(PackagingOutputs)" Importance="high" />-->
<ItemGroup>
<PackagingOutputs Remove="@(PackagingOutputs)" Condition="'%(PackagingOutputs.Filename)%(PackagingOutputs.Extension)' == 'Microsoft.Toolkit.Uwp.UI.Controls.pri'" />
<PackagingOutputs Remove="@(PackagingOutputs)" Condition="$([System.String]::new('%(PackagingOutputs.TargetPath)').StartsWith('Microsoft.Toolkit.Uwp.UI.Controls\'))" />
</ItemGroup>
<!--<Message Text="Files After: @(PackagingOutputs)" Importance="high" />-->
</Target>
</Project>

Просмотреть файл

@ -3,7 +3,9 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Globalization;
using System.Reflection;
using Microsoft.Toolkit.Diagnostics;
using Microsoft.UI;
using Color = Windows.UI.Color;
@ -22,10 +24,7 @@ namespace Microsoft.Toolkit.Uwp.Helpers
/// <returns>The created <see cref="Color"/>.</returns>
public static Color ToColor(this string colorString)
{
if (string.IsNullOrEmpty(colorString))
{
throw new ArgumentException(nameof(colorString));
}
Guard.IsNotNullOrEmpty(colorString, nameof(colorString));
if (colorString[0] == '#')
{
@ -80,8 +79,7 @@ namespace Microsoft.Toolkit.Uwp.Helpers
return Color.FromArgb(255, r, g, b);
}
default:
throw new FormatException(string.Format("The {0} string passed in the colorString argument is not a recognized Color format.", colorString));
default: return ThrowHelper.ThrowFormatException<Color>("The string passed in the colorString argument is not a recognized Color format.");
}
}
@ -91,24 +89,24 @@ namespace Microsoft.Toolkit.Uwp.Helpers
if (values.Length == 4)
{
var scA = double.Parse(values[0].Substring(3));
var scR = double.Parse(values[1]);
var scG = double.Parse(values[2]);
var scB = double.Parse(values[3]);
var scA = double.Parse(values[0].Substring(3), CultureInfo.InvariantCulture);
var scR = double.Parse(values[1], CultureInfo.InvariantCulture);
var scG = double.Parse(values[2], CultureInfo.InvariantCulture);
var scB = double.Parse(values[3], CultureInfo.InvariantCulture);
return Color.FromArgb((byte)(scA * 255), (byte)(scR * 255), (byte)(scG * 255), (byte)(scB * 255));
}
if (values.Length == 3)
{
var scR = double.Parse(values[0].Substring(3));
var scG = double.Parse(values[1]);
var scB = double.Parse(values[2]);
var scR = double.Parse(values[0].Substring(3), CultureInfo.InvariantCulture);
var scG = double.Parse(values[1], CultureInfo.InvariantCulture);
var scB = double.Parse(values[2], CultureInfo.InvariantCulture);
return Color.FromArgb(255, (byte)(scR * 255), (byte)(scG * 255), (byte)(scB * 255));
}
throw new FormatException(string.Format("The {0} string passed in the colorString argument is not a recognized Color format (sc#[scA,]scR,scG,scB).", colorString));
return ThrowHelper.ThrowFormatException<Color>("The string passed in the colorString argument is not a recognized Color format (sc#[scA,]scR,scG,scB).");
}
var prop = typeof(Colors).GetTypeInfo().GetDeclaredProperty(colorString);
@ -118,7 +116,7 @@ namespace Microsoft.Toolkit.Uwp.Helpers
return (Color)prop.GetValue(null);
}
throw new FormatException(string.Format("The {0} string passed in the colorString argument is not a recognized Color.", colorString));
return ThrowHelper.ThrowFormatException<Color>("The string passed in the colorString argument is not a recognized Color.");
}
/// <summary>

7
SmokeTests/App.xaml Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<Application
x:Class="SmokeTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest">
</Application>

106
SmokeTests/App.xaml.cs Normal file
Просмотреть файл

@ -0,0 +1,106 @@
// 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;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace SmokeTest
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
// TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}

Двоичные данные
SmokeTests/Assets/LockScreenLogo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
SmokeTests/Assets/SplashScreen.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.5 KiB

Двоичные данные
SmokeTests/Assets/Square150x150Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.9 KiB

Двоичные данные
SmokeTests/Assets/Square44x44Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичные данные
SmokeTests/Assets/StoreLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
SmokeTests/Assets/Wide310x150Logo.scale-200.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.1 KiB

Просмотреть файл

@ -0,0 +1,17 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300">
<Button Content="Click" Click="Button_Click" HorizontalAlignment="Center"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,23 @@
// 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 Microsoft.Toolkit.HighPerformance.Helpers;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
const uint value = 0xAAAA5555u;
textBlock.Text = BitHelper.HasLookupFlag(value, 0).ToString();
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
<Button Content="Click" Command="{x:Bind TestCommand}" HorizontalAlignment="Center"/>
<TextBlock x:Name="textBlock"/>
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,25 @@
// 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 Microsoft.Toolkit.Mvvm.Input;
namespace SmokeTest
{
public sealed partial class MainPage
{
public RelayCommand TestCommand { get; }
public MainPage()
{
TestCommand = new RelayCommand(ExecuteRelayCommand);
InitializeComponent();
}
private void ExecuteRelayCommand()
{
textBlock.Text = "Clicked";
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer>
<StackPanel Padding="12">
<TextBox x:Name="RawMarkdown"
Header="Markdown"
Text="This is **Markdown**"
TextChanged="RawMarkdown_TextChanged"
AcceptsReturn="True"
MinHeight="60" />
<TextBlock
Text="Result:"
Margin="0,10,0,0" />
<TextBlock x:Name="MarkdownResult" />
</StackPanel>
</ScrollViewer>
</Page>

Просмотреть файл

@ -0,0 +1,37 @@
// 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 Microsoft.Toolkit.Parsers.Markdown;
using Windows.UI.Xaml.Controls;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
Loaded += MarkdownParserPage_Loaded;
}
private void MarkdownParserPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
UpdateMDResult();
}
private void RawMarkdown_TextChanged(object sender, TextChangedEventArgs e)
{
UpdateMDResult();
}
private void UpdateMDResult()
{
var document = new MarkdownDocument();
document.Parse(RawMarkdown.Text);
MarkdownResult.Text = $"Root type is: {document.Type.ToString()}";
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300">
<Button x:Name="ConnectButton"
Margin="0,10,0,0"
VerticalAlignment="Bottom"
Click="ConnectButton_OnClick"
Content="Connect" />
<TextBlock x:Name="textBlock"/>
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,29 @@
// 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;
using Microsoft.Toolkit.Services.Twitter;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
private void ConnectButton_OnClick(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
try
{
TwitterService.Instance.Initialize(string.Empty, string.Empty, string.Empty);
}
catch (Exception ex)
{
textBlock.Text = ex.ToString();
}
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
<Button Content="Click" Click="Button_Click" HorizontalAlignment="Center"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Center"/>
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,21 @@
// 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 Microsoft.Toolkit.Uwp.Connectivity;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
textBlock.Text = NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable.ToString();
}
}
}

Просмотреть файл

@ -0,0 +1,27 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:developerTools="using:Microsoft.Toolkit.Uwp.DeveloperTools"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<developerTools:AlignmentGrid
Opacity="0.2"
LineBrush="Firebrick"
HorizontalStep="20"
VerticalStep="20" />
<StackPanel Margin="40" BorderThickness="1" BorderBrush="{ThemeResource SystemControlForegroundAccentBrush}">
<TextBlock Margin="0,0,0,30" Text="You can use the AlignmentGrid to check if your UI elements are corrected aligned" />
<TextBlock Margin="0,0,0,30" Text="The container of these texts has a margin of (40, 40, 40, 40)" />
<TextBlock Margin="20,0,0,20" Text="This text has a margin of (20, 0, 0, 20)" />
<TextBlock Margin="40,0,0,20" Text="This text has a margin of (40, 0, 0, 20)" />
<TextBlock Margin="20,0,0,20" Text="This text has a margin of (20, 0, 0, 20)" />
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,14 @@
// 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.
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
RequestedTheme="Light"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.Resources>
<DataTemplate x:Key="ItemsControlItemTemplate1">
<Ellipse Fill="#FFAD0000" HorizontalAlignment="Left" Width="5" Height="5" Stroke="Black" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" DataContext="{Binding DataContext, ElementName=Page, Mode=OneWay}">
<Ellipse.RenderTransform>
<TranslateTransform X="{Binding DataContext.X, RelativeSource={RelativeSource TemplatedParent}}" Y="{Binding DataContext.Y, RelativeSource={RelativeSource TemplatedParent}}"/>
</Ellipse.RenderTransform>
</Ellipse>
</DataTemplate>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<Canvas ></Canvas>
</ItemsPanelTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid>
<ItemsControl x:Name="Points" ItemTemplate="{StaticResource ItemsControlItemTemplate1}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{x:Bind GazeHistory}" ItemsPanel="{StaticResource ItemsPanelTemplate1}" />
</Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,67 @@
// 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.Collections.ObjectModel;
using Windows.Devices.Input.Preview;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SmokeTest
{
public sealed partial class MainPage
{
private GazeInputSourcePreview gazeInputSourcePreview;
public ObservableCollection<Point> GazeHistory { get; } = new ObservableCollection<Point>();
public int TracePointDiameter { get; set; }
public int MaxGazeHistorySize { get; set; }
public bool ShowIntermediatePoints { get; set; }
public MainPage()
{
InitializeComponent();
ShowIntermediatePoints = false;
MaxGazeHistorySize = 100;
gazeInputSourcePreview = GazeInputSourcePreview.GetForCurrentView();
gazeInputSourcePreview.GazeMoved += GazeInputSourcePreview_GazeMoved;
}
private void UpdateGazeHistory(GazePointPreview pt)
{
if (!pt.EyeGazePosition.HasValue)
{
return;
}
var transform = (Window.Current.Content as Frame).TransformToVisual(this);
var point = transform.TransformPoint(pt.EyeGazePosition.Value);
GazeHistory.Add(point);
if (GazeHistory.Count > MaxGazeHistorySize)
{
GazeHistory.RemoveAt(0);
}
}
private void GazeInputSourcePreview_GazeMoved(GazeInputSourcePreview sender, GazeMovedPreviewEventArgs args)
{
if (!ShowIntermediatePoints)
{
UpdateGazeHistory(args.CurrentPoint);
return;
}
var points = args.GetIntermediatePoints();
foreach (var pt in points)
{
UpdateGazeHistory(pt);
}
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Button Content="Click" Click="Button_Click"/>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,44 @@
// 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 Microsoft.Toolkit.Uwp.Notifications;
using Windows.UI.Notifications;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
ToastContent content = GenerateToastContent();
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml()));
}
public static ToastContent GenerateToastContent()
{
var builder = new ToastContentBuilder().SetToastScenario(ToastScenario.Reminder)
.AddToastActivationInfo("action=viewEvent&eventId=1983", ToastActivationType.Foreground)
.AddText("Adaptive Tiles Meeting")
.AddText("Conf Room 2001 / Building 135")
.AddText("10:00 AM - 10:30 AM")
.AddComboBox(
"snoozeTime",
"15",
("1", "1 minute"),
("15", "15 minutes"),
("60", "1 hour"),
("240", "4 hours"),
("1440", "1 day"))
.AddButton(new ToastButtonSnooze() { SelectionBoxId = "snoozeTime" })
.AddButton(new ToastButtonDismiss());
return builder.Content;
}
}
}

Просмотреть файл

@ -0,0 +1,49 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions"
xmlns:animations="using:Microsoft.Toolkit.Uwp.UI.Animations"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Canvas>
<Border x:Name="Element"
Height="100"
Width="100"
Background="Red"
Canvas.Top="100"
Canvas.Left="100"
extensions:VisualExtensions.CenterPoint="50,50,0">
<animations:Implicit.ShowAnimations>
<animations:TranslationAnimation Duration="0:0:1" From="0, -200, 0" To="0" ></animations:TranslationAnimation>
<animations:OpacityAnimation Duration="0:0:1" From="0" To="1.0"></animations:OpacityAnimation>
</animations:Implicit.ShowAnimations>
<animations:Implicit.HideAnimations>
<animations:ScalarAnimation Target="Opacity" Duration="0:0:1" To="0.0"></animations:ScalarAnimation>
<animations:ScalarAnimation Target="Translation.Y" Duration="0:0:1" To="-200">
<animations:ScalarKeyFrame Key="0.1" Value="30"></animations:ScalarKeyFrame>
<animations:ScalarKeyFrame Key="0.5" Value="0.0"></animations:ScalarKeyFrame>
</animations:ScalarAnimation>
</animations:Implicit.HideAnimations>
<animations:Implicit.Animations>
<animations:Vector3Animation Target="Offset" Duration="0:0:1"></animations:Vector3Animation>
<animations:ScalarAnimation Target="RotationAngleInDegrees" ImplicitTarget="Offset" Duration="0:0:1.2" From="0" To="0">
<animations:ScalarKeyFrame Key="0.9" Value="80"></animations:ScalarKeyFrame>
</animations:ScalarAnimation>
<animations:Vector3Animation Target="Scale" Duration="0:0:1"></animations:Vector3Animation>
</animations:Implicit.Animations>
</Border>
</Canvas>
<Button Click="Button_Click" Content="Click"/>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,25 @@
// 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;
using Windows.UI.Xaml.Controls;
namespace SmokeTest
{
public sealed partial class MainPage
{
private Random _random = new Random();
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
Canvas.SetTop(Element, _random.NextDouble() * this.ActualHeight);
Canvas.SetLeft(Element, _random.NextDouble() * this.ActualWidth);
}
}
}

Просмотреть файл

@ -0,0 +1,97 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.Resources>
<DataTemplate x:Key="RowDetailsTemplate">
<StackPanel>
<TextBlock Margin="20" Text="Here are the details for the selected mountain:" />
<Grid Margin="20,10" Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Coordinates: " FontWeight="SemiBold" FontSize="13" />
<TextBlock Grid.Row="1" Text="Prominence (m): " FontWeight="SemiBold" FontSize="13" />
<TextBlock Grid.Row="2" Text="First Ascent (year): " FontWeight="SemiBold" FontSize="13" />
<TextBlock Grid.Row="3" Text="No. of ascents: " FontWeight="SemiBold" FontSize="13" />
<TextBlock Grid.Column="1" FontSize="13" Text="{Binding Coordinates}" HorizontalAlignment="Right" />
<TextBlock Grid.Row="1" Grid.Column="1" FontSize="13" Text="{Binding Prominence}" HorizontalAlignment="Right" />
<TextBlock Grid.Row="2" Grid.Column="1" FontSize="13" Text="{Binding First_ascent}" HorizontalAlignment="Right" />
<TextBlock Grid.Row="3" Grid.Column="1" FontSize="13" Text="{Binding Ascents}" HorizontalAlignment="Right" />
</Grid>
</StackPanel>
</DataTemplate>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="12">
<TextBlock Text="DataGrid Sample : Mountains" VerticalAlignment="Center" Margin="5,0" Style="{ThemeResource SubtitleTextBlockStyle}"></TextBlock>
<AppBarButton Icon="Filter" Label="Filter by">
<AppBarButton.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Name="rankLow" Text="Rank &lt; 50" />
<MenuFlyoutItem x:Name="rankHigh" Text="Rank &gt; 50" />
<MenuFlyoutSeparator />
<MenuFlyoutItem x:Name="heightLow" Text="Height &lt; 8000ft" />
<MenuFlyoutItem x:Name="heightHigh" Text="Height &gt; 8000ft" />
<MenuFlyoutSeparator />
<MenuFlyoutItem x:Name="clearFilter" Text="Remove Filter" />
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton x:Name="groupButton" Icon="List" Label="Group by" />
</StackPanel>
<controls:DataGrid
Grid.Row="1"
x:Name="dataGrid"
Margin="12"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible"
AlternatingRowBackground="Transparent"
AlternatingRowForeground="Gray"
AreRowDetailsFrozen="False"
AreRowGroupHeadersFrozen="True"
AutoGenerateColumns="False"
CanUserSortColumns="False"
CanUserReorderColumns="True"
CanUserResizeColumns="True"
ColumnHeaderHeight="32"
MaxColumnWidth="400"
FrozenColumnCount="0"
GridLinesVisibility="None"
HeadersVisibility="Column"
IsReadOnly="False"
RowDetailsTemplate="{StaticResource RowDetailsTemplate}"
RowDetailsVisibilityMode="Collapsed"
SelectionMode="Extended"
RowGroupHeaderPropertyNameAlternative="Range"
Sorting="DataGrid_Sorting"
LoadingRowGroup="DataGrid_LoadingRowGroup">
<controls:DataGrid.Columns>
<controls:DataGridTextColumn Header="Rank" Binding="{Binding Rank}" Tag="Rank" />
<controls:DataGridComboBoxColumn Header="Mountain" Binding="{Binding Mountain}" Tag="Mountain" />
<controls:DataGridTextColumn Header="Height (m)" Binding="{Binding Height_m}" Tag="Height_m" />
<controls:DataGridTextColumn Header="Range" Binding="{Binding Range}" Tag="Range" />
<controls:DataGridTextColumn Header="Parent Mountain" Binding="{Binding Parent_mountain}" Tag="Parent_mountain" />
</controls:DataGrid.Columns>
</controls:DataGrid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,499 @@
// 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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Controls;
using Windows.UI.Xaml.Data;
namespace SmokeTest
{
public sealed partial class MainPage
{
private DataGridDataSource viewModel = new DataGridDataSource();
public MainPage()
{
InitializeComponent();
dataGrid.ItemsSource = viewModel.GetData();
}
private void DataGrid_Sorting(object sender, Microsoft.Toolkit.Uwp.UI.Controls.DataGridColumnEventArgs e)
{
// Clear previous sorted column if we start sorting a different column
string previousSortedColumn = viewModel.CachedSortedColumn;
if (previousSortedColumn != string.Empty)
{
foreach (DataGridColumn dataGridColumn in dataGrid.Columns)
{
if (dataGridColumn.Tag != null && dataGridColumn.Tag.ToString() == previousSortedColumn &&
(e.Column.Tag == null || previousSortedColumn != e.Column.Tag.ToString()))
{
dataGridColumn.SortDirection = null;
}
}
}
// Toggle clicked column's sorting method
if (e.Column.Tag != null)
{
if (e.Column.SortDirection == null)
{
dataGrid.ItemsSource = viewModel.SortData(e.Column.Tag.ToString(), true);
e.Column.SortDirection = DataGridSortDirection.Ascending;
}
else if (e.Column.SortDirection == DataGridSortDirection.Ascending)
{
dataGrid.ItemsSource = viewModel.SortData(e.Column.Tag.ToString(), false);
e.Column.SortDirection = DataGridSortDirection.Descending;
}
else
{
dataGrid.ItemsSource = viewModel.FilterData(DataGridDataSource.FilterOptions.All);
e.Column.SortDirection = null;
}
}
}
private void DataGrid_LoadingRowGroup(object sender, DataGridRowGroupHeaderEventArgs e)
{
ICollectionViewGroup group = e.RowGroupHeader.CollectionViewGroup;
DataGridDataItem item = group.GroupItems[0] as DataGridDataItem;
e.RowGroupHeader.PropertyValue = item.Range;
}
}
public class DataGridDataItem : INotifyDataErrorInfo, IComparable
{
private Dictionary<string, List<string>> _errors = new Dictionary<string, List<string>>();
private uint _rank;
private string _mountain;
private uint _height;
private string _range;
private string _parentMountain;
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
public uint Rank
{
get
{
return _rank;
}
set
{
if (_rank != value)
{
_rank = value;
}
}
}
public string Mountain
{
get
{
return _mountain;
}
set
{
if (_mountain != value)
{
_mountain = value;
bool isMountainValid = !_errors.Keys.Contains("Mountain");
if (_mountain == string.Empty && isMountainValid)
{
List<string> errors = new List<string>();
errors.Add("Mountain name cannot be empty");
_errors.Add("Mountain", errors);
this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs("Mountain"));
}
else if (_mountain != string.Empty && !isMountainValid)
{
_errors.Remove("Mountain");
this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs("Mountain"));
}
}
}
}
public uint Height_m
{
get
{
return _height;
}
set
{
if (_height != value)
{
_height = value;
}
}
}
public string Range
{
get
{
return _range;
}
set
{
if (_range != value)
{
_range = value;
bool isRangeValid = !_errors.Keys.Contains("Range");
if (_range == string.Empty && isRangeValid)
{
List<string> errors = new List<string>();
errors.Add("Range name cannot be empty");
_errors.Add("Range", errors);
this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs("Range"));
}
else if (_range != string.Empty && !isRangeValid)
{
_errors.Remove("Range");
this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs("Range"));
}
}
}
}
public string Parent_mountain
{
get
{
return _parentMountain;
}
set
{
if (_parentMountain != value)
{
_parentMountain = value;
bool isParentValid = !_errors.Keys.Contains("Parent_mountain");
if (_parentMountain == string.Empty && isParentValid)
{
List<string> errors = new List<string>();
errors.Add("Parent_mountain name cannot be empty");
_errors.Add("Parent_mountain", errors);
this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs("Parent_mountain"));
}
else if (_parentMountain != string.Empty && !isParentValid)
{
_errors.Remove("Parent_mountain");
this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs("Parent_mountain"));
}
}
}
}
public string Coordinates { get; set; }
public uint Prominence { get; set; }
public uint First_ascent { get; set; }
public string Ascents { get; set; }
bool INotifyDataErrorInfo.HasErrors
{
get
{
return _errors.Keys.Count > 0;
}
}
IEnumerable INotifyDataErrorInfo.GetErrors(string propertyName)
{
if (propertyName == null)
{
propertyName = string.Empty;
}
if (_errors.Keys.Contains(propertyName))
{
return _errors[propertyName];
}
else
{
return null;
}
}
int IComparable.CompareTo(object obj)
{
int lnCompare = Range.CompareTo((obj as DataGridDataItem).Range);
if (lnCompare == 0)
{
return Parent_mountain.CompareTo((obj as DataGridDataItem).Parent_mountain);
}
else
{
return lnCompare;
}
}
}
public class DataGridDataSource
{
private const string File = @"1,Mount Everest,8848,Mahalangur Himalaya,27d59m17sN 86d55m31sE,8848,none,1953,>>145 (121)
2, K2/Qogir,8611,Baltoro Karakoram,35d52m53sN 76d30m48sE,4017,Mount Everest,1954,45 (44)
3,Kangchenjunga,8586,Kangchenjunga Himalaya,27d42m12sN 88d08m51sE*,3922,Mount Everest,1955,38 (24)
4,Lhotse,8516,Mahalangur Himalaya,27d57m42sN 86d55m59sE,610,Mount Everest,1956,26 (26)
5,Makalu,8485,Mahalangur Himalaya,27d53m23sN 87d5m20sE,2386,Mount Everest,1955,45 (52)
6,Cho Oyu,8188, Mahalangur Himalaya,28d05m39sN 86d39m39sE,2340,Mount Everest,1954,79 (28)
7,Dhaulagiri I,8167, Dhaulagiri Himalaya,28d41m48sN 83d29m35sE,3357,K2,1960,51 (39)
8,Manaslu,8163,Manaslu Himalaya,28d33m00sN 84d33m35sE,3092,Cho Oyu,1956,49 (45)
9,Nanga Parbat,8126, Nanga Parbat Himalaya,35d14m14sN 74d35m21sE,4608,Dhaulagiri,1953,52 (67)
10,Annapurna I,8091, Annapurna Himalaya,28d35m44sN 83d49m13sE,2984,Cho Oyu,1950,36 (47)
11,Gasherbrum I,8080, Baltoro Karakoram,35d43m28sN 76d41m47sE,2155,K2,1958,31 (16)
12,Broad Peak/K3,8051,Baltoro Karakoram,35d48m38sN 76d34m06sE,1701,Gasherbrum I,1957,39 (19)
13,Gasherbrum II/K4,8034,Baltoro Karakoram,35d45m28sN 76d39m12sE,1523,Gasherbrum I,1956,54 (12)
14,Shishapangma,8027,Jugal Himalaya,28d21m12sN 85d46m43sE,2897,Cho Oyu,1964,43 (19)
15,Gyachung Kang,7952, Mahalangur Himalaya,28d05m53sN 86d44m42sE,700,Cho Oyu,1964,5 (3)
15,Gasherbrum III,7946, Baltoro Karakoram,35d45m33sN 76d38m30sE,355,Gasherbrum II,1975,2 (2)
16,Annapurna II,7937, Annapurna Himalaya,28d32m05sN 84d07m19sE,2437,Annapurna I,1960,6 (19)
17,Gasherbrum IV,7932, Baltoro Karakoram,35d45m38sN 76d36m58sE,715,Gasherbrum III,1958,4 (11)
18,Himalchuli,7893,Manaslu Himalaya,28d26m12sN 84d38m23sE*,1633,Manaslu,1960,6 (12)
19,Distaghil Sar,7884, Hispar Karakoram,36d19m33sN 75d11m16sE,2525,K2,1960,3 (5)
20,Ngadi Chuli,7871, Manaslu Himalaya,28d30m12sN 84d34m00sE,1020,Manaslu,1970,2 (6)";
private static ObservableCollection<DataGridDataItem> _items;
private static List<string> _mountains;
private static CollectionViewSource groupedItems;
private string _cachedSortedColumn = string.Empty;
// Loading data
public IEnumerable<DataGridDataItem> GetData()
{
_items = new ObservableCollection<DataGridDataItem>();
using (StringReader sr = new StringReader(File))
{
string line;
while ((line = sr.ReadLine()) != null)
{
string[] values = line.Split(',');
_items.Add(
new DataGridDataItem()
{
Rank = uint.Parse(values[0]),
Mountain = values[1],
Height_m = uint.Parse(values[2]),
Range = values[3],
Coordinates = values[4],
Prominence = uint.Parse(values[5]),
Parent_mountain = values[6],
First_ascent = uint.Parse(values[7]),
Ascents = values[8]
});
}
}
return _items;
}
// Load mountains into separate collection for use in combobox column
public IEnumerable<string> GetMountains()
{
if (_items == null || !_items.Any())
{
GetData();
}
_mountains = _items?.OrderBy(x => x.Mountain).Select(x => x.Mountain).Distinct().ToList();
return _mountains;
}
// Sorting implementation using LINQ
public string CachedSortedColumn
{
get
{
return _cachedSortedColumn;
}
set
{
_cachedSortedColumn = value;
}
}
public ObservableCollection<DataGridDataItem> SortData(string sortBy, bool ascending)
{
_cachedSortedColumn = sortBy;
switch (sortBy)
{
case "Rank":
if (ascending)
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Rank ascending
select item);
}
else
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Rank descending
select item);
}
case "Parent_mountain":
if (ascending)
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Parent_mountain ascending
select item);
}
else
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Parent_mountain descending
select item);
}
case "Mountain":
if (ascending)
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Mountain ascending
select item);
}
else
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Mountain descending
select item);
}
case "Height_m":
if (ascending)
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Height_m ascending
select item);
}
else
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Height_m descending
select item);
}
case "Range":
if (ascending)
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Range ascending
select item);
}
else
{
return new ObservableCollection<DataGridDataItem>(from item in _items
orderby item.Range descending
select item);
}
}
return _items;
}
// Grouping implementation using LINQ
public CollectionViewSource GroupData()
{
ObservableCollection<GroupInfoCollection<DataGridDataItem>> groups = new ObservableCollection<GroupInfoCollection<DataGridDataItem>>();
var query = from item in _items
orderby item
group item by item.Range into g
select new { GroupName = g.Key, Items = g };
foreach (var g in query)
{
GroupInfoCollection<DataGridDataItem> info = new GroupInfoCollection<DataGridDataItem>();
info.Key = g.GroupName;
foreach (var item in g.Items)
{
info.Add(item);
}
groups.Add(info);
}
groupedItems = new CollectionViewSource();
groupedItems.IsSourceGrouped = true;
groupedItems.Source = groups;
return groupedItems;
}
public class GroupInfoCollection<T> : ObservableCollection<T>
{
public object Key { get; set; }
public new IEnumerator<T> GetEnumerator()
{
return (IEnumerator<T>)base.GetEnumerator();
}
}
// Filtering implementation using LINQ
public enum FilterOptions
{
All = -1,
Rank_Low = 0,
Rank_High = 1,
Height_Low = 2,
Height_High = 3
}
public ObservableCollection<DataGridDataItem> FilterData(FilterOptions filterBy)
{
switch (filterBy)
{
case FilterOptions.All:
return new ObservableCollection<DataGridDataItem>(_items);
case FilterOptions.Rank_Low:
return new ObservableCollection<DataGridDataItem>(from item in _items
where item.Rank < 50
select item);
case FilterOptions.Rank_High:
return new ObservableCollection<DataGridDataItem>(from item in _items
where item.Rank > 50
select item);
case FilterOptions.Height_High:
return new ObservableCollection<DataGridDataItem>(from item in _items
where item.Height_m > 8000
select item);
case FilterOptions.Height_Low:
return new ObservableCollection<DataGridDataItem>(from item in _items
where item.Height_m < 8000
select item);
}
return _items;
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:winui="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<DataTemplate x:Key="WrapTemplate">
<Border Width="{Binding Width}" Height="50">
<Border.Background>
<SolidColorBrush Color="{Binding Color}"/>
</Border.Background>
<TextBlock Text="{Binding Index}" FontSize="20"/>
</Border>
</DataTemplate>
</Page.Resources>
<Grid Padding="48">
<winui:ItemsRepeaterScrollHost>
<!-- Needed for 1803 and below -->
<ScrollViewer x:Name="WrapScrollParent">
<winui:ItemsRepeater x:Name="WrapRepeater"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
ItemsSource="{x:Bind Items}"
ItemTemplate="{StaticResource WrapTemplate}">
<winui:ItemsRepeater.Layout>
<controls:WrapLayout x:Name="Wrap"
VerticalSpacing="5"
HorizontalSpacing="5"/>
</winui:ItemsRepeater.Layout>
</winui:ItemsRepeater>
</ScrollViewer>
</winui:ItemsRepeaterScrollHost>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,40 @@
// 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;
using System.Collections.ObjectModel;
using Windows.UI;
namespace SmokeTest
{
public sealed partial class MainPage
{
public ObservableCollection<Item> Items { get; } = new ObservableCollection<Item>();
private readonly Random _random;
public class Item
{
public int Index { get; internal set; }
public int Width { get; internal set; }
public int Height { get; internal set; }
public Color Color { get; internal set; }
}
public MainPage()
{
InitializeComponent();
_random = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < _random.Next(1000, 5000); i++)
{
var item = new Item { Index = i, Width = _random.Next(50, 250), Height = _random.Next(50, 250), Color = Color.FromArgb(255, (byte)_random.Next(0, 255), (byte)_random.Next(0, 255), (byte)_random.Next(0, 255)) };
Items.Add(item);
}
}
}
}

Просмотреть файл

@ -0,0 +1,50 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="12,12,12,0"
FontSize="18"
Text="Regular Text" />
<TextBox x:Name="UnformattedText"
Grid.Row="1"
Margin="12"
AcceptsReturn="True"
Text="**Try it live!** Type in the *unformatted text box* above!"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TextWrapping="Wrap" />
<TextBlock Grid.Row="2"
Margin="12,12,12,0"
FontSize="18"
Text="Markdown Text" />
<ScrollViewer Grid.Row="3"
Margin="12"
BorderBrush="{ThemeResource AppBarBorderThemeBrush}"
BorderThickness="2"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Visible">
<controls:MarkdownTextBlock x:Name="MarkdownText"
Margin="6"
Header1Foreground="{ThemeResource SystemControlForegroundAccentBrush}"
Text="{Binding ElementName=UnformattedText, Path=Text}"
SchemeList="companyportal,randomscheme"
UriPrefix="ms-appx://" />
</ScrollViewer>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,14 @@
// 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.
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,123 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<Style x:Key="BladeStyle" TargetType="controls:BladeItem">
<Setter Property="Header" Value="Default Blade" />
<Setter Property="Width" Value="400" />
<Setter Property="IsOpen" Value="True" />
</Style>
</Page.Resources>
<Grid>
<controls:BladeView x:Name="BladeView"
Margin="0"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BladeMode="Normal"
AutoCollapseCountThreshold="4">
<controls:BladeItem x:Name="FirstBlade"
Header="Test"
Style="{StaticResource BladeStyle}"
TitleBarVisibility="Collapsed">
<StackPanel Margin="24">
<TextBlock Text="This first blade has a hidden TitleBar, so you can't close it."
TextWrapping="WrapWholeWords" />
<TextBlock Margin="0,12,0,0"
Text="The buttons below toggle more blades on and off. The blades appear in the order that they're opened."
TextWrapping="WrapWholeWords" />
<ToggleButton Margin="0,24,0,0"
Content="Default Blade"
IsChecked="{Binding IsOpen, Mode=TwoWay, ElementName=SecondBlade}" />
<ToggleButton Margin="0,24,0,0"
Content="Custom Titlebar"
IsChecked="{Binding IsOpen, Mode=TwoWay, ElementName=ThirdBlade}" />
<ToggleButton Margin="0,24,0,0"
Content="Custom Close Button"
IsChecked="{Binding IsOpen, Mode=TwoWay, ElementName=FourthBlade}" />
<Button x:Name="AddBlade"
Margin="0,24,0,0"
Content="Add Blade" />
</StackPanel>
</controls:BladeItem>
<controls:BladeItem x:Name="SecondBlade"
Header="Default blade"
IsOpen="False"
Style="{StaticResource BladeStyle}">
<TextBlock Margin="24"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="This is a blade with all settings set to default." />
</controls:BladeItem>
<controls:BladeItem x:Name="ThirdBlade"
Header="Custom title bar"
Style="{StaticResource BladeStyle}"
IsOpen="False"
TitleBarBackground="DarkSlateGray"
CloseButtonForeground="White">
<controls:BladeItem.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Foreground="White" />
</DataTemplate>
</controls:BladeItem.HeaderTemplate>
<TextBlock Margin="24"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="This is a blade with custom titlebar colors." />
</controls:BladeItem>
<controls:BladeItem x:Name="FourthBlade"
Header="Custom close button color"
Style="{StaticResource BladeStyle}"
CloseButtonBackground="DarkSlateGray"
CloseButtonForeground="White"
IsOpen="False">
<TextBlock Margin="24"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="This is a blade with a custom close button color." />
</controls:BladeItem>
</controls:BladeView>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Full">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600" />
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="Small">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="BladeView.Padding" Value="12" />
<Setter Target="FirstBlade.Width" Value="280" />
<Setter Target="FirstBlade.FontSize" Value="12" />
<Setter Target="SecondBlade.Width" Value="280" />
<Setter Target="SecondBlade.FontSize" Value="12" />
<Setter Target="ThirdBlade.Width" Value="280" />
<Setter Target="ThirdBlade.FontSize" Value="12" />
<Setter Target="FourthBlade.Width" Value="280" />
<Setter Target="FourthBlade.FontSize" Value="12" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,14 @@
// 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.
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,31 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Image Source="ms-appx:///Assets/SplashScreen.png"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ProgressRing IsActive="True" Grid.ColumnSpan="2"
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" Width="200" Height="200"/>
<Border BorderBrush="Black" BorderThickness="1"
Grid.Column="2"
Height="400">
<Border.Background>
<media:BackdropBlurBrush Amount="3" />
</Border.Background>
</Border>
</Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,14 @@
// 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.
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,35 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<ScrollViewer>
<Grid Height="2200">
<Border x:Name="EffectElementHost"
Width="200"
Height="200"
Background="Gray">
<interactivity:Interaction.Behaviors>
<behaviors:ViewportBehavior x:Name="ViewportBehavior" />
</interactivity:Interaction.Behaviors>
<Image x:Name="EffectElement"
Width="100"
Height="100" />
</Border>
</Grid>
</ScrollViewer>
<TextBlock HorizontalAlignment="Left"
VerticalAlignment="Top"
Foreground="OrangeRed"
IsHitTestVisible="False"
Text="Please scroll down to see the effect." />
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,60 @@
// 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;
using System.Diagnostics;
using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Behaviors;
using Microsoft.Xaml.Interactivity;
using Windows.UI.Xaml.Media.Imaging;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
Loaded += this.MainPage_Loaded;
}
private void MainPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var behaviors = Interaction.GetBehaviors(EffectElementHost);
var viewportBehavior = behaviors.OfType<ViewportBehavior>().FirstOrDefault();
if (viewportBehavior != null)
{
viewportBehavior.EnteredViewport += EffectElementHost_EnteredViewport;
viewportBehavior.EnteringViewport += EffectElementHost_EnteringViewport;
viewportBehavior.ExitedViewport += EffectElementHost_ExitedViewport;
viewportBehavior.ExitingViewport += EffectElementHost_ExitingViewport;
}
}
private void EffectElementHost_EnteredViewport(object sender, EventArgs e)
{
Debug.WriteLine("Entered viewport");
}
private void EffectElementHost_EnteringViewport(object sender, EventArgs e)
{
Debug.WriteLine("Entering viewport");
EffectElement.Source = new BitmapImage(new Uri("ms-appx:///Assets/ToolkitLogo.png"));
}
private void EffectElementHost_ExitedViewport(object sender, EventArgs e)
{
Debug.WriteLine("Exited viewport");
EffectElement.Source = null;
}
private void EffectElementHost_ExitingViewport(object sender, EventArgs e)
{
Debug.WriteLine("Exiting viewport");
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Image x:Name="image"/>
<Button Content="Click" Click="Button_Click"/>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,67 @@
// 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;
using Microsoft.Toolkit.Uwp.Helpers;
using Windows.Graphics.Imaging;
using Windows.Media;
using Windows.System;
using Windows.UI.Xaml.Media.Imaging;
namespace SmokeTest
{
public sealed partial class MainPage
{
private CameraHelper _cameraHelper;
private DispatcherQueue _dispatcherQueue;
public MainPage()
{
InitializeComponent();
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();
image.Source = new SoftwareBitmapSource();
}
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (_cameraHelper != null)
{
_cameraHelper.FrameArrived -= CameraHelper_FrameArrived;
await _cameraHelper.CleanUpAsync();
}
_cameraHelper = new CameraHelper();
var result = await _cameraHelper.InitializeAndStartCaptureAsync();
if (result == CameraHelperResult.Success)
{
_cameraHelper.FrameArrived += CameraHelper_FrameArrived;
}
else
{
var errorMessage = result.ToString();
}
}
private void CameraHelper_FrameArrived(object sender, FrameEventArgs e)
{
VideoFrame currentVideoFrame = e.VideoFrame;
SoftwareBitmap softwareBitmap = currentVideoFrame.SoftwareBitmap;
if (softwareBitmap.BitmapPixelFormat != BitmapPixelFormat.Bgra8 || softwareBitmap.BitmapAlphaMode == BitmapAlphaMode.Straight)
{
softwareBitmap = SoftwareBitmap.Convert(softwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied);
}
_dispatcherQueue.TryEnqueue(async () =>
{
if (image.Source is SoftwareBitmapSource softwareBitmapSource)
{
await softwareBitmapSource.SetBitmapAsync(softwareBitmap);
}
});
}
}
}

Просмотреть файл

@ -0,0 +1,18 @@
<Page
x:Class="SmokeTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmokeTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
<TextBox x:Name="textBox"/>
<Button Content="Is Email?" Click="Button_Click" HorizontalAlignment="Center"/>
<TextBlock x:Name="textBlock"/>
</StackPanel>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,21 @@
// 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 Microsoft.Toolkit.Extensions;
namespace SmokeTest
{
public sealed partial class MainPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
textBlock.Text = textBox.Text?.IsEmail().ToString() ?? "False";
}
}
}

Просмотреть файл

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
IgnorableNamespaces="uap mp uap3">
<Identity
Name="96554a00-b926-4130-b09f-f2a0777f3d09"
Publisher="CN=alzollin"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="96554a00-b926-4130-b09f-f2a0777f3d09" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>SmokeTest</DisplayName>
<PublisherDisplayName>alzollin</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="SmokeTest.App">
<uap:VisualElements
DisplayName="SmokeTest"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="SmokeTest"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
<uap3:Capability Name="remoteSystem" />
<DeviceCapability Name="location" />
<DeviceCapability Name="bluetooth" />
<DeviceCapability Name="webcam" />
<DeviceCapability Name="gazeInput" />
</Capabilities>
</Package>

Просмотреть файл

@ -0,0 +1,31 @@
// 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.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SmokeTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SmokeTest")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: ComVisible(false)]

Просмотреть файл

@ -0,0 +1,31 @@
<!--
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
developers. However, you can modify these parameters to modify the behavior of the .NET Native
optimizer.
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
To fully enable reflection for App1.MyClass and all of its public/private members
<Type Name="App1.MyClass" Dynamic="Required All"/>
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
</Application>
</Directives>

129
SmokeTests/SmokeTest.csproj Normal file
Просмотреть файл

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<!-- - - - - - Don't check-in changes in between this lines. Used for development. - - - - - -->
<PropertyGroup Condition="'$(CurrentProject)' == ''">
<!-- When writting the SmokeTests, change this to whichever Toolkit project you want to build a test to, then reload the project -->
<CurrentProject>Microsoft.Toolkit.Uwp.UI.Controls</CurrentProject>
</PropertyGroup>
<!-- - - - - - Don't check-in changes in between this lines. Used for development. - - - - - -->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SmokeTest</RootNamespace>
<AssemblyName>SmokeTest.$(CurrentProject)</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.$(DefaultTargetPlatformVersion).0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.$(DefaultTargetPlatformMinVersion).0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<AppxBundlePlatforms>$(Platform)</AppxBundlePlatforms>
<AppxBundle>Always</AppxBundle>
<UapAppxPackageBuildMode>StoreUpload</UapAppxPackageBuildMode>
<PlatformTarget>$(Platform)</PlatformTarget>
<NoWarn>;2008;SA0001;SA1601</NoWarn>
<Prefer32Bit>true</Prefer32Bit>
<ErrorReport>prompt</ErrorReport>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(CurrentProject)' != ''">
<AppxPackageName>SmokeTest_$(CurrentProject)</AppxPackageName>
<IntermediateOutputPath>obj\$(CurrentProject)\</IntermediateOutputPath>
<OutputPath>bin\$(CurrentProject)\$(Platform)\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<!-- These empty PropertyGroup just make VS happy -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM64' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM64' ">
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup Condition="'$(CurrentProject)' != ''">
<Compile Include="$(CurrentProject)\*.cs" />
<Page Include="$(CurrentProject)\*.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.10</Version>
</PackageReference>
</ItemGroup>
<!-- Only the Layout package have a dependency on WinUI -->
<ItemGroup Condition="$(CurrentProject) == 'Microsoft.Toolkit.Uwp.UI.Controls.Layout'">
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.4.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(CurrentProject)' != ''">
<PackageReference Include="$(CurrentProject)" Version="7.*-*" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Target Name="BeforeBuild">
<ItemGroup>
<ToolkitNugets Include="../bin/nupkg/$(CurrentProject).*.nupkg"/>
<ToolkitNuget Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', `$(CurrentProject).([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?.nupkg`))" Include="@(ToolkitNugets)"/>
</ItemGroup>
<Error Condition="'@(ToolkitNuget)' == ''" Text="NuGet $(CurrentProject).[SEMVER].nupkg doesn't exist!"/>
</Target>
</Project>

51
SmokeTests/SmokeTest.sln Normal file
Просмотреть файл

@ -0,0 +1,51 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmokeTest", "SmokeTest.csproj", "{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|ARM.ActiveCfg = Debug|ARM
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|ARM.Build.0 = Debug|ARM
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|ARM.Deploy.0 = Debug|ARM
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|ARM64.ActiveCfg = Debug|ARM64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|ARM64.Build.0 = Debug|ARM64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|ARM64.Deploy.0 = Debug|ARM64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|x64.ActiveCfg = Debug|x64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|x64.Build.0 = Debug|x64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|x64.Deploy.0 = Debug|x64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|x86.ActiveCfg = Debug|x86
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|x86.Build.0 = Debug|x86
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Debug|x86.Deploy.0 = Debug|x86
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|ARM.ActiveCfg = Release|ARM
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|ARM.Build.0 = Release|ARM
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|ARM.Deploy.0 = Release|ARM
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|ARM64.ActiveCfg = Release|ARM64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|ARM64.Build.0 = Release|ARM64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|ARM64.Deploy.0 = Release|ARM64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|x64.ActiveCfg = Release|x64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|x64.Build.0 = Release|x64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|x64.Deploy.0 = Release|x64
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|x86.ActiveCfg = Release|x86
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|x86.Build.0 = Release|x86
{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8A672016-FF33-4C67-9309-5230BCE67EF6}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="Current" DefaultTargets="Build">
<PropertyGroup>
<BuildPlatforms>x86</BuildPlatforms>
<BuildConfigurations>Release</BuildConfigurations>
<ToolkitPackages>Microsoft.Toolkit;Microsoft.Toolkit.HighPerformance;Microsoft.Toolkit.Parsers;Microsoft.Toolkit.Mvvm;Microsoft.Toolkit.Services;Microsoft.Toolkit.Uwp;Microsoft.Toolkit.Uwp.Connectivity;Microsoft.Toolkit.Uwp.DeveloperTools;Microsoft.Toolkit.Uwp.Input.GazeInteraction;Microsoft.Toolkit.Uwp.Notifications;Microsoft.Toolkit.Uwp.UI;Microsoft.Toolkit.Uwp.UI.Animations;Microsoft.Toolkit.Uwp.UI.Controls;Microsoft.Toolkit.Uwp.UI.Controls.DataGrid;Microsoft.Toolkit.Uwp.UI.Controls.Layout;Microsoft.Toolkit.Uwp.UI.Media;Microsoft.Toolkit.Uwp.UI.Controls.Markdown</ToolkitPackages>
</PropertyGroup>
<Target Name="Build"
DependsOnTargets="ChooseProjectsToBuild"
Inputs="@(ProjectsToBuild)"
Outputs="%(Filename)">
<Message Importance="High" Text="Building project %(ProjectsToBuild.Filename): (%(ProjectsToBuild.Configuration)|%(ProjectsToBuild.Platform))" />
<MSBuild Projects="SmokeTest.csproj"
Targets="restore;build"
Properties="CurrentProject=%(ProjectsToBuild.Identity);Configuration=%(ProjectsToBuild.Configuration);Platform=%(ProjectsToBuild.Platform)"/>
</Target>
<Target Name="ChooseProjectsToBuild" DependsOnTargets="CheckNugets">
<ItemGroup>
<BuildPlatform Include="$(BuildPlatforms)" />
<BuildConfiguration Include="$(BuildConfigurations)" />
<ToolkitPackage Include="$(ToolkitPackages)" />
<ToolkitProject Include="@(ToolkitPackage)">
<Platforms>x86;x64;ARM;ARM64</Platforms>
<BinDir>bin</BinDir>
<AssemblyName>%(ToolkitPackage.Identity)</AssemblyName>
</ToolkitProject>
<CandidateProjects Include="@(ToolkitProject);@(AnyCPUProject)">
<Platform>%(BuildPlatform.Identity)</Platform>
</CandidateProjects>
<FilteredProjects Include="@(CandidateProjects)" Condition="$([System.String]::new('%(CandidateProjects.Platforms)').Contains('%(CandidateProjects.Platform)'))" />
<ProjectsPerConfig Include="@(FilteredProjects)">
<Configuration>%(BuildConfiguration.Identity)</Configuration>
</ProjectsPerConfig>
<ProjectsToBuild Include="@(ProjectsPerConfig)">
<AdditionalProperties>Platform=%(ProjectsPerConfig.Platform);Configuration=%(ProjectsPerConfig.Configuration)</AdditionalProperties>
</ProjectsToBuild>
</ItemGroup>
</Target>
<Target Name="CheckNugets">
<PropertyGroup>
<ToolkitNugets>../bin/nupkg/*.nupkg</ToolkitNugets>
</PropertyGroup>
<ItemGroup>
<ToolkitNugets Include="$(ToolkitNugets)" />
</ItemGroup>
<Error Condition="'@(ToolkitNugets)' == ''" Text="Directory '$(ToolkitNugets)' is empty"/>
</Target>
</Project>

8
SmokeTests/nuget.config Normal file
Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Local" value="..\bin\nupkg" />
</packageSources>
</configuration>

Просмотреть файл

@ -9,7 +9,7 @@
<!-- .NET Core 2.1 doesn't have the Unsafe type -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -160,7 +160,7 @@
<Version>1.4.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>4.7.1</Version>
<Version>5.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -69,6 +69,9 @@ jobs:
- powershell: .\build\build.ps1 -target=Package
displayName: Package
# - powershell: .\build\build.ps1 -target=SmokeTest
# displayName: SmokeTest
- task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
@ -106,3 +109,16 @@ jobs:
pathToPublish: .\bin\nupkg
artifactType: container
artifactName: Packages
# - task: CopyFiles@2
# inputs:
# sourceFolder: .\SmokeTests\AppPackages
# contents: '**\*.msixbundle'
# targetFolder: $(build.artifactstagingdirectory)\SmokeTestBundles
# - task: PublishBuildArtifacts@1
# displayName: Publish Smoke Test Artifacts
# inputs:
# pathToPublish: $(build.artifactstagingdirectory)\SmokeTestBundles
# artifactType: container
# artifactName: SmokeTestBundles

Просмотреть файл

@ -303,6 +303,13 @@ Task("Test")
}
}).DeferOnError();
Task("SmokeTest")
.Description("Runs all Smoke Tests")
.Does(() =>
{
NuGetRestore(baseDir + "/SmokeTests/SmokeTest.csproj");
MSBuild(baseDir + "/SmokeTests/SmokeTests.proj");
}).DeferOnError();
Task("MSTestUITest")
.Description("Runs UITests using MSTest")