Skip to content

Commit 8751ca0

Browse files
committed
Upgrade to .Net 6
1 parent 89958f9 commit 8751ca0

File tree

3 files changed

+60
-60
lines changed

3 files changed

+60
-60
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
3+
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net5.0-windows10.0.17763.0</TargetFramework>
5+
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
66
<UseWPF>true</UseWPF>
77
<AssemblyName>Grab Windows 10 Lock Screen Pictures</AssemblyName>
88
<ApplicationIcon>Data\lion_icon.ico</ApplicationIcon>
9-
</PropertyGroup>
9+
</PropertyGroup>
1010

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>
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>
1717

1818
<ItemGroup>
1919
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
2020
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.0.2" />
2121
</ItemGroup>
2222

2323
<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>
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>
3333
</ItemGroup>
3434

3535
<ItemGroup>
36-
<Resource Include="Data\lionicon.ico">
37-
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
38-
</Resource>
36+
<Resource Include="Data\lionicon.ico">
37+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
38+
</Resource>
3939
</ItemGroup>
4040

4141
</Project>

GrabWindows10LockScreenPictures/Helpers/PopTheToast.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
using System;
33
using System.IO;
44

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-
}
5+
namespace GrabWindows10LockScreenPictures.Helpers;
6+
7+
public class PopTheToast {
8+
public static void PopIt(string notifText) =>
9+
new ToastContentBuilder()
10+
.AddText("Grab Windows 10 Lock Screen Pictures")
11+
.AddText(!string.IsNullOrWhiteSpace(notifText) ? notifText : "Script has run with an unknown result.")
12+
.AddHeroImage(new Uri("file:///" + Path.GetFullPath("Data/buffelo.png")))
13+
.AddAppLogoOverride(new Uri("file:///" + Path.GetFullPath("Data/lion.png")), ToastGenericAppLogoCrop.Circle)
14+
.AddAttributionText("Via GWLSP")
15+
.Show(toast => toast.ExpirationTime = DateTime.Now.AddMinutes(10));
1616
}

GrabWindows10LockScreenPictures/Program.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,43 @@
44
using System.IO;
55
using System.Linq;
66

7-
namespace GrabWindows10LockScreenPictures {
8-
class Program {
9-
static readonly string App_Folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Grab Windows 10 Lock Screen Pictures";
7+
namespace GrabWindows10LockScreenPictures;
108

11-
static void Main(string[] args) {
12-
try {
13-
string userName = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).Replace(@"C:\Users\", "");
9+
class Program {
10+
static readonly string App_Folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Grab Windows 10 Lock Screen Pictures";
1411

15-
if (!Directory.Exists(App_Folder)) {
16-
Directory.CreateDirectory(App_Folder);
17-
File.WriteAllText(Path.Combine(App_Folder, "locations.txt"), userName);
18-
}
12+
static void Main(string[] args) {
13+
try {
14+
string userName = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile).Replace(@"C:\Users\", "");
1915

20-
if (File.Exists(Path.Combine(App_Folder, "locations.txt"))) {
21-
string[] users = File.ReadAllLines(Path.Combine(App_Folder, "locations.txt"));
22-
string saved = @$"C:\Users\{users.FirstOrDefault()}\Pictures\Spotlight Images";
16+
if (!Directory.Exists(App_Folder)) {
17+
Directory.CreateDirectory(App_Folder);
18+
File.WriteAllText(Path.Combine(App_Folder, "locations.txt"), userName);
19+
}
2320

24-
foreach (string name in users) {
25-
GetPics(@$"C:\Users\{name}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", saved);
26-
}
21+
if (File.Exists(Path.Combine(App_Folder, "locations.txt"))) {
22+
string[] users = File.ReadAllLines(Path.Combine(App_Folder, "locations.txt"));
23+
string saved = @$"C:\Users\{users.FirstOrDefault()}\Pictures\Spotlight Images";
2724

28-
PopTheToast.PopIt("All images were successfully saved.");
29-
} else {
30-
PopTheToast.PopIt("Error: locations.txt file was not found.");
25+
foreach (string name in users) {
26+
GetPics(@$"C:\Users\{name}\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets", saved);
3127
}
32-
} catch (Exception ex) {
33-
PopTheToast.PopIt("An error occurred: " + ex.Message);
28+
29+
PopTheToast.PopIt("All images were successfully saved.");
30+
} else {
31+
PopTheToast.PopIt("Error: locations.txt file was not found.");
3432
}
33+
} catch (Exception ex) {
34+
PopTheToast.PopIt("An error occurred: " + ex.Message);
3535
}
36+
}
3637

37-
static void GetPics(string assets, string saved) {
38-
foreach (string file in Directory.GetFiles(assets).Where(f => new FileInfo(f).Length > 200 * 1024)) {
39-
Image img = Image.FromFile(file);
40-
if (img.Width > img.Height) {
41-
string newFile = saved + file.Replace(assets, "") + ".jpg";
42-
File.Copy(file, newFile, true);
43-
}
38+
static void GetPics(string assets, string saved) {
39+
foreach (string file in Directory.GetFiles(assets).Where(f => new FileInfo(f).Length > 200 * 1024)) {
40+
Image img = Image.FromFile(file);
41+
if (img.Width > img.Height) {
42+
string newFile = saved + file.Replace(assets, "") + ".jpg";
43+
File.Copy(file, newFile, true);
4444
}
4545
}
4646
}

0 commit comments

Comments
 (0)