Merge branch 'main' into winui

# Conflicts:
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/SampleLiveTiles.gif
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/SampleToast.gif
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/WeatherTileLarge.png
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/WeatherTileMedium.png
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/WeatherTileSmall.png
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/WeatherTileWide.png
#	CommunityToolkit.WinUI.SampleApp.Package/Images/NotificationAssets/WeatherToast.png
#	CommunityToolkit.WinUI.SampleApp/SamplePages/LiveTile/LiveTilePage.xaml
#	CommunityToolkit.WinUI.SampleApp/SamplePages/LiveTile/LiveTilePage.xaml.cs
#	CommunityToolkit.WinUI.SampleApp/SamplePages/Toast/ToastPage.xaml.cs
#	CommunityToolkit.WinUI.SampleApp/SamplePages/WeatherLiveTileAndToast/WeatherLiveTileAndToastPage.xaml
#	CommunityToolkit.WinUI.SampleApp/SamplePages/WeatherLiveTileAndToast/WeatherLiveTileAndToastPage.xaml.cs
#	Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj
This commit is contained in:
Alexandre Zollinger Chohfi 2021-09-20 14:10:54 -07:00
Родитель 5c5c487205 fa96904bd4
Коммит 1427242853
14 изменённых файлов: 69 добавлений и 189 удалений

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

После

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

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

После

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

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

После

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

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

После

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

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

После

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

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

После

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

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

После

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

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

@ -36,9 +36,6 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed">
<Version>2.0.4</Version>
</PackageReference>
<PackageReference Include="NotificationsVisualizerLibrary.WinUI">
<Version>2.0.1</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>

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

@ -3,8 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:visualizer="using:NotificationsVisualizerLibrary"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
mc:Ignorable="d">
<Page.Resources>
@ -23,7 +21,8 @@
Margin="20,20,20,0"
HorizontalAlignment="Stretch"
Click="ButtonPinTile_Click"
Content="Pin Tile" />
Content="Pin Tile"
Style="{ThemeResource AccentButtonStyle}" />
<RichTextBlock Margin="20,10,20,0">
<Paragraph>Click the button to pin a secondary tile and send a notification to the tile, displaying rich visual content. The previews below show you what the tile will look like when you pin it.</Paragraph>
@ -35,52 +34,10 @@
</Paragraph>
</RichTextBlock>
<controls:WrapPanel
Margin="18"
HorizontalAlignment="Center">
<StackPanel
HorizontalAlignment="Center"
Padding="20"
Background="{ThemeResource Brush-Grey-04}"
Margin="10">
<TextBlock
Text="MEDIUM"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="MediumPreviewTile"
IsAnimationEnabled="False"
TileSize="Medium"
HorizontalAlignment="Center" />
</StackPanel>
<StackPanel
HorizontalAlignment="Center"
Padding="20"
Background="{ThemeResource Brush-Grey-04}"
Margin="10">
<TextBlock
Text="WIDE"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="WidePreviewTile"
IsAnimationEnabled="False"
TileSize="Wide"
HorizontalAlignment="Center" />
</StackPanel>
<StackPanel
HorizontalAlignment="Center"
Padding="20"
Background="{ThemeResource Brush-Grey-04}"
Margin="10">
<TextBlock
Text="LARGE"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="LargePreviewTile"
IsAnimationEnabled="False"
TileSize="Large"
HorizontalAlignment="Center" />
</StackPanel>
</controls:WrapPanel>
<Border Background="{ThemeResource Brush-Grey-04}" Padding="20" HorizontalAlignment="Center" Margin="18">
<Image Source="ms-appx:///Assets/NotificationAssets/SampleLiveTiles.gif" Width="400"/>
</Border>
</StackPanel>
</ScrollViewer>
</Page>

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

