Skip to content

Commit 5ed7671

Browse files
committed
fix issue #125
1 parent 56c2a8d commit 5ed7671

File tree

5 files changed

+322
-89
lines changed

5 files changed

+322
-89
lines changed

VolumeControl/GlobalSuppressions.cs

+1-11
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.CheckForUpdates")]
1212
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.CustomAddonDirectories")]
1313
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.CustomLocalizationDirectories")]
14-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.EnableDefaultDevice")]
15-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationEnabled")]
16-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationShowsVolumeChange")]
17-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationTimeout")]
1814
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.ShowIcons")]
1915
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.ShowUpdateMessageBox")]
2016
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.StartMinimized")]
@@ -28,17 +24,11 @@
2824
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationDragRequiresAlt")]
2925
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.DeleteHotkeyConfirmation")]
3026
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.LockTargetSession")]
31-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationDoFadeIn")]
32-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationDoFadeOut")]
33-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationFadeInDuration")]
34-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationFadeOutDuration")]
3527
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationSavesPosition")]
36-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.NotificationTimeoutEnabled")]
3728
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.VolumeStepSize")]
3829
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.HiddenSessionProcessNames")]
3930
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.LockTargetDevice")]
40-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.DeviceListNotificationConfig")]
4131
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.KeepRelativePosition")]
4232
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.LogEnabled")]
4333
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.LogFilePath")]
44-
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.SessionListNotificationConfig")]
34+
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~P:VolumeControl.Helpers.VCSettings.RunAtStartup")]

VolumeControl/Helpers/PathFinder.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Configuration;
33
using System.Diagnostics;
44
using System.IO;
5+
using System.Reflection;
56
using VolumeControl.Log;
67

78
namespace VolumeControl.Helpers
@@ -20,7 +21,15 @@ internal static class PathFinder
2021
/// </remarks>
2122
public static string ApplicationAppDataPath => _localAppData ??= FindLocalAppDataConfigDir();
2223
private static string? _localAppData = null;
23-
public static string ExecutableDirectory => _executableDirectory ??= FindExecutableDirectory();
24+
/// <summary>
25+
/// The path of Volume Control's executable.
26+
/// </summary>
27+
public static string ExecutablePath => _executablePath ??= FindExecutablePath();
28+
private static string? _executablePath = null;
29+
/// <summary>
30+
/// The directory that Volume Control's executable is located in.
31+
/// </summary>
32+
public static string ExecutableDirectory => _executableDirectory ??= Path.GetDirectoryName(FindExecutablePath()) ?? AppDomain.CurrentDomain.BaseDirectory;
2433
private static string? _executableDirectory = null;
2534
#endregion Properties
2635

@@ -44,10 +53,10 @@ private static string FindLocalAppDataConfigDir()
4453
}
4554
return path;
4655
}
47-
private static string FindExecutableDirectory()
56+
private static string FindExecutablePath()
4857
{
4958
using var proc = Process.GetCurrentProcess();
50-
return Path.GetDirectoryName(proc.MainModule?.FileName) ?? AppDomain.CurrentDomain.BaseDirectory;
59+
return proc.MainModule?.FileName!;
5160
}
5261
#endregion Functions
5362
}

VolumeControl/Helpers/VCSettings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public bool DeleteHotkeyConfirmation
8080
/// <inheritdoc cref="Config.RunAtStartup"/>
8181
public bool? RunAtStartup
8282
{
83-
get => !RunAtStartupHelper.ValueEquals(this.ExecutablePath) && !RunAtStartupHelper.ValueEqualsNull() ? null : Settings.RunAtStartup;
84-
set => RunAtStartupHelper.Value = (Settings.RunAtStartup = value ?? false) ? this.ExecutablePath : null;
83+
get => RunAtStartupHelper.IsEnabled;
84+
set => RunAtStartupHelper.IsEnabled = Settings.RunAtStartup = value ?? false;
8585
}
8686
/// <inheritdoc cref="Config.StartMinimized"/>
8787
public bool StartMinimized

0 commit comments

Comments
 (0)