Skip to content

Portable Tool for an Ideal Windows Setup

add universal timer & static reduction

Greedeks9042d64a48b3
diff --git a/.Source/GTweak/Core/ViewModel/MainViewModel.cs b/.Source/GTweak/Core/ViewModel/MainViewModel.cs
index 39d027e9..61b3a0c0 100644
--- a/.Source/GTweak/Core/ViewModel/MainViewModel.cs
+++ b/.Source/GTweak/Core/ViewModel/MainViewModel.cs
@@ -8,6 +8,7 @@ namespace GTweak.Core.ViewModel
{
internal class MainViewModel : ViewModelBase
{
+ private readonly SystemDiagnostics _systemDiagnostics = new SystemDiagnostics();
private object _currentView;
public object CurrentView
@@ -16,9 +17,9 @@ namespace GTweak.Core.ViewModel
set { _currentView = value; OnPropertyChanged(); }
}
- public ImageSource DisplayProfileAvatar => SystemDiagnostics.GetProfileImage();
+ public ImageSource DisplayProfileAvatar => _systemDiagnostics.GetProfileImage();
- public string DisplayProfileName => SystemDiagnostics.GetProfileName();
+ public string DisplayProfileName => _systemDiagnostics.GetProfileName();
public string DisplayTweakVersion => (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index b0fe3291..ccaf6dd9 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -276,6 +276,7 @@
<Compile Include="Utilities\Helpers\DisablingWinKeys.cs" />
<Compile Include="Utilities\Helpers\CommandExecutor.cs" />
<Compile Include="Utilities\Managers\ExplorerManager.cs" />
+ <Compile Include="Utilities\Managers\TimerControlManager.cs" />
<Compile Include="Utilities\Storage\WinKeyStorage.cs" />
<Compile Include="Utilities\Managers\TaskSchedulerManager.cs" />
<Compile Include="Utilities\Managers\ArchiveManager.cs" />
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 25601a4e..427c6c87 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -84,13 +84,13 @@ namespace GTweak.Utilities.Configuration
internal static bool isIPAddressFormatValid = false;
- internal static ImageSource GetProfileImage()
+ internal ImageSource GetProfileImage()
{
string imageSrc = RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\{WindowsIdentity.GetCurrent().User?.Value}", "Image1080", string.Empty);
return !string.IsNullOrWhiteSpace(imageSrc) ? new BitmapImage(new Uri(imageSrc)) : Application.Current.Resources["DI_AvatarProfile"] as ImageSource;
}
- internal static string GetProfileName()
+ internal string GetProfileName()
{
string nameProfile = string.Empty;
diff --git a/.Source/GTweak/Utilities/Managers/TimerControlManager.cs b/.Source/GTweak/Utilities/Managers/TimerControlManager.cs
new file mode 100644
index 00000000..0170ef9a
--- /dev/null
+++ b/.Source/GTweak/Utilities/Managers/TimerControlManager.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Windows;
+using System.Windows.Threading;
+
+namespace GTweak.Utilities.Managers
+{
+ internal sealed class TimerControlManager
+ {
+ private readonly DispatcherTimer _timer;
+ private TimeSpan _time;
+ private readonly TimerMode _mode;
+ private readonly Action<TimeSpan> _action;
+ private readonly Action _onFinished;
+
+ internal enum TimerMode
+ {
+ CountUp,
+ CountDown
+ }
+
+ internal TimerControlManager(TimeSpan startTime, TimerMode mode, Action<TimeSpan> action, Action onFinished = null, TimeSpan? interval = null)
+ {
+ _time = startTime;
+ _mode = mode;
+ _action = action;
+ _onFinished = onFinished;
+
+ _timer = new DispatcherTimer(interval ?? TimeSpan.FromSeconds(1), DispatcherPriority.Normal, (s, e) =>
+ {
+ _action?.Invoke(_time);
+
+ if (_mode == TimerMode.CountDown)
+ {
+ if (_time <= TimeSpan.Zero)
+ {
+ Stop();
+ _onFinished?.Invoke();
+ return;
+ }
+ _time -= _timer.Interval;
+ }
+ else
+ _time += _timer.Interval;
+
+ }, Application.Current.Dispatcher);
+ }
+
+ internal void Start() => _timer.Start();
+
+ internal void Stop() => _timer.Stop();
+ }
+}
diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
index a8485058..bff49ed9 100644
--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
@@ -98,7 +98,7 @@ namespace GTweak.Utilities.Tweaks
catch { return false; }
}
- internal static void ApplyTweaks(string tweak, bool isDisabled)
+ internal void ApplyTweaks(string tweak, bool isDisabled)
{
INIManager.TempWrite(INIManager.TempTweaksConf, tweak, isDisabled);
diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
index 3fd13683..42079a3d 100644
--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
@@ -176,7 +176,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "HideFileExt", "1");
}
- internal static void ApplyTweaks(string tweak, bool isDisabled)
+ internal void ApplyTweaks(string tweak, bool isDisabled)
{
INIManager.TempWrite(INIManager.TempTweaksIntf, tweak, isDisabled);
diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
index 7cf99e8a..9d48136e 100644
--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
@@ -187,7 +187,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vmicvss", "Start", "4");
}
- internal static void ApplyTweaks(string tweak, bool isDisabled)
+ internal void ApplyTweaks(string tweak, bool isDisabled)
{
INIManager.TempWrite(INIManager.TempTweaksSvc, tweak, isDisabled);
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index d878e390..26606ce5 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -187,7 +187,7 @@ namespace GTweak.Utilities.Tweaks
[DllImport("user32.dll")]
private static extern bool SystemParametersInfo(uint _uiAction, uint _uiParam, uint _pvParam, uint _fWinIni);
- internal static void ApplyTweaksSlider(string tweak, uint value)
+ internal void ApplyTweaksSlider(string tweak, uint value)
{
INIManager.TempWrite(INIManager.TempTweaksSys, tweak, value);
@@ -211,7 +211,7 @@ namespace GTweak.Utilities.Tweaks
[DllImport("user32.dll")]
private static extern bool SystemParametersInfo(uint _uiAction, uint _uiParam, uint[] _pvParam, uint _fWinIni);
- internal static async void ApplyTweaks(string tweak, bool isDisabled, bool canShowWindow = true)
+ internal async void ApplyTweaks(string tweak, bool isDisabled, bool canShowWindow = true)
{
INIManager.TempWrite(INIManager.TempTweaksSys, tweak, isDisabled);
diff --git a/.Source/GTweak/View/ConfidentialityView.xaml.cs b/.Source/GTweak/View/ConfidentialityView.xaml.cs
index 57ba790e..f193e858 100644
--- a/.Source/GTweak/View/ConfidentialityView.xaml.cs
+++ b/.Source/GTweak/View/ConfidentialityView.xaml.cs
@@ -36,7 +36,7 @@ namespace GTweak.View
{
ToggleButton toggleButton = (ToggleButton)sender;
- ConfidentialityTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
+ _confTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
if (NotificationManager.ConfActions.TryGetValue(toggleButton.Name, out string action))
new NotificationManager(300).Show(action);
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index 9a59a16d..339fc37f 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -3,6 +3,7 @@ using GTweak.Utilities.Animation;
using GTweak.Utilities.Configuration;
using GTweak.Utilities.Controls;
using GTweak.Utilities.Helpers;
+using GTweak.Utilities.Managers;
using System;
using System.Collections.Generic;
using System.Windows;
@@ -21,8 +22,7 @@ namespace GTweak.View
{
private readonly MonitoringService _monitoringService = new MonitoringService();
private readonly SystemDiagnostics _systemDiagnostics = new SystemDiagnostics();
- private readonly DispatcherTimer _timer = default;
- private TimeSpan _time = TimeSpan.FromSeconds(0);
+ private readonly TimerControlManager timer = default;
public DataSystemView()
{
@@ -45,15 +45,15 @@ namespace GTweak.View
DataContext = new DataSystemVM();
};
- _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, async delegate
+ timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, async time =>
{
- if ((int)_time.TotalSeconds % 2 == 0)
+ if ((int)time.TotalSeconds % 2 == 0)
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
await backgroundQueue.QueueTask(async delegate { await _monitoringService.GetTotalProcessorUsage(); });
AnimationProgressBars();
}
- else if ((int)_time.TotalSeconds % 5 == 0)
+ else if ((int)time.TotalSeconds % 5 == 0)
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
await backgroundQueue.QueueTask(delegate { _systemDiagnostics.GetUserIpAddress(); });
@@ -67,10 +67,8 @@ namespace GTweak.View
Timeline.SetDesiredFrameRate(doubleAnim, 240);
IpAddress.Effect.BeginAnimation(BlurEffect.RadiusProperty, doubleAnim);
}
-
- _time = _time.Add(TimeSpan.FromSeconds(+1));
- }, Application.Current.Dispatcher);
- _timer.Start();
+ });
+ timer.Start();
}
#region Animations
@@ -185,7 +183,7 @@ namespace GTweak.View
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
_monitoringService.StopDeviceMonitoring();
- _timer.Stop();
+ timer.Stop();
}
}
}
diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.cs
index 9e689196..5a669798 100644
--- a/.Source/GTweak/View/InterfaceView.xaml.cs
+++ b/.Source/GTweak/View/InterfaceView.xaml.cs
@@ -68,7 +68,7 @@ namespace GTweak.View
private void TglButton_ChangedState(object sender, EventArgs e)
{
ToggleButton toggleButton = (ToggleButton)sender;
- InterfaceTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
+ _intfTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
if (ExplorerManager.IntfMapping.TryGetValue(toggleButton.Name, out bool needRestart))
ExplorerManager.Restart(new Process());
diff --git a/.Source/GTweak/View/PakagesView.xaml b/.Source/GTweak/View/PakagesView.xaml
index 5513e726..f4c940ad 100644
--- a/.Source/GTweak/View/PakagesView.xaml
+++ b/.Source/GTweak/View/PakagesView.xaml
@@ -6,7 +6,7 @@
xmlns:uc="clr-namespace:GTweak.Assets.UserControl"
xmlns:local="clr-namespace:GTweak.View"
mc:Ignorable="d" d:DesignHeight="550" d:DesignWidth="1100"
- Style="{StaticResource LaunchPage}" Loaded="Page_Loaded">
+ Style="{StaticResource LaunchPage}" Loaded="Page_Loaded" Unloaded="Page_Unloaded">
<Grid>
<Grid x:Name="Overlay" Panel.ZIndex="1" Visibility="Collapsed">
<Grid Background="{StaticResource Color_Background_Dark}" Opacity="0.9"/>
diff --git a/.Source/GTweak/View/PakagesView.xaml.cs b/.Source/GTweak/View/PakagesView.xaml.cs
index 5f3314ee..b43d1fc1 100644
--- a/.Source/GTweak/View/PakagesView.xaml.cs
+++ b/.Source/GTweak/View/PakagesView.xaml.cs
@@ -20,28 +20,24 @@ namespace GTweak.View
{
public partial class PakagesView : UserControl
{
- private readonly DispatcherTimer _timer;
- private TimeSpan _time = TimeSpan.FromSeconds(0);
+ private readonly TimerControlManager timer = default;
private bool _isWebViewRemoval = false;
public PakagesView()
{
InitializeComponent();
- _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
+ timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, time =>
{
- if ((int)_time.TotalSeconds % 5 == 0)
+ if ((int)time.TotalSeconds % 5 == 0)
{
BackgroundWorker backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += delegate { new UninstallingPakages().LoadInstalledPackages(); };
backgroundWorker.RunWorkerCompleted += delegate { UpdateViewStatePakages(); };
backgroundWorker.RunWorkerAsync();
}
-
- _time = _time.Add(TimeSpan.FromSeconds(+1));
- }, Application.Current.Dispatcher);
-
- _timer.Start();
+ });
+ timer.Start();
}
private void Apps_MouseEnter(object sender, MouseEventArgs e)
@@ -159,6 +155,8 @@ namespace GTweak.View
private void Page_Loaded(object sender, RoutedEventArgs e) => UpdateViewStatePakages();
+ private void Page_Unloaded(object sender, RoutedEventArgs e) => timer.Stop();
+
private ImageSource AvailabilityInstalledPackage(string packageName, bool isOneDrive = false)
{
if (!UninstallingPakages.PackagesDetails.TryGetValue(packageName, out var details) || details.Scripts == null)
diff --git a/.Source/GTweak/View/ServicesView.xaml.cs b/.Source/GTweak/View/ServicesView.xaml.cs
index 76f5d2f8..2cc09d7c 100644
--- a/.Source/GTweak/View/ServicesView.xaml.cs
+++ b/.Source/GTweak/View/ServicesView.xaml.cs
@@ -33,7 +33,7 @@ namespace GTweak.View
private void TglButton_ChangedState(object sender, EventArgs e)
{
- ServicesTweaks.ApplyTweaks(((ToggleButton)sender).Name, ((ToggleButton)sender).State);
+ _svcTweaks.ApplyTweaks(((ToggleButton)sender).Name, ((ToggleButton)sender).State);
new NotificationManager(300).Show("restart");
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index 142f7077..3d2fb414 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -40,14 +40,14 @@ namespace GTweak.View
CommentTweak.Text = (string)FindResource("defaultDescription");
}
- private void Sliders_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) => SystemTweaks.ApplyTweaksSlider(((Slider)sender).Name, (uint)((Slider)sender).Value);
+ private void Sliders_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) => _sysTweaks.ApplyTweaksSlider(((Slider)sender).Name, (uint)((Slider)sender).Value);
private void TglButton_ChangedState(object sender, EventArgs e)
{
ToggleButton toggleButton = (ToggleButton)sender;
if (toggleButton.Name != "TglButton8")
{
- SystemTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
+ _sysTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
if (NotificationManager.SysActions.TryGetValue(toggleButton.Name, out string action))
new NotificationManager(300).Show(action);
@@ -55,7 +55,7 @@ namespace GTweak.View
Parallel.Invoke(async delegate { await Task.Delay(1000); _sysTweaks.AnalyzeAndUpdate(this); });
}
else
- SystemTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
+ _sysTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
}
private void Page_Loaded(object sender, RoutedEventArgs e) => Parallel.Invoke(() => _sysTweaks.AnalyzeAndUpdate(this));
diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.cs
index 0584e9fb..e5feae33 100644
--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs
+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs
@@ -16,6 +16,10 @@ namespace GTweak.Windows
{
public partial class ImportWindow : Window
{
+ private readonly ConfidentialityTweaks _confTweaks = new ConfidentialityTweaks();
+ private readonly InterfaceTweaks _intfTweaks = new InterfaceTweaks();
+ private readonly ServicesTweaks _svcTweaks = new ServicesTweaks();
+ private readonly SystemTweaks _sysTweaks = new SystemTweaks();
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private readonly HashSet<string> _requiredActions = new HashSet<string>();
private bool _isExpRestartNeed = false;
@@ -62,9 +66,9 @@ namespace GTweak.Windows
var allSections = new (string Section, Action<string, bool> TweakAction, IEnumerable<KeyValuePair<string, string>> NotificationActions, IEnumerable<KeyValuePair<string, bool>> ExplorerMapping)[]
{
- (INIManager.SectionConf, ConfidentialityTweaks.ApplyTweaks, NotificationManager.ConfActions, null),
- (INIManager.SectionIntf, InterfaceTweaks.ApplyTweaks, NotificationManager.IntfActions, ExplorerManager.IntfMapping),
- (INIManager.SectionSvc, ServicesTweaks.ApplyTweaks, null, null),
+ (INIManager.SectionConf, _confTweaks.ApplyTweaks, NotificationManager.ConfActions, null),
+ (INIManager.SectionIntf, _intfTweaks.ApplyTweaks, NotificationManager.IntfActions, ExplorerManager.IntfMapping),
+ (INIManager.SectionSvc, _svcTweaks.ApplyTweaks, null, null),
(INIManager.SectionSys, null, NotificationManager.SysActions, null)
};
@@ -90,14 +94,14 @@ namespace GTweak.Windows
if (section == INIManager.SectionSys)
{
if (tweak.StartsWith("TglButton") && tweak != "TglButton8")
- SystemTweaks.ApplyTweaks(tweak, Convert.ToBoolean(value));
+ _sysTweaks.ApplyTweaks(tweak, Convert.ToBoolean(value));
else if (tweak == "TglButton8")
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
- await backgroundQueue.QueueTask(delegate { SystemTweaks.ApplyTweaks(tweak, Convert.ToBoolean(value), false); });
+ await backgroundQueue.QueueTask(delegate { _sysTweaks.ApplyTweaks(tweak, Convert.ToBoolean(value), false); });
}
else
- SystemTweaks.ApplyTweaksSlider(tweak, Convert.ToUInt32(value));
+ _sysTweaks.ApplyTweaksSlider(tweak, Convert.ToUInt32(value));
foreach (var act in NotificationManager.SysActions.Where(get => get.Key == tweak))
_requiredActions.Add(act.Value);
diff --git a/.Source/GTweak/Windows/MessageWindow.xaml.cs b/.Source/GTweak/Windows/MessageWindow.xaml.cs
index 30666fb5..214cf822 100644
--- a/.Source/GTweak/Windows/MessageWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MessageWindow.xaml.cs
@@ -1,35 +1,26 @@
using GTweak.Utilities.Animation;
-using GTweak.Utilities.Controls;
+using GTweak.Utilities.Managers;
using System;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
-using System.Windows.Threading;
namespace GTweak.Windows
{
public partial class MessageWindow
{
- private readonly DispatcherTimer _timer;
- private TimeSpan _time = TimeSpan.FromSeconds(4);
+
public MessageWindow(bool isViolationSystem = false)
{
InitializeComponent();
- try
+ TimerControlManager timer = new TimerControlManager(TimeSpan.FromSeconds(4), TimerControlManager.TimerMode.CountDown, time =>
{
- _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
- {
- BtnAccept.Content = $"{new Regex("[(05)(04)(03)(02)]").Replace(BtnAccept.Content.ToString(), "")}({_time:ss})";
- if (_time == TimeSpan.Zero) { _timer?.Stop(); Application.Current.Shutdown(); }
- _time = _time.Add(TimeSpan.FromSeconds(-1));
- }, Application.Current.Dispatcher);
-
- }
- catch (Exception ex) { ErrorLogging.LogDebug(ex); }
- _timer?.Start();
+ BtnAccept.Content = $"{new Regex("[(05)(04)(03)(02)]").Replace(BtnAccept.Content.ToString(), "")}({time:ss})";
+ }, () => Application.Current.Shutdown());
+ timer.Start();
if (isViolationSystem)
{
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index 62c7c721..2dcb2068 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -1,6 +1,7 @@
using GTweak.Utilities.Animation;
using GTweak.Utilities.Controls;
using GTweak.Utilities.Helpers;
+using GTweak.Utilities.Managers;
using System;
using System.ComponentModel;
using System.Media;
@@ -14,9 +15,6 @@ namespace GTweak.Windows
{
public partial class NotificationWindow
{
- private readonly DispatcherTimer _timer;
- private TimeSpan _time = TimeSpan.FromSeconds(3);
-
private string clickAction = string.Empty;
internal string TitleNotice { set => TitleSet.Text = value; get => TitleSet.Text; }
internal string TextNotice { set => TextSet.Text = value; get => TextSet.Text; }
@@ -26,13 +24,8 @@ namespace GTweak.Windows
{
InitializeComponent();
- _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
- {
- if (_time == TimeSpan.Zero) { _timer.Stop(); Close(); }
- _time = _time.Add(TimeSpan.FromSeconds(-1));
- }, Application.Current.Dispatcher);
-
- _timer.Start();
+ TimerControlManager timer = new TimerControlManager(TimeSpan.FromSeconds(3), TimerControlManager.TimerMode.CountDown, null, () => { Close(); });
+ timer.Start();
}
private void BtnExit_PreviewMouseDown(object sender, MouseButtonEventArgs e)