Skip to content

Commit 9e39c8d

Browse files
authored
Merge branch 'master' into feature/new-bithelper-apis
2 parents 188791b + 3e4ba97 commit 9e39c8d

File tree

22 files changed

+551
-370
lines changed

22 files changed

+551
-370
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ Windows 10 Build Number:
4242
- [ ] April 2018 Update (17134)
4343
- [ ] October 2018 Update (17763)
4444
- [ ] May 2019 Update (18362)
45+
- [ ] May 2020 Update (19041)
4546
- [ ] Insider Build (build number: )
4647
4748
App min and target version:
4849
- [ ] Fall Creators Update (16299)
4950
- [ ] April 2018 Update (17134)
5051
- [ ] October 2018 Update (17763)
5152
- [ ] May 2019 Update (18362)
53+
- [ ] May 2020 Update (19041)
5254
- [ ] Insider Build (xxxxx)
5355
5456
Device form factor:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## Fixes #<!-- Link to relevant issue (for ex: #1234) which will automatically close the issue once the PR is merged. -->
1+
## Fixes #
2+
<!-- Add the relevant issue number after the "#" mentioned above (for ex: Fixes #1234) which will automatically close the issue once the PR is merged. -->
23

34
<!-- Add a brief overview here of the feature/bug & fix. -->
45

Microsoft.Toolkit.Parsers/Markdown/Blocks/YamlHeaderBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ internal static YamlHeaderBlock Parse(string markdown, int start, int end, out i
7878
else if (end - pos >= 3 && markdown.Substring(pos, 3) == "---")
7979
{
8080
lockedFinalUnderline = true;
81-
realEndIndex = pos + 3;
8281
break;
8382
}
8483
else if (startOfNextLine == pos + 1)
@@ -134,6 +133,7 @@ internal static YamlHeaderBlock Parse(string markdown, int start, int end, out i
134133
return null;
135134
}
136135

136+
realEndIndex = pos + 3;
137137
return result;
138138
}
139139

Microsoft.Toolkit.Services/Microsoft.Toolkit.Services.csproj

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<DefineConstants Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">$(DefineConstants);WINRT</DefineConstants>
2020
</PropertyGroup>
2121

22+
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
23+
<UseWpf>true</UseWpf>
24+
<EnableDefaultPageItems>false</EnableDefaultPageItems>
25+
</PropertyGroup>
26+
2227
<ItemGroup>
2328
<ProjectReference Include="..\Microsoft.Toolkit.Parsers\Microsoft.Toolkit.Parsers.csproj" />
2429
<ProjectReference Include="..\Microsoft.Toolkit\Microsoft.Toolkit.csproj" />
@@ -40,28 +45,9 @@
4045
</ItemGroup>
4146

4247
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
43-
<Reference Include="System.Data" />
44-
<Reference Include="System.ComponentModel" />
45-
<Reference Include="System.Drawing" />
46-
<Reference Include="System.Windows" />
47-
<Reference Include="System.Windows.Forms" />
4848
<Reference Include="System.Web" />
49-
<Reference Include="System.Xaml">
50-
<RequiredTargetFramework>4.0</RequiredTargetFramework>
51-
</Reference>
52-
<Reference Include="WindowsBase" />
53-
<Reference Include="PresentationCore" />
54-
<Reference Include="PresentationFramework" />
5549
<PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView" Version="[5.0.0-preview.gb86cb1c4cb,)" />
5650
<PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls.WebView" Version="[5.0.0-preview.gb86cb1c4cb,)" />
57-
<Page Update="PlatformSpecific\NetFramework\PopupWPF.xaml">
58-
<Generator>MSBuild:Compile</Generator>
59-
<SubType>Designer</SubType>
60-
</Page>
61-
<Compile Update="PlatformSpecific\NetFramework\PopupWPF.xaml.cs">
62-
<DependentUpon>PlatformSpecific\NetFramework\PopupWPF.xaml</DependentUpon>
63-
<SubType>Code</SubType>
64-
</Compile>
6551
</ItemGroup>
6652

6753
<ItemGroup Condition="!('$(TargetFramework)'=='uap10.0.16299')">

Microsoft.Toolkit.Uwp.Notifications/Microsoft.Toolkit.Uwp.Notifications.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="MSBuild.Sdk.Extras">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.4;uap10.0;native;net461;netcoreapp3.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard1.4;uap10.0;native;net461;netcoreapp3.1</TargetFrameworks>
55
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
66
<Title>Windows Community Toolkit Notifications</Title>
77
<Description>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/InAppNotification/InAppNotificationCode.bind

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,29 @@ if (isTemplatePresent && inAppNotificationWithButtonsTemplate is DataTemplate)
4646
ExampleInAppNotification.Show(inAppNotificationWithButtonsTemplate as DataTemplate);
4747
}
4848

