Skip to content

Commit 33aadff

Browse files
committed
Merge branch 'refactoring/unsafe-null-refs' of https://github.com/Sergio0694/WindowsCommunityToolkit into refactoring/unsafe-null-refs
2 parents 63ad9e7 + dd158b3 commit 33aadff

File tree

95 files changed

+11069
-425
lines changed

Some content is hidden

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

95 files changed

+11069
-425
lines changed

Microsoft.Toolkit.Uwp.Connectivity/Network/NetworkHelper.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,11 @@ namespace Microsoft.Toolkit.Uwp.Connectivity
1212
/// </summary>
1313
public class NetworkHelper
1414
{
15-
/// <summary>
16-
/// Private singleton field.
17-
/// </summary>
18-
private static NetworkHelper _instance;
19-
2015
/// <summary>
2116
/// Event raised when the network changes.
2217
/// </summary>
2318
public event EventHandler NetworkChanged;
2419

25-
/// <summary>
26-
/// Gets public singleton property.
27-
/// </summary>
28-
public static NetworkHelper Instance => _instance ?? (_instance = new NetworkHelper());
29-
30-
/// <summary>
31-
/// Gets instance of <see cref="ConnectionInformation"/>.
32-
/// </summary>
33-
public ConnectionInformation ConnectionInformation { get; } = new ConnectionInformation();
34-
3520
/// <summary>
3621
/// Initializes a new instance of the <see cref="NetworkHelper"/> class.
3722
/// </summary>
@@ -52,6 +37,19 @@ protected NetworkHelper()
5237
NetworkInformation.NetworkStatusChanged -= OnNetworkStatusChanged;
5338
}
5439

40+
/// <summary>
41+
/// Gets public singleton property.
42+
/// </summary>
43+
public static NetworkHelper Instance { get; } = new NetworkHelper();
44+
45+
/// <summary>
46+
/// Gets instance of <see cref="ConnectionInformation"/>.
47+
/// </summary>
48+
public ConnectionInformation ConnectionInformation { get; }
49+
50+
/// <summary>
51+
/// Checks the current connection information and raises <see cref="NetworkChanged"/> if needed.
52+
/// </summary>
5553
private void UpdateConnectionInformation()
5654
{
5755
lock (ConnectionInformation)
@@ -69,6 +67,9 @@ private void UpdateConnectionInformation()
6967
}
7068
}
7169

70+
/// <summary>
71+
/// Invokes <see cref="UpdateConnectionInformation"/> when the current network status changes.
72+
/// </summary>
7273
private void OnNetworkStatusChanged(object sender)
7374
{
7475
UpdateConnectionInformation();

Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveProgressBarValue.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ namespace Microsoft.Toolkit.Uwp.Notifications
1111
/// </summary>
1212
public sealed class AdaptiveProgressBarValue
1313
{
14+
/// <summary>
15+
/// Gets or sets the property name to bind to.
16+
/// </summary>
17+
public string BindingName { get; set; }
18+
1419
/// <summary>
1520
/// Gets or sets the value (0-1) representing the percent complete.
1621
/// </summary>
@@ -35,6 +40,11 @@ internal string ToXmlString()
3540
return "indeterminate";
3641
}
3742

43+
if (BindingName != null)
44+
{
45+
return "{" + BindingName + "}";
46+
}
47+
3848
return Value.ToString();
3949
}
4050

@@ -69,5 +79,18 @@ public static AdaptiveProgressBarValue FromValue(double d)
6979
Value = d
7080
};
7181
}
82+
83+
/// <summary>
84+
/// Returns a progress bar value using the specified binding name.
85+
/// </summary>
86+
/// <param name="bindingName">The property to bind to.</param>
87+
/// <returns>A progress bar value.</returns>
88+
public static AdaptiveProgressBarValue FromBinding(string bindingName)
89+
{
90+
return new AdaptiveProgressBarValue()
91+
{
92+
BindingName = bindingName
93+
};
94+
}
7295
}
7396
}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,17 @@
2525
</ItemGroup>
2626
<PropertyGroup>
2727
<!--Define the WINDOWS_UWP conditional symbol, since the Windows.Data.Xml and the Windows.UI.Notification namespaces are available-->
28-
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>
28+
<DefineConstants>$(DefineConstants);WINDOWS_UWP;WIN32</DefineConstants>
2929
</PropertyGroup>
3030
</When>
3131

32-
<!--Non-desktop apps (UWP, libraries, ASP.NET servers)-->
33-
<Otherwise>
34-
<ItemGroup>
35-
<!--Remove the DesktopNotificationManager code-->
36-
<Compile Remove="DesktopNotificationManager\**\*" />
37-
</ItemGroup>
38-
</Otherwise>
39-
4032
</Choose>
4133

42-
<!--NET Core desktop apps also need the Registry NuGet package-->
34+
<!--NET Core desktop apps also need the Registry NuGet package and System.Reflection.Emit for generating COM class dynamically-->
4335
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
4436
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
37+
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
38+
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
4539
</ItemGroup>
4640

4741
<ItemGroup Condition=" '$(TargetFramework)' == 'native' ">

Microsoft.Toolkit.Uwp.Notifications/Tiles/TileCommon.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ public enum TileSize
1515
/// <summary>
1616
/// Small Square Tile
1717
/// </summary>
18-
Small = 0,
18+
Small = 1,
1919

2020
/// <summary>
2121
/// Medium Square Tile
2222
/// </summary>
23-
Medium = 1,
23+
Medium = 2,
2424

2525
/// <summary>
2626
/// Wide Rectangle Tile
2727
/// </summary>
28-
Wide = 2,
28+
Wide = 4,
2929

3030
/// <summary>
3131
/// Large Square Tile
3232
/// </summary>
33-
Large = 4
33+
Large = 8
3434
}
3535
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
#if WINDOWS_UWP
6+
7+
using Windows.Foundation;
8+
using Windows.UI.Notifications;
9+
10+
namespace Microsoft.Toolkit.Uwp.Notifications
11+
{
12+
/// <summary>
13+
/// Allows you to set additional properties on the <see cref="ToastNotification"/> object before the toast is displayed.
14+
/// </summary>
15+
/// <param name="toast">The toast to modify that will be displayed.</param>
16+
public delegate void CustomizeToast(ToastNotification toast);
17+
18+
/// <summary>
19+
/// Allows you to set additional properties on the <see cref="ToastNotification"/> object before the toast is displayed.
20+
/// </summary>
21+
/// <param name="toast">The toast to modify that will be displayed.</param>
22+
/// <returns>An operation.</returns>
23+
public delegate IAsyncAction CustomizeToastAsync(ToastNotification toast);
24+
25+
/// <summary>
26+
/// Allows you to set additional properties on the <see cref="ScheduledToastNotification"/> object before the toast is scheduled.
27+
/// </summary>
28+
/// <param name="toast">The scheduled toast to modify that will be scheduled.</param>
29+
public delegate void CustomizeScheduledToast(ScheduledToastNotification toast);
30+
31+
/// <summary>
32+
/// Allows you to set additional properties on the <see cref="ScheduledToastNotification"/> object before the toast is scheduled.
33+
/// </summary>
34+
/// <param name="toast">The scheduled toast to modify that will be scheduled.</param>
35+
/// <returns>An operation.</returns>
36+
public delegate IAsyncAction CustomizeScheduledToastAsync(ScheduledToastNotification toast);
37+
}
38+
39+
#endif

0 commit comments

Comments
 (0)