Skip to content

Commit 4229f7c

Browse files
committed
feat: 恢复桌面布局前自动备份;优化部分代码
1 parent 645cd06 commit 4229f7c

14 files changed

+325
-454
lines changed

.gitattributes

Lines changed: 0 additions & 63 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ bld/
5151
# JetBrains Rider
5252
*.sln.iml
5353
# End of https://www.toptal.com/developers/gitignore/api/csharp
54+
55+
Properties/

DesktopICO.csproj

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@
66
<Nullable>enable</Nullable>
77
<UseWindowsForms>true</UseWindowsForms>
88
<ImplicitUsings>enable</ImplicitUsings>
9-
<PublishSingleFile>true</PublishSingleFile>
10-
<SelfContained>false</SelfContained>
11-
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
12-
<ApplicationIcon>icon.ico</ApplicationIcon>
9+
<PublishSingleFile>true</PublishSingleFile>
10+
<SelfContained>false</SelfContained>
11+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
12+
<ApplicationIcon>icon.ico</ApplicationIcon>
13+
<PackageIcon>icon.png</PackageIcon>
14+
<PackageReadmeFile>README.md</PackageReadmeFile>
15+
<PackageProjectUrl>https://github.com/sinspired/DesktopIcoManager</PackageProjectUrl>
16+
<RepositoryUrl>https://github.com/sinspired/DesktopIcoManager</RepositoryUrl>
1317
</PropertyGroup>
1418

1519
<ItemGroup>
1620
<Content Include="icon.ico" />
1721
</ItemGroup>
1822

1923
<ItemGroup>
20-
<Compile Update="Properties\Resources.Designer.cs">
21-
<DesignTime>True</DesignTime>
22-
<AutoGen>True</AutoGen>
23-
<DependentUpon>Resources.resx</DependentUpon>
24-
</Compile>
24+
<None Update="icon.png">
25+
<Pack>True</Pack>
26+
<PackagePath>\</PackagePath>
27+
</None>
28+
<None Update="README.md">
29+
<Pack>True</Pack>
30+
<PackagePath>\</PackagePath>
31+
</None>
2532
</ItemGroup>
26-
27-
<ItemGroup>
28-
<EmbeddedResource Update="Properties\Resources.resx">
29-
<Generator>ResXFileCodeGenerator</Generator>
30-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
31-
</EmbeddedResource>
32-
</ItemGroup>
33-
3433
</Project>

DesktopICO.csproj.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<_LastSelectedProfileId>D:\Desktop\WinTool\DesktopICO\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
4+
<_LastSelectedProfileId>D:\Desktop\DesktopICO\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
55
</PropertyGroup>
66
<ItemGroup>
77
<Compile Update="InputDialog.cs">

InputDialog.Designer.cs

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LayoutFileHelper.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace DesktopICO
2+
{
3+
public class LayoutFileHelper
4+
{
5+
public record LayoutFileInfo(string Prefix, string Resolution, string UserName, DateTime Timestamp);
6+
7+
public static string CreateFileName(string prefix, bool autoBackup = false)
8+
{
9+
string resolution = $"{Screen.PrimaryScreen?.Bounds.Width}x{Screen.PrimaryScreen?.Bounds.Height}";
10+
string userName = Environment.UserName;
11+
string timestamp = DateTime.Now.ToString("yyyy_MMdd_HHmmss");
12+
return $"{(autoBackup ? "自动备份" : prefix)}_{resolution}_{userName}_{timestamp}";
13+
}
14+
15+
public static string CreateDisplayName(string prefix, string resolution)
16+
{
17+
return $"{prefix}[{resolution}]";
18+
}
19+
20+
public static LayoutFileInfo ParseFileName(string fileName)
21+
{
22+
var parts = Path.GetFileNameWithoutExtension(fileName).Split('_');
23+
if (parts.Length < 6)
24+
throw new ArgumentException("Invalid file name format");
25+
26+
string dateString = $"{parts[3]}{parts[4]}{parts[5]}";
27+
return new LayoutFileInfo(
28+
parts[0],
29+
parts[1],
30+
parts[2],
31+
DateTime.ParseExact(dateString, "yyyyMMddHHmmss", null)
32+
);
33+
}
34+
}
35+
}

MainForm.Designer.cs

Lines changed: 74 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)