@ -5,11 +5,8 @@
using System;
using CommunityToolkit.WinUI.Notifications;
using CommunityToolkit.WinUI.SampleApp.Common;
using CommunityToolkit.WinUI.SampleApp.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using NotificationsVisualizerLibrary;
using Windows.UI.Notifications;
using Windows.UI.StartScreen;
@ -17,12 +14,9 @@ namespace CommunityToolkit.WinUI.SampleApp.SamplePages
{
public sealed partial class LiveTilePage : Page
{
private TileContent _tileContent;
public LiveTilePage()
{
InitializeComponent();
Initialize();
}
public static TileContent GenerateTileContent(string username, string avatarLogoSource)
@ -149,34 +143,9 @@ namespace CommunityToolkit.WinUI.SampleApp.SamplePages
return;
}
TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(_tileContent.GetXml()));
}
private void Initialize()
{
// Generate the tile notification content
_tileContent = GenerateTileContent("MasterHip", "Assets/Photos/Owl.jpg");
// Prepare and update the preview tiles
var previewTiles = new PreviewTile[]
{
MediumPreviewTile, WidePreviewTile, LargePreviewTile
};
foreach (var tile in previewTiles)
{
tile.DisplayName = "Xbox";
tile.VisualElements.BackgroundColor = Constants.ApplicationBackgroundColor;
tile.VisualElements.ShowNameOnSquare150x150Logo = true;
tile.VisualElements.ShowNameOnSquare310x310Logo = true;
tile.VisualElements.ShowNameOnWide310x150Logo = true;
tile.VisualElements.Square44x44Logo = Constants.Square44x44Logo;
tile.VisualElements.Square150x150Logo = Constants.Square150x150Logo;
tile.VisualElements.Wide310x150Logo = Constants.Wide310x150Logo;
tile.VisualElements.Square310x310Logo = Constants.Square310x310Logo;
_ = tile.UpdateAsync(); // Commit changes (no need to await)
tile.CreateTileUpdater().Update(new TileNotification(_tileContent.GetXml()));
}
// Generate the tile notification content and update the tile
TileContent content = GenerateTileContent("MasterHip", "Assets/Photos/Owl.jpg");
TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(content.GetXml()));
}
}
}

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

@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:visualizer="using:NotificationsVisualizerLibrary"
mc:Ignorable="d">
<Page.Resources>
@ -21,7 +20,8 @@
<Button x:Name="ButtonPopToast"
HorizontalAlignment="Stretch"
Click="ButtonPopToast_Click"
Content="Pop Toast" />
Content="Pop Toast"
Style="{ThemeResource AccentButtonStyle}" />
<RichTextBlock Margin="0,10,0,0">
<Paragraph>The button will pop a Toast notification reminder about your calendar appointment. A preview is seen below.</Paragraph>
@ -42,9 +42,7 @@
<TextBlock
Text="TOAST"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewToast x:Name="PreviewToastReminder"
MaxWidth="362"
HorizontalAlignment="Left" />
<Image Source="ms-appx:///Assets/NotificationAssets/SampleToast.gif" Width="362"/>
</StackPanel>
</StackPanel>
</ScrollViewer>

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