49+
// Show notification using an object
50+
<controls:InAppNotification
51+
x:Name="ExampleInAppNotification"
52+
ContentTemplate="{StaticResource MyNotificationDataTemplate}" />
53+
54+
var notificationData = new MyNotificationData("Title", "Message");
55+
ExampleInAppNotification.Show(notificationData, duration: 2000);
56+
4957
// Dismiss notification
5058
ExampleInAppNotification.Dismiss();
5159

5260
// ## C# - Handle button events
5361

5462
private void YesButton_Click(object sender, RoutedEventArgs e)
5563
{
56-
// TODO : Do something when user accepted
64+
// TODO : Do something when user accepted
5765

5866
ExampleInAppNotification.Dismiss();
5967
}
6068

6169
private void NoButton_Click(object sender, RoutedEventArgs e)
6270
{
63-
// TODO : Do something when user refused
71+
// TODO : Do something when user refused
6472

6573
ExampleInAppNotification.Dismiss();
6674
}

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/InAppNotification/InAppNotificationPage.xaml.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
6-
using System.Windows.Input;
75
using Microsoft.Toolkit.Uwp.UI.Controls;
86
using Microsoft.Toolkit.Uwp.UI.Extensions;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Windows.Input;
910
using Windows.UI.Xaml;
1011
using Windows.UI.Xaml.Controls;
1112

@@ -57,6 +58,15 @@ private void Load()
5758
_exampleInAppNotification?.Show(GetRandomText(), NotificationDuration);
5859
});
5960

61+
SampleController.Current.RegisterNewCommand("Show notification with object", (sender, args) =>
62+
{
63+
_exampleVSCodeInAppNotification?.Dismiss();
64+
SetDefaultControlTemplate();
65+
66+
var random = new Random();
67+
_exampleInAppNotification?.Show(new KeyValuePair<int, string>(random.Next(1, 10), GetRandomText()), NotificationDuration);
68+
});
69+
6070
SampleController.Current.RegisterNewCommand("Show notification with buttons (without DataTemplate)", (sender, args) =>
6171
{
6272
_exampleVSCodeInAppNotification?.Dismiss();

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/InAppNotification/InAppNotificationXaml.bind

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@
153153
<ColumnDefinition Width="Auto" />
154154
</Grid.ColumnDefinitions>
155155

156-
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
156+
<ContentPresenter x:Name="PART_Presenter"
157+
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
157158
HorizontalContentAlignment="Stretch"
158159
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
159160
VerticalContentAlignment="Center"
@@ -333,7 +334,8 @@
333334
<ColumnDefinition Width="Auto" />
334335
</Grid.ColumnDefinitions>
335336

336-
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
337+
<ContentPresenter x:Name="PART_Presenter"
338+
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
337339
HorizontalContentAlignment="Stretch"
338340
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
339341
VerticalContentAlignment="Center"
@@ -376,7 +378,17 @@
376378
AnimationDuration="@[AnimationDuration:TimeSpan:100:0-5000]"
377379
VerticalOffset="@[VerticalOffset:DoubleSlider:100.0:-200.0-200.0]"
378380
HorizontalOffset="@[HorizontalOffset:DoubleSlider:0.0:-200.0-200.0]"
379-
StackMode="@[StackMode:Enum:StackMode.Replace]" />
381+
StackMode="@[StackMode:Enum:StackMode.Replace]">
382+
<controls:InAppNotification.ContentTemplate>
383+
<DataTemplate>
384+
<StackPanel>
385+
<TextBlock Text="{Binding Value}" Margin="0,0,0,8" />
386+
<TextBlock Text="{Binding Key}" Style="{ThemeResource CaptionTextBlockStyle}" Opacity="0.8" />
387+
</StackPanel>
388+
</DataTemplate>
389+
</controls:InAppNotification.ContentTemplate>
390+
</controls:InAppNotification>
391+
380392

381393
<controls:InAppNotification x:Name="ExampleCustomInAppNotification"
382394
Style="{StaticResource MSEdgeNotificationTemplate_NoDismissButton}"

Microsoft.Toolkit.Uwp.UI.Controls/InAppNotification/InAppNotification.Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ public partial class InAppNotification
2828
/// Key of the UI Element that dismiss the control
2929
/// </summary>
3030
private const string DismissButtonPart = "PART_DismissButton";
31+
32+
/// <summary>
33+
/// Key of the UI Element that will display the notification content.
34+
/// </summary>
35+
private const string ContentPresenterPart = "PART_Presenter";
3136
}
3237
}

