Daniel Chalmers 1 年之前
父节点
当前提交
abd025468f

+ 1 - 1
DesktopClock.Tests/DesktopClock.Tests.csproj

@@ -6,7 +6,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
     <PackageReference Include="xunit" Version="2.5.2" />
     <PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all">
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

+ 1 - 1
DesktopClock/DesktopClock.csproj

@@ -16,7 +16,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
+    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
     <PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="All" />
     <PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.118" />
     <PackageReference Include="Humanizer.Core" Version="2.14.1" />

+ 1 - 0
DesktopClock/MainWindow.xaml

@@ -6,6 +6,7 @@
         xmlns:local="clr-namespace:DesktopClock"
         xmlns:p="clr-namespace:DesktopClock.Properties"
         xmlns:tb="http://www.hardcodet.net/taskbar"
+        d:DataContext="{d:DesignInstance Type=local:MainWindow}"
         mc:Ignorable="d"
         Title="DesktopClock"
         AllowsTransparency="True"

+ 6 - 6
DesktopClock/Properties/Settings.cs

@@ -86,18 +86,18 @@ public sealed class Settings : INotifyPropertyChanged, IDisposable
     /// <summary>
     /// Determines if the settings file has been modified externally since the last time it was used.
     /// </summary>
-    public bool CheckIfModifiedExternally() =>
-        File.GetLastWriteTimeUtc(FilePath) > _fileDate;
+    public bool CheckIfModifiedExternally() => File.GetLastWriteTimeUtc(FilePath) > _fileDate;
 
     /// <summary>
     /// Saves to the default path.
     /// </summary>
     public void Save()
     {
-        using (var fileStream = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
-        using (var streamWriter = new StreamWriter(fileStream))
-        using (var jsonWriter = new JsonTextWriter(streamWriter))
-            JsonSerializer.Create(_jsonSerializerSettings).Serialize(jsonWriter, this);
+        using var fileStream = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+        using var streamWriter = new StreamWriter(fileStream);
+        using var jsonWriter = new JsonTextWriter(streamWriter);
+
+        JsonSerializer.Create(_jsonSerializerSettings).Serialize(jsonWriter, this);
 
         _fileDate = DateTime.UtcNow;
     }