@ -3,32 +3,29 @@
// See the LICENSE file in the project root for more information.
using CommunityToolkit.WinUI.Notifications;
using CommunityToolkit.WinUI.SampleApp.Common;
using CommunityToolkit.WinUI.SampleApp.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using NotificationsVisualizerLibrary;
using Windows.UI.Notifications;
namespace CommunityToolkit.WinUI.SampleApp.SamplePages
{
public sealed partial class ToastPage : Page
{
private ToastContent _toastContent;
public ToastPage()
{
InitializeComponent();
Initialize();
}
private void ButtonPopToast_Click(object sender, RoutedEventArgs e)
{
PopToast();
}
#pragma warning disable SA1008 // Parenthesis spacing
#pragma warning disable SA1117 // Parameters must be on same line or separate lines
public static ToastContent GenerateToastContent()
private void PopToast()
{
var builder = new ToastContentBuilder()
new ToastContentBuilder()
.SetToastScenario(ToastScenario.Reminder)
.AddArgument("action", "viewEvent")
.AddArgument("eventId", 1983)
@ -43,37 +40,11 @@ namespace CommunityToolkit.WinUI.SampleApp.SamplePages
.AddButton(new ToastButton()
.SetSnoozeActivation("snoozeTime"))
.AddButton(new ToastButton()
.SetDismissActivation());
return builder.Content;
.SetDismissActivation())
.Show();
}
#pragma warning restore SA1008
#pragma warning restore SA1117
private void ButtonPopToast_Click(object sender, RoutedEventArgs e)
{
PopToast();
}
private void PopToast()
{
ToastNotificationManagerCompat.CreateToastNotifier().Show(new ToastNotification(_toastContent.GetXml()));
}
private void Initialize()
{
// Generate the toast notification content
_toastContent = GenerateToastContent();
// Prepare and update preview toast
PreviewToastReminder.Properties = new PreviewToastProperties()
{
BackgroundColor = Constants.ApplicationBackgroundColor,
DisplayName = Constants.ApplicationDisplayName,
Square44x44Logo = Constants.Square44x44Logo
};
PreviewToastReminder.Initialize(_toastContent.GetXml());
}
}
}

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

@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:visualizer="using:NotificationsVisualizerLibrary"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
mc:Ignorable="d">
@ -22,12 +21,14 @@
<Button x:Name="ButtonPopToast"
HorizontalAlignment="Stretch"
Click="ButtonPopToast_Click"
Content="Pop Toast" />
Content="Pop Toast"
Style="{ThemeResource AccentButtonStyle}" />
<Button x:Name="ButtonPinTile"
Margin="0,10,0,0"
HorizontalAlignment="Stretch"
Click="ButtonPinTile_Click"
Content="Pin Tile" />
Content="Pin Tile"
Style="{ThemeResource AccentButtonStyle}" />
<RichTextBlock Margin="0,10,0,0">
<Paragraph>The first button will pop a Toast notification displaying the weather forecast.</Paragraph>
@ -52,9 +53,7 @@
<TextBlock
Text="TOAST"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewToast x:Name="PreviewToastWeather"
MaxWidth="362"
HorizontalAlignment="Center" />
<Image Source="ms-appx:///Assets/NotificationAssets/WeatherToast.png" Width="362"/>
</StackPanel>
<TextBlock
@ -74,9 +73,7 @@
<TextBlock
Text="SMALL"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="PreviewTileSmall"
IsAnimationEnabled="False"
TileSize="Small" />
<Image Source="ms-appx:///Assets/NotificationAssets/WeatherTileSmall.png" Width="48"/>
</StackPanel>
<StackPanel
@ -87,9 +84,7 @@
<TextBlock
Text="MEDIUM"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="PreviewTileMedium"
IsAnimationEnabled="False"
TileSize="Medium" />
<Image Source="ms-appx:///Assets/NotificationAssets/WeatherTileMedium.png" Width="100"/>
</StackPanel>
<StackPanel
@ -100,9 +95,7 @@
<TextBlock
Text="WIDE"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="PreviewTileWide"
IsAnimationEnabled="False"
TileSize="Wide" />
<Image Source="ms-appx:///Assets/NotificationAssets/WeatherTileWide.png" Width="204"/>
</StackPanel>
<StackPanel
@ -113,9 +106,7 @@
<TextBlock
Text="LARGE"
Style="{StaticResource Box-Header}" />
<visualizer:PreviewTile x:Name="PreviewTileLarge"
IsAnimationEnabled="False"
TileSize="Large" />
<Image Source="ms-appx:///Assets/NotificationAssets/WeatherTileLarge.png" Width="204"/>
</StackPanel>
</controls:WrapPanel>
</StackPanel>

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

