diff --git a/NebulaAuth/Core/DialogsController.cs b/NebulaAuth/Core/DialogsController.cs
index fb9e70d..f7047a7 100644
--- a/NebulaAuth/Core/DialogsController.cs
+++ b/NebulaAuth/Core/DialogsController.cs
@@ -5,7 +5,6 @@ using NebulaAuth.Model.Entities;
using NebulaAuth.View;
using NebulaAuth.View.Dialogs;
using NebulaAuth.ViewModel.Other;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
namespace NebulaAuth.Core;
diff --git a/NebulaAuth/Model/Storage.cs b/NebulaAuth/Model/Storage.cs
index be74735..9cb90ba 100644
--- a/NebulaAuth/Model/Storage.cs
+++ b/NebulaAuth/Model/Storage.cs
@@ -9,7 +9,6 @@ using SteamLib.Utility.MaFiles;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.DirectoryServices.ActiveDirectory;
using System.IO;
using System.Linq;
diff --git a/NebulaAuth/NebulaAuth.csproj b/NebulaAuth/NebulaAuth.csproj
index ac148e1..6713f62 100644
--- a/NebulaAuth/NebulaAuth.csproj
+++ b/NebulaAuth/NebulaAuth.csproj
@@ -19,17 +19,17 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs b/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs
index 56b2ab0..ae1bdce 100644
--- a/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs
+++ b/NebulaAuth/View/Dialogs/LoginAgainOnImportDialog.xaml.cs
@@ -1,6 +1,4 @@
-using System.Windows.Controls;
-
-namespace NebulaAuth.View.Dialogs
+namespace NebulaAuth.View.Dialogs
{
///
/// Логика взаимодействия для LoginAgainDialog.xaml
diff --git a/NebulaAuth/View/UpdaterView.xaml.cs b/NebulaAuth/View/UpdaterView.xaml.cs
index 04363ed..c77a531 100644
--- a/NebulaAuth/View/UpdaterView.xaml.cs
+++ b/NebulaAuth/View/UpdaterView.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace NebulaAuth.View
{
diff --git a/NebulaAuth/ViewModel/MainVM_Code.cs b/NebulaAuth/ViewModel/MainVM_Code.cs
index 3496e9d..2e688db 100644
--- a/NebulaAuth/ViewModel/MainVM_Code.cs
+++ b/NebulaAuth/ViewModel/MainVM_Code.cs
@@ -1,8 +1,10 @@
-using CommunityToolkit.Mvvm.ComponentModel;
+using System;
+using CommunityToolkit.Mvvm.ComponentModel;
using SteamLib.SteamMobile;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Windows;
+using System.Windows.Threading;
namespace NebulaAuth.ViewModel;
@@ -14,30 +16,32 @@ public partial class MainVM
[MemberNotNull(nameof(_codeTimer))]
- [MemberNotNull(nameof(_code))]
private void CreateCodeTimer()
{
- var currentTime = TimeAligner.GetSteamTime();
_codeTimer = new Timer(UpdateCode, null, 0, 1000);
}
+
+
private void UpdateCode(object? state = null)
{
var currentTime = TimeAligner.GetSteamTime();
var untilChange = currentTime - currentTime / 30L * 30L;
var codeProgress = untilChange / 30D * 100;
-
+
string? code = null;
if (untilChange == 0 && SelectedMafile != null)
{
code = SteamGuardCodeGenerator.GenerateCode(SelectedMafile!.SharedSecret);
}
- if(Application.Current == null) return;
- Application.Current.Dispatcher.BeginInvoke(() =>
+
+ if (Application.Current == null) return;
+ Application.Current.Dispatcher.Invoke((string? c) =>
{
+ if (Application.Current.MainWindow?.WindowState == WindowState.Minimized) return;
CodeProgress = codeProgress;
- if (code != null) Code = code;
- });
+ if (c != null) Code = c;
+ }, DispatcherPriority.Background, code);
}
}
\ No newline at end of file
diff --git a/NebulaAuth/ViewModel/MainVM_Groups.cs b/NebulaAuth/ViewModel/MainVM_Groups.cs
index 6b7b767..b5df780 100644
--- a/NebulaAuth/ViewModel/MainVM_Groups.cs
+++ b/NebulaAuth/ViewModel/MainVM_Groups.cs
@@ -5,7 +5,6 @@ using NebulaAuth.Model.Entities;
using System;
using System.Collections.ObjectModel;
using System.Linq;
-using System.Threading.Tasks;
namespace NebulaAuth.ViewModel;
diff --git a/NebulaAuth/ViewModel/Other/LinkAccountVM.cs b/NebulaAuth/ViewModel/Other/LinkAccountVM.cs
index 190ff61..706e0b2 100644
--- a/NebulaAuth/ViewModel/Other/LinkAccountVM.cs
+++ b/NebulaAuth/ViewModel/Other/LinkAccountVM.cs
@@ -6,7 +6,6 @@ using MaterialDesignThemes.Wpf;
using NebulaAuth.Model;
using NebulaAuth.Model.Entities;
using NebulaAuth.Utility;
-using Newtonsoft.Json;
using NLog;
using SteamLib;
using SteamLib.Account;
@@ -26,7 +25,6 @@ using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using NebulaAuth.Core;
-using SteamLib.Utility.MaFiles;
namespace NebulaAuth.ViewModel.Other;
diff --git a/NebulaAuth/ViewModel/Other/LoginAgainOnImportVM.cs b/NebulaAuth/ViewModel/Other/LoginAgainOnImportVM.cs
index 860c16f..1263743 100644
--- a/NebulaAuth/ViewModel/Other/LoginAgainOnImportVM.cs
+++ b/NebulaAuth/ViewModel/Other/LoginAgainOnImportVM.cs
@@ -2,7 +2,6 @@
using NebulaAuth.Model.Entities;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Windows.Forms;
using CommunityToolkit.Mvvm.Input;
namespace NebulaAuth.ViewModel.Other;
diff --git a/NebulaAuth/ViewModel/Other/LoginAgainVM.cs b/NebulaAuth/ViewModel/Other/LoginAgainVM.cs
index 1135370..69fde2d 100644
--- a/NebulaAuth/ViewModel/Other/LoginAgainVM.cs
+++ b/NebulaAuth/ViewModel/Other/LoginAgainVM.cs
@@ -1,9 +1,4 @@
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using CommunityToolkit.Mvvm.ComponentModel;
-using NebulaAuth.Model;
-using NebulaAuth.Model.Entities;
+using CommunityToolkit.Mvvm.ComponentModel;
namespace NebulaAuth.ViewModel.Other;
diff --git a/NebulaAuth/ViewModel/Other/ProxyManagerVM.cs b/NebulaAuth/ViewModel/Other/ProxyManagerVM.cs
index 14ff354..9be1d1f 100644
--- a/NebulaAuth/ViewModel/Other/ProxyManagerVM.cs
+++ b/NebulaAuth/ViewModel/Other/ProxyManagerVM.cs
@@ -21,7 +21,7 @@ public partial class ProxyManagerVM : ObservableObject
[ObservableProperty] private KeyValuePair? _defaultProxy;
public ObservableDictionary Proxies => ProxyStorage.Proxies;
- private static readonly Regex IdRegex = new(@"\{(\d+)\}$");
+ private static readonly Regex IdRegex = new(@"\{(\d+)\}$", RegexOptions.Compiled);
public ProxyManagerVM()
@@ -77,7 +77,7 @@ public partial class ProxyManagerVM : ObservableObject
SnackbarController.SendSnackbar(string.Format(GetLocalizationOrDefault("DuplicateId"), id));
return;
}
- proxies.Add(new KeyValuePair(id, proxy));
+ proxies.Add(KeyValuePair.Create(id, proxy));
}
else
{
diff --git a/NebulaAuth/ViewModel/Other/UpdaterVM.cs b/NebulaAuth/ViewModel/Other/UpdaterVM.cs
index 83fc9cd..715ce35 100644
--- a/NebulaAuth/ViewModel/Other/UpdaterVM.cs
+++ b/NebulaAuth/ViewModel/Other/UpdaterVM.cs
@@ -1,6 +1,5 @@
using AutoUpdaterDotNET;
using CommunityToolkit.Mvvm.ComponentModel;
-using Microsoft.VisualBasic.FileIO;
namespace NebulaAuth.ViewModel.Other;
diff --git a/SteamLibForked/SteamMobile/SteamGuardCodeGenerator.cs b/SteamLibForked/SteamMobile/SteamGuardCodeGenerator.cs
index edd77b1..0f9b01e 100644
--- a/SteamLibForked/SteamMobile/SteamGuardCodeGenerator.cs
+++ b/SteamLibForked/SteamMobile/SteamGuardCodeGenerator.cs
@@ -44,10 +44,8 @@ public class SteamGuardCodeGenerator : ISteamGuardProvider
time >>= 8;
}
- HMACSHA1 hmacGenerator = new()
- {
- Key = sharedSecret
- };
+ using HMACSHA1 hmacGenerator = new();
+ hmacGenerator.Key = sharedSecret;
var hashedData = hmacGenerator.ComputeHash(timeArray);
var codeArray = new byte[5];
diff --git a/SteamLibForked/SteamMobile/TimeAligner.cs b/SteamLibForked/SteamMobile/TimeAligner.cs
index cee4720..27007c2 100644
--- a/SteamLibForked/SteamMobile/TimeAligner.cs
+++ b/SteamLibForked/SteamMobile/TimeAligner.cs
@@ -46,9 +46,8 @@ public static class TimeAligner
var req = new HttpRequestMessage(HttpMethod.Post, SteamConstants.STEAM_API + TIME_ALIGN_ENDPOINT);
var response = client.Send(req).EnsureSuccessStatusCode();
sw.Stop();
- var stream = new StreamReader(response.Content.ReadAsStream());
+ using var stream = new StreamReader(response.Content.ReadAsStream());
var respStr = stream.ReadToEnd();
- stream.Dispose();
var j = JObject.Parse(respStr);
var time = j["response"]!["server_time"]!.Value();
var now = UtcNow - sw.Elapsed;
@@ -80,7 +79,6 @@ public static class TimeAligner
}
finally
{
- sw.Stop();
client.Dispose();
}
}