Skip to content

Portable Tool for an Ideal Windows Setup

fix display of disconnected (phantom) devices deb 5.3.0

Greedeks76fda00c0fb1
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index 52e7dfde..01089da3 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -15,6 +15,8 @@ namespace GTweak
internal static event EventHandler ThemeChanged;
internal static event EventHandler TweaksImported;
+ private readonly SystemDiagnostics _systemDiagnostics = new SystemDiagnostics();
+
internal static void UpdateImport() => TweaksImported?.Invoke(default, EventArgs.Empty);
public App()
@@ -23,6 +25,7 @@ namespace GTweak
DispatcherUnhandledException += OnDispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
+ _systemDiagnostics.HandleDevicesEvents += OnHandleDevicesEvents;
}
private async void App_Startup(object sender, StartupEventArgs e)
@@ -37,6 +40,8 @@ namespace GTweak
RunGuard.CheckingApplicationCopies();
await RunGuard.CheckingSystemRequirements();
+ _systemDiagnostics.StartDeviceMonitoring();
+
new LoadingWindow().Show();
}
@@ -54,6 +59,12 @@ namespace GTweak
Environment.Exit(0);
}
+ private async void OnHandleDevicesEvents(MonitoringService.DeviceType deviceType)
+ {
+ BackgroundQueue backgroundQueue = new BackgroundQueue();
+ await backgroundQueue.QueueTask(delegate { _systemDiagnostics.UpdatingDevicesData(deviceType); });
+ }
+
private static Uri GetResourceUri(string folder, bool isTheme = false) => isTheme ? new Uri($"Styles/Themes/{folder}/Colors.xaml", UriKind.Relative) : new Uri($"Languages/{folder}/Localize.xaml", UriKind.Relative);
internal static string Language
@@ -132,5 +143,11 @@ namespace GTweak
ThemeChanged?.Invoke(default, EventArgs.Empty);
}
}
+
+ protected override void OnExit(ExitEventArgs e)
+ {
+ _systemDiagnostics?.StopDeviceMonitoring();
+ base.OnExit(e);
+ }
}
}
diff --git a/.Source/GTweak/Properties/AssemblyInfo.cs b/.Source/GTweak/Properties/AssemblyInfo.cs
index cae3ab9d..5d08a7c2 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.cs
+++ b/.Source/GTweak/Properties/AssemblyInfo.cs
@@ -7,9 +7,9 @@ using System.Windows;
[assembly: AssemblyProduct("GTweak")]
[assembly: AssemblyCopyright("© 2024-2025 Greedeks")]
[assembly: AssemblyTrademark("Greedeks")]
-[assembly: AssemblyInformationalVersion("Build: 5.2.9")]
-[assembly: AssemblyVersion("5.2.65.481")]
-[assembly: AssemblyFileVersion("5.2.65.481")]
+[assembly: AssemblyInformationalVersion("Build: 5.3.0")]
+[assembly: AssemblyVersion("5.3.22.935")]
+[assembly: AssemblyFileVersion("5.3.22.935")]
[assembly: ComVisible(false)]
diff --git a/.Source/GTweak/Properties/AssemblyInfo.tt b/.Source/GTweak/Properties/AssemblyInfo.tt
index 84a2f3b9..779e5cf5 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.tt
+++ b/.Source/GTweak/Properties/AssemblyInfo.tt
@@ -20,7 +20,7 @@ using System.Windows;
ResourceDictionaryLocation.SourceAssembly
)]
<#+
- private const string majorVersion = "Build: 5.2.9";
+ private const string majorVersion = "Build: 5.3.0";
private string GenerateVersion()
{
diff --git a/.Source/GTweak/View/DataSystemView.xaml b/.Source/GTweak/View/DataSystemView.xaml
index 9b6fb2bd..6f7ab78e 100644
--- a/.Source/GTweak/View/DataSystemView.xaml
+++ b/.Source/GTweak/View/DataSystemView.xaml
@@ -7,7 +7,7 @@
xmlns:vm="clr-namespace:GTweak.Core.ViewModel"
xmlns:xrpb="http://XamlRadialProgressBar/DotNet"
mc:Ignorable="d" d:DesignHeight="550" d:DesignWidth="1100"
- Style="{StaticResource LaunchPage}" Unloaded="Page_Unloaded" Loaded="Page_Loaded">
+ Style="{StaticResource LaunchPage}">
<UserControl.DataContext>
<vm:DataSystemVM />
</UserControl.DataContext>
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index 585d2d04..1e4c677a 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -19,7 +19,6 @@ namespace GTweak.View
{
public partial class DataSystemView : UserControl
{
- private readonly MonitoringService _monitoringService = new MonitoringService();
private readonly SystemDiagnostics _systemDiagnostics = new SystemDiagnostics();
private readonly BackgroundQueue backgroundQueue = new BackgroundQueue();
private readonly TimerControlManager _timer = default;
@@ -28,9 +27,7 @@ namespace GTweak.View
{
InitializeComponent();
- _monitoringService.HandleDevicesEvents += OnHandleDevicesEvents;
-
- RAMLoad.Value = _monitoringService.GetMemoryUsage;
+ RAMLoad.Value = _systemDiagnostics.GetMemoryUsage;
CPULoad.Value = MonitoringService.GetProcessorUsage;
App.LanguageChanged += delegate
@@ -51,7 +48,7 @@ namespace GTweak.View
{
if ((int)time.TotalSeconds % 2 == 0)
{
- await backgroundQueue.QueueTask(async delegate { await _monitoringService.GetTotalProcessorUsage(); });
+ await backgroundQueue.QueueTask(async delegate { await _systemDiagnostics.GetTotalProcessorUsage(); });
AnimationProgressBars();
}
else if ((int)time.TotalSeconds % 5 == 0)
@@ -66,16 +63,17 @@ namespace GTweak.View
IpAddress.Effect.BeginAnimation(BlurEffect.RadiusProperty, FactoryAnimation.CreateTo(0.18, () => { SettingsEngine.IsHiddenIpAddress = false; }));
});
});
- }
+ _timer.Start();
- private async void OnHandleDevicesEvents(MonitoringService.DeviceType deviceType) => await backgroundQueue.QueueTask(delegate { _systemDiagnostics.UpdatingDevicesData(deviceType); });
+ Unloaded += delegate { _timer.Stop(); };
+ }
private void AnimationProgressBars()
{
Dispatcher.Invoke(() =>
{
CPULoad.BeginAnimation(ProgressBar.ValueProperty, FactoryAnimation.CreateIn(CPULoad.Value, MonitoringService.GetProcessorUsage, 0.2));
- RAMLoad.BeginAnimation(ProgressBar.ValueProperty, FactoryAnimation.CreateIn(RAMLoad.Value, _monitoringService.GetMemoryUsage, 0.2));
+ RAMLoad.BeginAnimation(ProgressBar.ValueProperty, FactoryAnimation.CreateIn(RAMLoad.Value, _systemDiagnostics.GetMemoryUsage, 0.2));
});
}
private void AnimationPopup()
@@ -131,17 +129,5 @@ namespace GTweak.View
AnimationPopup();
}
}
-
- private void Page_Loaded(object sender, RoutedEventArgs e)
- {
- _monitoringService.StartDeviceMonitoring();
- _timer.Start();
- }
-
- private void Page_Unloaded(object sender, RoutedEventArgs e)
- {
- _monitoringService.StopDeviceMonitoring();
- _timer.Stop();
- }
}
}
diff --git a/.Source/GTweak/View/PakagesView.xaml.cs b/.Source/GTweak/View/PakagesView.xaml.cs
index 6921db91..1f6aeca3 100644
--- a/.Source/GTweak/View/PakagesView.xaml.cs
+++ b/.Source/GTweak/View/PakagesView.xaml.cs
@@ -20,7 +20,7 @@ namespace GTweak.View
public partial class PakagesView : UserControl
{
private readonly BackgroundQueue backgroundQueue = new BackgroundQueue();
- private readonly TimerControlManager timer = default;
+ private readonly TimerControlManager _timer = default;
private bool _isWebViewRemoval = false;
@@ -28,7 +28,7 @@ namespace GTweak.View
{
InitializeComponent();
- timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, time =>
+ _timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, time =>
{
if ((int)time.TotalSeconds % 5 == 0)
{
@@ -38,7 +38,9 @@ namespace GTweak.View
backgroundWorker.RunWorkerAsync();
}
});
- timer.Start();
+
+ if (_timer == null)
+ _timer.Start();
}
private void Apps_MouseEnter(object sender, MouseEventArgs e)
diff --git a/.Source/GTweak/Windows/MessageWindow.xaml.cs b/.Source/GTweak/Windows/MessageWindow.xaml.cs
index 7d1e5aa5..308387a7 100644
--- a/.Source/GTweak/Windows/MessageWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MessageWindow.xaml.cs
@@ -10,17 +10,16 @@ namespace GTweak.Windows
{
public partial class MessageWindow
{
-
-
+ private readonly TimerControlManager _timer = default;
public MessageWindow(bool isViolationSystem = false)
{
InitializeComponent();
- TimerControlManager timer = new TimerControlManager(TimeSpan.FromSeconds(4), TimerControlManager.TimerMode.CountDown, time =>
+ _timer = new TimerControlManager(TimeSpan.FromSeconds(4), TimerControlManager.TimerMode.CountDown, time =>
{
BtnAccept.Content = $"{new Regex("[(05)(04)(03)(02)]").Replace(BtnAccept.Content.ToString(), "")}({time:ss})";
}, () => Application.Current.Shutdown());
- timer.Start();
+ _timer.Start();
if (isViolationSystem)
{
@@ -45,7 +44,7 @@ namespace GTweak.Windows
{
Closing -= Window_Closing;
e.Cancel = true;
- BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.1, () => { Close(); }));
+ BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.1, () => { _timer.Stop(); Close(); }));
}
private void Window_Loaded(object sender, RoutedEventArgs e) => BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0, 1, 0.2));
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index b189bffb..db5c8a47 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -15,6 +15,8 @@ namespace GTweak.Windows
public partial class NotificationWindow
{
private NotificationManager.NoticeAction _requiredAction = default;
+ private readonly TimerControlManager _timer = default;
+
internal string NoticeTitle { set => Header.Text = value; get => Header.Text; }
internal string NoticeText { set => MessageBody.Text = value; get => MessageBody.Text; }
internal NotificationManager.NoticeAction RequiredAction { set => _requiredAction = value; get => _requiredAction; }
@@ -23,8 +25,8 @@ namespace GTweak.Windows
{
InitializeComponent();
- TimerControlManager timer = new TimerControlManager(TimeSpan.FromSeconds(3), TimerControlManager.TimerMode.CountDown, null, () => { Close(); });
- timer.Start();
+ _timer = new TimerControlManager(TimeSpan.FromSeconds(3), TimerControlManager.TimerMode.CountDown, null, () => { Close(); });
+ _timer.Start();
}
private void BtnExit_PreviewMouseDown(object sender, MouseButtonEventArgs e)
@@ -72,7 +74,7 @@ namespace GTweak.Windows
{
Closing -= Window_Closing;
e.Cancel = true;
- BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.1, () => { Close(); }));
+ BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.1, () => { _timer.Stop(); Close(); }));
}
}
}