Skip to content

Commit 7d3fd41

Browse files
committed
Add toast notif with try catch to show result
1 parent bbe0e34 commit 7d3fd41

File tree

8 files changed

+56
-5
lines changed

8 files changed

+56
-5
lines changed
3.34 MB
Loading
1.84 MB
Loading
140 KB
Binary file not shown.
816 KB
Loading
26.6 KB
Binary file not shown.
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net5.0-windows</TargetFramework>
5+
<TargetFramework>net5.0-windows10.0.17763.0</TargetFramework>
66
<UseWPF>true</UseWPF>
77
<AssemblyName>Grab Windows 10 Lock Screen Pictures</AssemblyName>
8+
<ApplicationIcon>Data\lion_icon.ico</ApplicationIcon>
89
</PropertyGroup>
910

11+
<ItemGroup>
12+
<None Remove="Data\buffelo.png" />
13+
<None Remove="Data\lion.png" />
14+
<None Remove="Data\lionicon.ico" />
15+
<None Remove="Data\lion_icon.ico" />
16+
</ItemGroup>
17+
1018
<ItemGroup>
1119
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
20+
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.0.1" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<Content Include="Data\buffelo.png">
25+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
26+
</Content>
27+
<Content Include="Data\lion.png">
28+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
29+
</Content>
30+
<Resource Include="Data\lion_icon.ico">
31+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
32+
</Resource>
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<Resource Include="Data\lionicon.ico">
37+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
38+
</Resource>
1239
</ItemGroup>
1340

1441
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.Toolkit.Uwp.Notifications;
2+
using System;
3+
using System.IO;
4+
5+
namespace GrabWindows10LockScreenPictures.Helpers {
6+
public class PopTheToast {
7+
public static void PopIt(string notifText) =>
8+
new ToastContentBuilder()
9+
.AddText("Grab Windows 10 Lock Screen Pictures")
10+
.AddText(!string.IsNullOrWhiteSpace(notifText) ? notifText : "Script has run with an unknown result.")
11+
.AddHeroImage(new Uri("file:///" + Path.GetFullPath("Data/buffelo.png")))
12+
.AddAppLogoOverride(new Uri("file:///" + Path.GetFullPath("Data/lion.png")), ToastGenericAppLogoCrop.Circle)
13+
.AddAttributionText("Via GWLSP")
14+
.Show(toast => toast.ExpirationTime = DateTime.Now.AddMinutes(10));
15+
}
16+
}

GrabWindows10LockScreenPictures/Program.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Drawing;
1+
using GrabWindows10LockScreenPictures.Helpers;
2+
using System;
3+
using System.Drawing;
24
using System.IO;
35
using System.Linq;
46

@@ -9,8 +11,14 @@ static void Main(string[] args) {
911
string assetsOthers = @"C:\Users\others\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets";
1012
string saved = @"C:\Users\user\Pictures\Spotlight Images";
1113

12-
GetPics(assetsAryeh, saved);
13-
GetPics(assetsOthers, saved);
14+
try {
15+
GetPics(assetsAryeh, saved);
16+
GetPics(assetsOthers, saved);
17+
18+
PopTheToast.PopIt("All images were successfully saved.");
19+
} catch (Exception ex) {
20+
PopTheToast.PopIt("An error occurred: " + ex.Message);
21+
}
1422
}
1523

1624
static void GetPics(string assets, string saved) {

0 commit comments

Comments
 (0)