@ -5,10 +5,7 @@
using System;
using CommunityToolkit.WinUI.Notifications;
using CommunityToolkit.WinUI.SampleApp.Common;
using CommunityToolkit.WinUI.SampleApp.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Navigation;
using NotificationsVisualizerLibrary;
using Windows.System.Profile;
using Windows.UI.Notifications;
using Windows.UI.StartScreen;
@ -17,13 +14,9 @@ namespace CommunityToolkit.WinUI.SampleApp.SamplePages
{
public sealed partial class WeatherLiveTileAndToastPage
{
private TileContent _tileContent;
private ToastContent _toastContent;
public WeatherLiveTileAndToastPage()
{
InitializeComponent();
Initialize();
}
public static ToastContent GenerateToastContent()
@ -278,7 +271,9 @@ namespace CommunityToolkit.WinUI.SampleApp.SamplePages
return;
}
TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(_tileContent.GetXml()));
// Generate the tile notification content and update the tile
TileContent content = GenerateTileContent();
TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(content.GetXml()));
}
private void ButtonPopToast_Click(object sender, RoutedEventArgs e)
@ -288,46 +283,48 @@ namespace CommunityToolkit.WinUI.SampleApp.SamplePages
private void PopToast()
{
ToastNotificationManagerCompat.CreateToastNotifier().Show(new ToastNotification(_toastContent.GetXml()));
}
private void Initialize()
{
// Generate the tile notification content
_tileContent = GenerateTileContent();
// Generate the toast notification content
_toastContent = GenerateToastContent();
ToastContentBuilder builder = new ToastContentBuilder();
// Prepare and update the preview tiles
var previewTiles = new PreviewTile[]
{
PreviewTileSmall, PreviewTileMedium, PreviewTileWide, PreviewTileLarge
};
foreach (var tile in previewTiles)
{
tile.DisplayName = "WeatherSample";
tile.VisualElements.BackgroundColor = Constants.ApplicationBackgroundColor;
tile.VisualElements.ShowNameOnSquare150x150Logo = true;
tile.VisualElements.ShowNameOnSquare310x310Logo = true;
tile.VisualElements.ShowNameOnWide310x150Logo = true;
tile.VisualElements.Square44x44Logo = Constants.Square44x44Logo;
tile.VisualElements.Square150x150Logo = Constants.Square150x150Logo;
tile.VisualElements.Wide310x150Logo = Constants.Wide310x150Logo;
tile.VisualElements.Square310x310Logo = Constants.Square310x310Logo;
_ = tile.UpdateAsync(); // Commit changes (no need to await)
// Include launch string so we know what to open when user clicks toast
builder.AddArgument("action", "viewForecast");
builder.AddArgument("zip", 98008);
tile.CreateTileUpdater().Update(new TileNotification(_tileContent.GetXml()));
// We'll always have this summary text on our toast notification
// (it is required that your toast starts with a text element)
builder.AddText("Today will be mostly sunny with a high of 63 and a low of 42.");
// If Adaptive Toast Notifications are supported
if (IsAdaptiveToastSupported())
{
// Use the rich Tile-like visual layout
builder.AddVisualChild(new AdaptiveGroup()
{
Children =
{
GenerateSubgroup("Mon", "Mostly Cloudy.png", 63, 42),
GenerateSubgroup("Tue", "Cloudy.png", 57, 38),
GenerateSubgroup("Wed", "Sunny.png", 59, 43),
GenerateSubgroup("Thu", "Sunny.png", 62, 42),
GenerateSubgroup("Fri", "Sunny.png", 71, 66)
}
});
}
// Prepare and update preview toast
PreviewToastWeather.Properties = new PreviewToastProperties()
// Otherwise...
else
{
BackgroundColor = Constants.ApplicationBackgroundColor,
DisplayName = Constants.ApplicationDisplayName,
Square44x44Logo = Constants.Square44x44Logo
};
PreviewToastWeather.Initialize(_toastContent.GetXml());
// We'll just add two simple lines of text
builder
.AddText("Monday ⛅ 63° / 42°")
.AddText("Tuesday ☁ 57° / 38°");
}
// Set the base URI for the images, so we don't redundantly specify the entire path
builder.Content.Visual.BaseUri = new Uri("Assets/NotificationAssets/", UriKind.Relative);
// Show the toast
builder.Show();
}
}
}