From f1a4a61cde82a126ff866596f22303093a908511 Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Tue, 10 Oct 2023 15:18:31 -0400 Subject: [PATCH] All - Cleanup Style --- Nickvision.Aura.Tests/AuraTest.cs | 2 -- Nickvision.Aura.Tests/KeyringTest.cs | 2 +- .../SystemDirectoriesTest.cs | 6 ++-- Nickvision.Aura.Tests/UserDirectoriesTest.cs | 13 ++++----- Nickvision.Aura/AppInfo.cs | 4 +-- Nickvision.Aura/Aura.cs | 8 +++--- Nickvision.Aura/DependencyLocator.cs | 2 +- Nickvision.Aura/IPCServer.cs | 8 +++--- Nickvision.Aura/Keyring/Credential.cs | 5 ++-- Nickvision.Aura/Keyring/Keyring.cs | 4 +-- .../Keyring/KeyringDialogController.cs | 25 ++++++++--------- Nickvision.Aura/Keyring/PasswordGenerator.cs | 16 +++++------ Nickvision.Aura/Keyring/Store.cs | 24 ++++++++-------- .../Keyring/SystemCredentialManager.cs | 4 +-- Nickvision.Aura/Localization/Gettext.cs | 2 +- Nickvision.Aura/Network/INetworkMonitor.cs | 1 - Nickvision.Aura/Network/NetworkMonitor.cs | 10 +++---- Nickvision.Aura/Network/WebHelpers.cs | 2 +- Nickvision.Aura/SystemDirectories.cs | 7 +++-- Nickvision.Aura/Taskbar/LauncherEntry.cs | 28 +++++++++---------- Nickvision.Aura/Taskbar/ProgressFlags.cs | 2 +- Nickvision.Aura/Taskbar/TaskbarFlash.cs | 6 ++-- Nickvision.Aura/Taskbar/TaskbarItem.cs | 2 +- Nickvision.Aura/Update/Updater.cs | 16 +++++------ Nickvision.Aura/UserDirectories.cs | 10 +++---- 25 files changed, 102 insertions(+), 107 deletions(-) diff --git a/Nickvision.Aura.Tests/AuraTest.cs b/Nickvision.Aura.Tests/AuraTest.cs index d9a9896..c2b49ea 100644 --- a/Nickvision.Aura.Tests/AuraTest.cs +++ b/Nickvision.Aura.Tests/AuraTest.cs @@ -1,5 +1,3 @@ -using Xunit.Abstractions; - namespace Nickvision.Aura.Tests; public class AuraTest diff --git a/Nickvision.Aura.Tests/KeyringTest.cs b/Nickvision.Aura.Tests/KeyringTest.cs index 16464d1..a4b94e1 100644 --- a/Nickvision.Aura.Tests/KeyringTest.cs +++ b/Nickvision.Aura.Tests/KeyringTest.cs @@ -11,7 +11,7 @@ public KeyringTest(ITestOutputHelper output) { _output = output; } - + [SkippableFact] public async Task AccessTest() { diff --git a/Nickvision.Aura.Tests/SystemDirectoriesTest.cs b/Nickvision.Aura.Tests/SystemDirectoriesTest.cs index f0fea1f..eb472d1 100644 --- a/Nickvision.Aura.Tests/SystemDirectoriesTest.cs +++ b/Nickvision.Aura.Tests/SystemDirectoriesTest.cs @@ -9,7 +9,7 @@ public class SystemDirectoriesTest [Fact] public void Path() { - var path = new []{ "test0", "test1" }; + var path = new[] { "test0", "test1" }; Environment.SetEnvironmentVariable("PATH", string.Join(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ";" : ":", path)); Assert.True(SystemDirectories.Path.SequenceEqual(path)); } @@ -21,7 +21,7 @@ public void Config() { Assert.True(SystemDirectories.Config.Length == 0); } - var config = new []{ "test0", "test1" }; + var config = new[] { "test0", "test1" }; Environment.SetEnvironmentVariable("XDG_CONFIG_DIRS", string.Join(":", config)); Assert.True(SystemDirectories.Config.SequenceEqual(config)); } @@ -33,7 +33,7 @@ public void Data() { Assert.True(SystemDirectories.Data.Length == 0); } - var data = new []{ "test0", "test1" }; + var data = new[] { "test0", "test1" }; Environment.SetEnvironmentVariable("XDG_DATA_DIRS", string.Join(":", data)); Assert.True(SystemDirectories.Data.SequenceEqual(data)); } diff --git a/Nickvision.Aura.Tests/UserDirectoriesTest.cs b/Nickvision.Aura.Tests/UserDirectoriesTest.cs index 4b9defb..bcde3be 100644 --- a/Nickvision.Aura.Tests/UserDirectoriesTest.cs +++ b/Nickvision.Aura.Tests/UserDirectoriesTest.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using System.Runtime.InteropServices; using Xunit.Abstractions; @@ -8,7 +7,7 @@ namespace Nickvision.Aura.Tests; public class UserDirectoriesTest { private readonly ITestOutputHelper _output; - + public UserDirectoriesTest(ITestOutputHelper output) { _output = output; @@ -80,14 +79,14 @@ public void Desktop() _output.WriteLine($"Desktop: {UserDirectories.Desktop}"); Assert.True(Directory.Exists(UserDirectories.Desktop)); } - + [Fact] public void Documents() { _output.WriteLine($"Documents: {UserDirectories.Documents}"); Assert.True(Directory.Exists(UserDirectories.Documents)); } - + [Fact] public void Downloads() { @@ -101,14 +100,14 @@ public void Music() _output.WriteLine($"Music: {UserDirectories.Music}"); Assert.True(Directory.Exists(UserDirectories.Music)); } - + [Fact] public void Pictures() { _output.WriteLine($"Pictures: {UserDirectories.Pictures}"); Assert.True(Directory.Exists(UserDirectories.Pictures)); } - + [SkippableFact] public void PublicShare() { @@ -116,7 +115,7 @@ public void PublicShare() _output.WriteLine($"PublicShare: {UserDirectories.PublicShare}"); Assert.True(Directory.Exists(UserDirectories.PublicShare)); } - + [Fact] public void Templates() { diff --git a/Nickvision.Aura/AppInfo.cs b/Nickvision.Aura/AppInfo.cs index 24060b7..f831ac0 100644 --- a/Nickvision.Aura/AppInfo.cs +++ b/Nickvision.Aura/AppInfo.cs @@ -102,7 +102,7 @@ internal AppInfo() Artists = new Dictionary(); TranslatorCredits = ""; } - + /// /// Gets changelog in HTML format /// @@ -131,7 +131,7 @@ public List TranslatorNames { get { - var result = new List (); + var result = new List(); foreach (var line in TranslatorCredits.Split("\n")) { if (line.IndexOf("<") > -1) diff --git a/Nickvision.Aura/Aura.cs b/Nickvision.Aura/Aura.cs index 0c50afe..325bb89 100644 --- a/Nickvision.Aura/Aura.cs +++ b/Nickvision.Aura/Aura.cs @@ -14,7 +14,7 @@ namespace Nickvision.Aura; public class Aura { private static Aura? _instance; - + /// /// The AppInfo object /// @@ -39,7 +39,7 @@ private Aura(string id, string name) }; ConfigFiles = new Dictionary(); } - + /// /// Initialize Aura /// @@ -54,7 +54,7 @@ public static void Init(string id, string name) } _instance = new Aura(id, name); } - + /// /// Get currently active instance of Aura /// @@ -70,7 +70,7 @@ public static Aura Active return _instance; } } - + /// /// Start IPCServer or send command to a running one and quit /// diff --git a/Nickvision.Aura/DependencyLocator.cs b/Nickvision.Aura/DependencyLocator.cs index 3a4320f..65da3a9 100644 --- a/Nickvision.Aura/DependencyLocator.cs +++ b/Nickvision.Aura/DependencyLocator.cs @@ -27,7 +27,7 @@ static DependencyLocator() /// The path of the dependency if found, else null public static string? Find(string dependency) { - if(_locations.ContainsKey(dependency) && !string.IsNullOrEmpty(_locations[dependency])) + if (_locations.ContainsKey(dependency) && !string.IsNullOrEmpty(_locations[dependency])) { return _locations[dependency]; } diff --git a/Nickvision.Aura/IPCServer.cs b/Nickvision.Aura/IPCServer.cs index 196828e..0cc37ca 100644 --- a/Nickvision.Aura/IPCServer.cs +++ b/Nickvision.Aura/IPCServer.cs @@ -13,12 +13,12 @@ public class IPCServer { private readonly string _id; private bool _running; - + /// /// Occurs when a command is received /// public EventHandler? CommandReceived; - + /// /// Construct IPCServer /// @@ -27,7 +27,7 @@ public IPCServer() _id = Aura.Active.AppInfo.ID; _running = false; } - + /// /// Enable IPCServer. /// First it will be checked if the server is already running @@ -58,7 +58,7 @@ public bool Communicate(string[] args) } return _running; } - + /// /// Triggers the server to start listening for commands /// diff --git a/Nickvision.Aura/Keyring/Credential.cs b/Nickvision.Aura/Keyring/Credential.cs index 7431ee9..02ebc67 100644 --- a/Nickvision.Aura/Keyring/Credential.cs +++ b/Nickvision.Aura/Keyring/Credential.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Text.RegularExpressions; namespace Nickvision.Aura.Keyring; @@ -42,7 +41,7 @@ public class Credential : IComparable, IEquatable /// The password of the credential /// public string Password { get; set; } - + /// /// Constructs a Credential /// @@ -58,7 +57,7 @@ public Credential(string name, Uri? uri, string username, string password) Username = username; Password = password; } - + /// /// Constructs a Credential /// diff --git a/Nickvision.Aura/Keyring/Keyring.cs b/Nickvision.Aura/Keyring/Keyring.cs index a503fcd..4142eac 100644 --- a/Nickvision.Aura/Keyring/Keyring.cs +++ b/Nickvision.Aura/Keyring/Keyring.cs @@ -12,7 +12,7 @@ public class Keyring : IDisposable { private bool _disposed; private readonly Store _store; - + /// /// The name of the Keyring /// @@ -139,7 +139,7 @@ protected virtual void Dispose(bool disposing) /// True if successful, else false public async Task DestroyAsync() { - if(_store.Destroy()) + if (_store.Destroy()) { try { diff --git a/Nickvision.Aura/Keyring/KeyringDialogController.cs b/Nickvision.Aura/Keyring/KeyringDialogController.cs index 7967f1d..603161a 100644 --- a/Nickvision.Aura/Keyring/KeyringDialogController.cs +++ b/Nickvision.Aura/Keyring/KeyringDialogController.cs @@ -1,4 +1,3 @@ -using Nickvision.Aura.Keyring; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -46,11 +45,11 @@ public class KeyringDialogController /// Thrown if the keyring name is empty or if there is a mismatch between the name and Keyring object public KeyringDialogController(string name, Keyring? keyring) { - if(string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Keyring name can not be empty."); } - if(keyring != null && keyring.Name != name) + if (keyring != null && keyring.Name != name) { throw new ArgumentException("Provided Keyring object does not match the provided keyring name."); } @@ -64,7 +63,7 @@ public KeyringDialogController(string name, Keyring? keyring) /// True if successful, false is Keyring already enabled or error public async Task EnableKeyringAsync(string? password = null) { - if(Keyring == null) + if (Keyring == null) { Keyring = await Keyring.AccessAsync(_keyringName, password); return Keyring != null; @@ -78,7 +77,7 @@ public async Task EnableKeyringAsync(string? password = null) /// True if successful, false if Keyring already disabled public async Task DisableKeyringAsync() { - if(Keyring != null) + if (Keyring != null) { await Keyring.DestroyAsync(); Keyring = null; @@ -112,15 +111,15 @@ public async Task ResetKeyringAsync() public CredentialCheckStatus ValidateCredential(string name, string? uri, string username, string password) { CredentialCheckStatus result = 0; - if(string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { result |= CredentialCheckStatus.EmptyName; } - if(string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password)) { result |= CredentialCheckStatus.EmptyUsernamePassword; } - if(!string.IsNullOrEmpty(uri)) + if (!string.IsNullOrEmpty(uri)) { try { @@ -144,7 +143,7 @@ public CredentialCheckStatus ValidateCredential(string name, string? uri, string /// The list of Credential objects public async Task> GetAllCredentialsAsync() { - if(Keyring != null) + if (Keyring != null) { return await Keyring.GetAllCredentialsAsync(); } @@ -161,7 +160,7 @@ public async Task> GetAllCredentialsAsync() /// True if successful, else false public async Task AddCredentialAsync(string name, string? uri, string username, string password) { - if(ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null) + if (ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null) { return await Keyring.AddCredentialAsync(new Credential(name, string.IsNullOrEmpty(uri) ? null : new Uri(uri), username, password)); } @@ -179,10 +178,10 @@ public async Task AddCredentialAsync(string name, string? uri, string user /// True if successful, else false public async Task UpdateCredentialAsync(int id, string name, string? uri, string username, string password) { - if(ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null) + if (ValidateCredential(name, uri, username, password) == CredentialCheckStatus.Valid && Keyring != null) { var credential = await Keyring.LookupCredentialAsync(id); - if(credential != null) + if (credential != null) { credential.Name = name; credential.Uri = string.IsNullOrEmpty(uri) ? null : new Uri(uri); @@ -201,7 +200,7 @@ public async Task UpdateCredentialAsync(int id, string name, string? uri, /// True if successful, else false public async Task DeleteCredentialAsync(int id) { - if(Keyring != null) + if (Keyring != null) { return await Keyring.DeleteCredentialAsync(id); } diff --git a/Nickvision.Aura/Keyring/PasswordGenerator.cs b/Nickvision.Aura/Keyring/PasswordGenerator.cs index ab41f57..32481d6 100644 --- a/Nickvision.Aura/Keyring/PasswordGenerator.cs +++ b/Nickvision.Aura/Keyring/PasswordGenerator.cs @@ -21,7 +21,7 @@ public class PasswordGenerator { private readonly List _chars; private PasswordContent _contentFlags; - + /// /// Constructs password generator /// @@ -31,25 +31,25 @@ public PasswordGenerator(PasswordContent contentFlags = PasswordContent.Numeric _chars = new(); ContentFlags = contentFlags; } - + /// /// Possible characters for PasswordGenerator /// public PasswordContent ContentFlags { get => _contentFlags; - + set { _contentFlags = value; _chars.Clear(); if (_contentFlags.HasFlag(PasswordContent.Numeric)) { - _chars.AddRange(new []{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }); + _chars.AddRange(new[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }); } if (_contentFlags.HasFlag(PasswordContent.Uppercase)) { - _chars.AddRange(new [] + _chars.AddRange(new[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' @@ -57,7 +57,7 @@ public PasswordContent ContentFlags } if (_contentFlags.HasFlag(PasswordContent.Lowercase)) { - _chars.AddRange(new [] + _chars.AddRange(new[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' @@ -65,7 +65,7 @@ public PasswordContent ContentFlags } if (_contentFlags.HasFlag(PasswordContent.Special)) { - _chars.AddRange(new [] + _chars.AddRange(new[] { '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~' @@ -73,7 +73,7 @@ public PasswordContent ContentFlags } } } - + /// /// Generates new password /// diff --git a/Nickvision.Aura/Keyring/Store.cs b/Nickvision.Aura/Keyring/Store.cs index 902fc0b..4937c9a 100644 --- a/Nickvision.Aura/Keyring/Store.cs +++ b/Nickvision.Aura/Keyring/Store.cs @@ -24,7 +24,7 @@ internal class Store : IDisposable /// The name of the Store /// public string Name { get; init; } - + /// /// The location of the Store on disk /// @@ -59,18 +59,18 @@ private Store(string name, SqliteConnection database) public static Store Create(string name, string password, bool overwrite) { Directory.CreateDirectory(StoreDir); - if(string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { throw new ArgumentException("The name to create a Store must not be empty."); } - if(string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(password)) { throw new ArgumentException("The password to create a Store must not be empty."); } var path = $"{StoreDir}{Path.DirectorySeparatorChar}{name}.nring"; - if(File.Exists(path)) + if (File.Exists(path)) { - if(overwrite) + if (overwrite) { File.Delete(path); } @@ -87,7 +87,7 @@ public static Store Create(string name, string password, bool overwrite) Password = password }.ConnectionString)); } - + /// /// Loads an existing Store /// @@ -99,16 +99,16 @@ public static Store Create(string name, string password, bool overwrite) /// The loaded Store object public static Store Load(string name, string password) { - if(string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { throw new ArgumentException("The name to create a Store must not be empty."); } - if(string.IsNullOrEmpty(password)) + if (string.IsNullOrEmpty(password)) { throw new ArgumentException("The password to create a Store must not be empty."); } var path = $"{StoreDir}{Path.DirectorySeparatorChar}{name}.nring"; - if(!File.Exists(path)) + if (!File.Exists(path)) { throw new FileNotFoundException("A Store is not found with the provided name."); } @@ -127,7 +127,7 @@ public static Store Load(string name, string password) throw new IOException("Unable to access the Store. Make sure the password is correct."); } } - + /// /// Gets whether or not a Store exists /// @@ -170,7 +170,7 @@ protected virtual void Dispose(bool disposing) } if (disposing) { - if(_database.State == ConnectionState.Open) + if (_database.State == ConnectionState.Open) { _database.Close(); } @@ -273,7 +273,7 @@ public async Task> LookupCredentialsAsync(string name) await _database.CloseAsync(); return credentials; } - + /// /// Adds a Credential to the store /// diff --git a/Nickvision.Aura/Keyring/SystemCredentialManager.cs b/Nickvision.Aura/Keyring/SystemCredentialManager.cs index 172aefb..df6f1ba 100644 --- a/Nickvision.Aura/Keyring/SystemCredentialManager.cs +++ b/Nickvision.Aura/Keyring/SystemCredentialManager.cs @@ -61,7 +61,7 @@ internal static class SystemCredentialManager await items[0].SetSecret(Encoding.UTF8.GetBytes(password), "text/plain; charset=utf8"); return password; } - var lookupAttributes = new Dictionary {{ "application", name.ToLower() }}; + var lookupAttributes = new Dictionary { { "application", name.ToLower() } }; await _collection!.CreateItemAsync(name, lookupAttributes, Encoding.UTF8.GetBytes(password), "text/plain; charset=utf8", false); return password; } @@ -109,7 +109,7 @@ private static async Task GetDBusKeyringItemsAsync(string attribute) throw new AuraException("Failed to get or create default collection in system keyring."); } await _collection.UnlockAsync(); - var lookupAttributes = new Dictionary {{ "application", attribute.ToLower() }}; + var lookupAttributes = new Dictionary { { "application", attribute.ToLower() } }; return await _collection.SearchItemsAsync(lookupAttributes); } } \ No newline at end of file diff --git a/Nickvision.Aura/Localization/Gettext.cs b/Nickvision.Aura/Localization/Gettext.cs index 4a34233..0285c79 100644 --- a/Nickvision.Aura/Localization/Gettext.cs +++ b/Nickvision.Aura/Localization/Gettext.cs @@ -17,7 +17,7 @@ public static class Gettext static Gettext() { var name = Aura.Active.AppInfo.EnglishShortName.ToLower(); - if(string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(name)) { name = Aura.Active.AppInfo.Name.Replace(' ', '_').ToLower(); } diff --git a/Nickvision.Aura/Network/INetworkMonitor.cs b/Nickvision.Aura/Network/INetworkMonitor.cs index 69d6fca..f1729b8 100644 --- a/Nickvision.Aura/Network/INetworkMonitor.cs +++ b/Nickvision.Aura/Network/INetworkMonitor.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using Tmds.DBus; diff --git a/Nickvision.Aura/Network/NetworkMonitor.cs b/Nickvision.Aura/Network/NetworkMonitor.cs index c455fcd..0b2a19e 100644 --- a/Nickvision.Aura/Network/NetworkMonitor.cs +++ b/Nickvision.Aura/Network/NetworkMonitor.cs @@ -15,7 +15,7 @@ public class NetworkMonitor : IDisposable private Connection? _dbusConnection; private INetworkMonitor? _networkMonitorDBus; private string[]? _networkAddresses; - + /// /// Occurs when the network state is changed /// @@ -63,7 +63,7 @@ public static async Task NewAsync() /// Finalizes the NetworkMonitor /// ~NetworkMonitor() => Dispose(false); - + /// /// Occurs when network state is changed /// @@ -115,19 +115,19 @@ public async Task GetStateAsync() } return await PingReliableSitesAsync(); } - + /// /// Setup network monitor to use dotnet NetworkChange and ping /// private void SetupPing() { - _networkAddresses = new []{ "8.8.8.8", "http://www.baidu.com", "http://www.aparat.com" }; + _networkAddresses = new[] { "8.8.8.8", "http://www.baidu.com", "http://www.aparat.com" }; NetworkChange.NetworkAvailabilityChanged += async (sender, e) => { _stateChanged?.Invoke(this, await PingReliableSitesAsync()); }; } - + /// /// Ping reliable web sites to ensure network connection /// diff --git a/Nickvision.Aura/Network/WebHelpers.cs b/Nickvision.Aura/Network/WebHelpers.cs index cda581c..c7f3578 100644 --- a/Nickvision.Aura/Network/WebHelpers.cs +++ b/Nickvision.Aura/Network/WebHelpers.cs @@ -51,7 +51,7 @@ public static async Task GetIsValidWebsiteAsync(this Uri uri) public static async Task GetFileAsync(this HttpClient client, string url, string path) { var bytes = await client.GetByteArrayAsync(url); - if(bytes.Length > 0) + if (bytes.Length > 0) { await File.WriteAllBytesAsync(path, bytes); } diff --git a/Nickvision.Aura/SystemDirectories.cs b/Nickvision.Aura/SystemDirectories.cs index 9e36dd9..1df06c8 100644 --- a/Nickvision.Aura/SystemDirectories.cs +++ b/Nickvision.Aura/SystemDirectories.cs @@ -7,11 +7,12 @@ namespace Nickvision.Aura; /// /// System directories paths /// -public class SystemDirectories { +public class SystemDirectories +{ private static string[]? _path; private static string[]? _config; private static string[]? _data; - + /// /// Array of paths from PATH variable /// @@ -23,7 +24,7 @@ public static string[] Path return _path; } } - + /// /// Array of paths from XDG_CONFIG_DIRS /// diff --git a/Nickvision.Aura/Taskbar/LauncherEntry.cs b/Nickvision.Aura/Taskbar/LauncherEntry.cs index 2e85c6d..7f72859 100644 --- a/Nickvision.Aura/Taskbar/LauncherEntry.cs +++ b/Nickvision.Aura/Taskbar/LauncherEntry.cs @@ -12,7 +12,7 @@ internal class LauncherEntry : ILauncherEntry { private readonly string _appUri; private readonly Dictionary _properties; - + /// /// DBus object path /// @@ -28,14 +28,14 @@ public long Count _properties.TryGetValue("count", out var count); return (long?)count ?? 0; } - + set { _properties.TryGetValue("count", out var current); if ((long?)current != value) { _properties["count"] = value; - OnUpdate?.Invoke((_appUri, new Dictionary { {"count", _properties["count"]} })); + OnUpdate?.Invoke((_appUri, new Dictionary { { "count", _properties["count"] } })); } } } @@ -57,7 +57,7 @@ public bool CountVisible if ((bool?)current != value) { _properties["count-visible"] = value; - OnUpdate?.Invoke((_appUri, new Dictionary { {"count-visible", _properties["count-visible"]} })); + OnUpdate?.Invoke((_appUri, new Dictionary { { "count-visible", _properties["count-visible"] } })); } } } @@ -73,14 +73,14 @@ public double Progress _properties.TryGetValue("progress", out var progress); return (double?)progress ?? 0.0; } - + set { _properties.TryGetValue("progress", out var current); if (current == null || Math.Abs((double)current - value) >= 0.01) { _properties["progress"] = value; - OnUpdate?.Invoke((_appUri, new Dictionary { {"progress", _properties["progress"]} })); + OnUpdate?.Invoke((_appUri, new Dictionary { { "progress", _properties["progress"] } })); } } } @@ -95,14 +95,14 @@ public bool ProgressVisible _properties.TryGetValue("progress-visible", out var progressVisible); return (bool?)progressVisible ?? false; } - + set { _properties.TryGetValue("progress-visible", out var current); - if ((bool?) current != value) + if ((bool?)current != value) { _properties["progress-visible"] = value; - OnUpdate?.Invoke((_appUri, new Dictionary { {"progress-visible", _properties["progress-visible"]} })); + OnUpdate?.Invoke((_appUri, new Dictionary { { "progress-visible", _properties["progress-visible"] } })); } } } @@ -124,13 +124,13 @@ public bool Urgent if ((bool?)current != value) { _properties["urgent"] = value; - OnUpdate?.Invoke((_appUri, new Dictionary { {"urgent", _properties["urgent"]} })); + OnUpdate?.Invoke((_appUri, new Dictionary { { "urgent", _properties["urgent"] } })); } } } - + public event Action<(string appUri, IDictionary properties)>? OnUpdate; - + /// /// Constructs LauncherEntry /// @@ -146,7 +146,7 @@ public LauncherEntry(string desktopFile) ObjectPath = $"/com/canonical/unity/launcherentry/{hash}"; _properties = new Dictionary(); } - + /// /// Adds Update DBus signal /// @@ -155,7 +155,7 @@ public Task WatchUpdateAsync(Action<(string appUri, IDictionary /// Returns result in Query DBus method call /// diff --git a/Nickvision.Aura/Taskbar/ProgressFlags.cs b/Nickvision.Aura/Taskbar/ProgressFlags.cs index b30d9c3..c51850e 100644 --- a/Nickvision.Aura/Taskbar/ProgressFlags.cs +++ b/Nickvision.Aura/Taskbar/ProgressFlags.cs @@ -4,7 +4,7 @@ namespace Nickvision.Aura.Taskbar; /// Flags that control the current state of the progress button. /// Specify only one of the following flags; all states are mutually exclusive of all others. /// -public enum ProgressFlags +public enum ProgressFlags { NoProgress = 0, Indeterminate = 0x1, diff --git a/Nickvision.Aura/Taskbar/TaskbarFlash.cs b/Nickvision.Aura/Taskbar/TaskbarFlash.cs index a23bc37..85fd0af 100644 --- a/Nickvision.Aura/Taskbar/TaskbarFlash.cs +++ b/Nickvision.Aura/Taskbar/TaskbarFlash.cs @@ -11,14 +11,14 @@ internal partial class TaskbarFlash [LibraryImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static partial bool FlashWindowEx(ref FlashInfo pwfi); - + //Stop flashing. The system restores the window to its original state. public const UInt32 FLASHW_STOP = 0; //Flash the taskbar button. - public const UInt32 FLASHW_TRAY = 2; + public const UInt32 FLASHW_TRAY = 2; //Flash continuously, until the FLASHW_STOP flag is set. public const UInt32 FLASHW_TIMER = 4; - + public static void Change(nint hwnd, bool state) { var fInfo = new FlashInfo diff --git a/Nickvision.Aura/Taskbar/TaskbarItem.cs b/Nickvision.Aura/Taskbar/TaskbarItem.cs index 068e77b..a8b3f14 100644 --- a/Nickvision.Aura/Taskbar/TaskbarItem.cs +++ b/Nickvision.Aura/Taskbar/TaskbarItem.cs @@ -185,7 +185,7 @@ public bool CountVisible /// /// Count value /// - /// Changing count value automatically sets to true if count is >=0, otherewise will be set to false + /// Changing count value automatically sets to true if count is >=0, otherwise will be set to false public long Count { get => _count; diff --git a/Nickvision.Aura/Update/Updater.cs b/Nickvision.Aura/Update/Updater.cs index 6bd562d..7948073 100644 --- a/Nickvision.Aura/Update/Updater.cs +++ b/Nickvision.Aura/Update/Updater.cs @@ -76,26 +76,26 @@ internal Updater() /// Will force quit the current running app to install the update public async Task WindowsUpdateAsync(VersionType versionType) { - if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || _latestReleaseId == null) + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || _latestReleaseId == null) { return false; } var release = (await _github.Repository.Release.GetAll(_repoOwner, _repoName)).FirstOrDefault(x => x.Id == _latestReleaseId); - if(release != null) + if (release != null) { ReleaseAsset? asset = null; - foreach(var a in release.Assets) + foreach (var a in release.Assets) { - if(a.Name.ToLower().EndsWith("setup.exe")) + if (a.Name.ToLower().EndsWith("setup.exe")) { asset = a; break; } } - if(asset != null) + if (asset != null) { var path = $"{UserDirectories.ApplicationCache}{Path.DirectorySeparatorChar}{asset.Name}"; - if(await WebHelpers.Client.GetFileAsync(asset.BrowserDownloadUrl, path)) + if (await WebHelpers.Client.GetFileAsync(asset.BrowserDownloadUrl, path)) { Process.Start(path); Environment.Exit(0); @@ -118,7 +118,7 @@ public async Task WindowsUpdateAsync(VersionType versionType) Release? latest = null; foreach (var release in releases) { - if((versionType == VersionType.Stable && !release.Prerelease) || versionType == VersionType.Preview && release.Prerelease) + if ((versionType == VersionType.Stable && !release.Prerelease) || versionType == VersionType.Preview && release.Prerelease) { if (latest == null || (latest != null && release.CreatedAt > latest.CreatedAt)) { @@ -126,7 +126,7 @@ public async Task WindowsUpdateAsync(VersionType versionType) } } } - if(latest != null) + if (latest != null) { try { diff --git a/Nickvision.Aura/UserDirectories.cs b/Nickvision.Aura/UserDirectories.cs index 8c387c5..0905334 100644 --- a/Nickvision.Aura/UserDirectories.cs +++ b/Nickvision.Aura/UserDirectories.cs @@ -12,10 +12,10 @@ public static class UserDirectories { [DllImport("shell32.dll")] private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid id, int flags, nint token, [MarshalAs(UnmanagedType.LPWStr)] out string path); - - private static Guid WindowsDownloadsFolderGuid = new ("374DE290-123F-4565-9164-39C4925E467B"); - private static Dictionary _xdgDirectories = new (); - + + private static Guid WindowsDownloadsFolderGuid = new("374DE290-123F-4565-9164-39C4925E467B"); + private static Dictionary _xdgDirectories = new(); + /// /// Main user directory /// @@ -90,7 +90,7 @@ public static string ApplicationCache return path; } } - + /// /// Directory for local data ///