|
@@ -10,6 +10,7 @@ using System.Windows.Input;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using DesktopClock.Properties;
|
|
using DesktopClock.Properties;
|
|
|
|
+using DesktopClock.Utilities;
|
|
using H.NotifyIcon;
|
|
using H.NotifyIcon;
|
|
using H.NotifyIcon.EfficiencyMode;
|
|
using H.NotifyIcon.EfficiencyMode;
|
|
using Humanizer;
|
|
using Humanizer;
|
|
@@ -27,6 +28,7 @@ public partial class MainWindow : Window
|
|
private TaskbarIcon _trayIcon;
|
|
private TaskbarIcon _trayIcon;
|
|
private TimeZoneInfo _timeZone;
|
|
private TimeZoneInfo _timeZone;
|
|
private SoundPlayer _soundPlayer;
|
|
private SoundPlayer _soundPlayer;
|
|
|
|
+ private PixelShifter _pixelShifter;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// The date and time to countdown to, or <c>null</c> if regular clock is desired.
|
|
/// The date and time to countdown to, or <c>null</c> if regular clock is desired.
|
|
@@ -40,6 +42,12 @@ public partial class MainWindow : Window
|
|
[ObservableProperty]
|
|
[ObservableProperty]
|
|
private string _currentTimeOrCountdownString;
|
|
private string _currentTimeOrCountdownString;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The amount of margin applied in order to shift the clock's pixels and help prevent burn-in.
|
|
|
|
+ /// </summary>
|
|
|
|
+ [ObservableProperty]
|
|
|
|
+ private Thickness _pixelShift;
|
|
|
|
+
|
|
public MainWindow()
|
|
public MainWindow()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
@@ -202,6 +210,8 @@ public partial class MainWindow : Window
|
|
{
|
|
{
|
|
UpdateTimeString();
|
|
UpdateTimeString();
|
|
|
|
|
|
|
|
+ TryShiftPixels();
|
|
|
|
+
|
|
TryPlaySound();
|
|
TryPlaySound();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -258,6 +268,20 @@ public partial class MainWindow : Window
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void TryShiftPixels()
|
|
|
|
+ {
|
|
|
|
+ if (!Settings.Default.BurnInMitigation || DateTimeOffset.Now.Second != 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ _pixelShifter ??= new();
|
|
|
|
+
|
|
|
|
+ Dispatcher.Invoke(() =>
|
|
|
|
+ {
|
|
|
|
+ Left += _pixelShifter.ShiftX();
|
|
|
|
+ Top += _pixelShifter.ShiftY();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
private void UpdateTimeString()
|
|
private void UpdateTimeString()
|
|
{
|
|
{
|
|
string GetTimeString()
|
|
string GetTimeString()
|