Microsoft.Toolkit.Uwp.UI.Controls/InAppNotification/InAppNotification.Events.cs

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6-
using Microsoft.Toolkit.Uwp.Extensions;
76
using Windows.UI.Xaml;
8-
using Windows.UI.Xaml.Automation;
97
using Windows.UI.Xaml.Automation.Peers;
108

119
namespace Microsoft.Toolkit.Uwp.UI.Controls
@@ -45,44 +43,39 @@ private void DismissTimer_Tick(object sender, object e)
4543
Dismiss(InAppNotificationDismissKind.Timeout);
4644
}
4745

48-
private void OpenAnimationTimer_Tick(object sender, object e)
46+
private void OnCurrentStateChanged(object sender, VisualStateChangedEventArgs e)
4947
{
50-
lock (_openAnimationTimer)
48+
switch (e.NewState.Name)
5149
{
52-
_openAnimationTimer.Stop();
53-
Opened?.Invoke(this, EventArgs.Empty);
54-
SetValue(AutomationProperties.NameProperty, StringExtensions.GetLocalized("WindowsCommunityToolkit_InAppNotification_NameProperty", "/Microsoft.Toolkit.Uwp.UI.Controls/Resources"));
55-
if (ContentTemplateRoot != null)
56-
{
57-
var peer = FrameworkElementAutomationPeer.CreatePeerForElement(ContentTemplateRoot);
58-
if (Content?.GetType() == typeof(string))
59-
{
60-
AutomateTextNotification(peer, Content.ToString());
61-
}
62-
}
50+
case StateContentVisible:
51+
OnNotificationVisible();
52+
break;
53+
case StateContentCollapsed:
54+
OnNotificationCollapsed();
55+
break;
6356
}
6457
}
6558

66-
private void AutomateTextNotification(AutomationPeer peer, string message)
59+
private void OnNotificationVisible()
6760
{
68-
if (peer != null)
69-
{
70-
peer.SetFocus();
71-
peer.RaiseNotificationEvent(
72-
AutomationNotificationKind.Other,
73-
AutomationNotificationProcessing.ImportantMostRecent,
74-
StringExtensions.GetLocalized("WindowsCommunityToolkit_InAppNotification_Events_NewNotificationMessage", "/Microsoft.Toolkit.Uwp.UI.Controls/Resources") + message,
75-
Guid.NewGuid().ToString());
76-
}
61+
Opened?.Invoke(this, EventArgs.Empty);
62+
}
63+
64+
private void OnNotificationCollapsed()
65+
{
66+
Closed?.Invoke(this, new InAppNotificationClosedEventArgs(_lastDismissKind));
67+
Visibility = Visibility.Collapsed;
7768
}
7869

79-
private void ClosingAnimationTimer_Tick(object sender, object e)
70+
private void RaiseAutomationNotification()
8071
{
81-
lock (_closingAnimationTimer)
72+
if (!AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged))
8273
{
83-
_closingAnimationTimer.Stop();
84-
Closed?.Invoke(this, new InAppNotificationClosedEventArgs(_lastDismissKind));
74+
return;
8575
}
76+
77+
var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this);
78+
peer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
8679
}
8780
}
8881
}

0 commit comments

Comments
 (0)