From c2043ea08e4c21c8ae8e22f4fb96cda4a1374c3c Mon Sep 17 00:00:00 2001 From: radj307 Date: Mon, 30 May 2022 22:36:48 -0400 Subject: [PATCH] bug fixes, performance increases, & ui improvements --- HotkeyLib/WindowsHotkey.cs | 1 + VolumeControl.Audio/AudioAPI.cs | 2 +- VolumeControl.Audio/AudioDevice.cs | 2 +- VolumeControl.Audio/AudioSession.cs | 2 +- VolumeControl.Core/CompatibleVersions.cs | 2 +- VolumeControl.Core/VolumeControl.Core.csproj | 6 +- .../Attributes/ActionAddonAttribute.cs | 2 +- VolumeControl.Hotkeys/Enum/EVirtualKeyCode.cs | 279 ++++++++++++++++++ .../Interfaces/IActionBinding.cs | 3 +- VolumeControl.Log/LogWriter.cs | 2 +- VolumeControl.Log/VolumeControl.Log.csproj | 50 ++-- .../ArrayExtensions.cs | 26 ++ .../EnumExtensions.cs | 2 +- .../Int32Extensions.cs | 3 +- .../ListExtensions.cs | 2 +- .../MathExt.cs | 2 +- .../NullableBoolExtensions.cs | 2 +- .../ProcessExtensions.cs | 2 +- .../RealNumberExtensions.cs | 2 +- .../StringExtensions.cs | 2 +- .../TimerExtensions.cs | 2 +- .../VolumeControl.TypeExtensions.csproj | 19 ++ VolumeControl.WPF/Bindings/MultiBinding.cs | 14 +- .../Collections/BindableEventType.cs | 22 +- .../Collections/ObservableList.cs | 12 +- .../Collections/ObservableListExtensions.cs | 16 - VolumeControl.WPF/Controls/NumericUpDown.cs | 6 +- .../Converters/ConverterChain.cs | 3 + .../MultiBindingBooleanConverter.cs | 4 + ...ter.cs => SquaredCornerRadiusConverter.cs} | 12 +- VolumeControl.WPF/Markup/ConvertExtension.cs | 25 ++ VolumeControl.WPF/PInvoke/MINMAXINFO.cs | 2 + VolumeControl.WPF/Themes/Generic.xaml | 6 +- VolumeControl.WPF/VolumeControl.WPF.csproj | 5 +- VolumeControl/App.xaml.cs | 6 +- VolumeControl/Helpers/Update/Release.cs | 2 +- .../Helpers/VolumeControlSettings.cs | 2 +- VolumeControl/ListNotification.xaml.cs | 3 +- VolumeControl/Mixer.xaml | 67 +++-- volume-control-3.sln | 8 + 40 files changed, 510 insertions(+), 120 deletions(-) create mode 100644 VolumeControl.TypeExtensions/ArrayExtensions.cs rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/EnumExtensions.cs (98%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/Int32Extensions.cs (94%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/ListExtensions.cs (97%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/MathExt.cs (99%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/NullableBoolExtensions.cs (98%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/ProcessExtensions.cs (99%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/RealNumberExtensions.cs (97%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/StringExtensions.cs (97%) rename {VolumeControl.Core/Extensions => VolumeControl.TypeExtensions}/TimerExtensions.cs (96%) create mode 100644 VolumeControl.TypeExtensions/VolumeControl.TypeExtensions.csproj delete mode 100644 VolumeControl.WPF/Collections/ObservableListExtensions.cs rename VolumeControl.WPF/Converters/{NumericUpDownCornerRadiusConverter.cs => SquaredCornerRadiusConverter.cs} (81%) create mode 100644 VolumeControl.WPF/Markup/ConvertExtension.cs diff --git a/HotkeyLib/WindowsHotkey.cs b/HotkeyLib/WindowsHotkey.cs index e30f5d148..d9e4fa15e 100644 --- a/HotkeyLib/WindowsHotkey.cs +++ b/HotkeyLib/WindowsHotkey.cs @@ -74,6 +74,7 @@ public Keys Key set { NotifyPropertyChanging(); + NotifyPropertyChanging(nameof(Valid)); _combo.Key = value; NotifyKeysChanged(); NotifyPropertyChanged(); diff --git a/VolumeControl.Audio/AudioAPI.cs b/VolumeControl.Audio/AudioAPI.cs index 370fe7448..a9e44af02 100644 --- a/VolumeControl.Audio/AudioAPI.cs +++ b/VolumeControl.Audio/AudioAPI.cs @@ -3,9 +3,9 @@ using System.Runtime.CompilerServices; using VolumeControl.Audio.Events; using VolumeControl.Audio.Interfaces; -using VolumeControl.Core.Extensions; using VolumeControl.Log; using VolumeControl.WPF.Collections; +using VolumeControl.TypeExtensions; namespace VolumeControl.Audio { diff --git a/VolumeControl.Audio/AudioDevice.cs b/VolumeControl.Audio/AudioDevice.cs index b4d4d5042..fd24fcb68 100644 --- a/VolumeControl.Audio/AudioDevice.cs +++ b/VolumeControl.Audio/AudioDevice.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; using System.Windows.Media; using VolumeControl.Audio.Interfaces; -using VolumeControl.Core.Extensions; +using VolumeControl.TypeExtensions; namespace VolumeControl.Audio { diff --git a/VolumeControl.Audio/AudioSession.cs b/VolumeControl.Audio/AudioSession.cs index 26a33fb9c..a0c2f3682 100644 --- a/VolumeControl.Audio/AudioSession.cs +++ b/VolumeControl.Audio/AudioSession.cs @@ -5,8 +5,8 @@ using System.Runtime.CompilerServices; using System.Windows.Media; using VolumeControl.Audio.Interfaces; -using VolumeControl.Core.Extensions; using VolumeControl.Log; +using VolumeControl.TypeExtensions; namespace VolumeControl.Audio { diff --git a/VolumeControl.Core/CompatibleVersions.cs b/VolumeControl.Core/CompatibleVersions.cs index ada11e874..be110b7ff 100644 --- a/VolumeControl.Core/CompatibleVersions.cs +++ b/VolumeControl.Core/CompatibleVersions.cs @@ -1,5 +1,5 @@ using Semver; -using VolumeControl.Core.Extensions; +using VolumeControl.TypeExtensions; namespace VolumeControl.Core { diff --git a/VolumeControl.Core/VolumeControl.Core.csproj b/VolumeControl.Core/VolumeControl.Core.csproj index 1fb29e094..82b964a4c 100644 --- a/VolumeControl.Core/VolumeControl.Core.csproj +++ b/VolumeControl.Core/VolumeControl.Core.csproj @@ -6,13 +6,10 @@ enable Debug;Release;SDK True - True - + @@ -21,6 +18,7 @@ + diff --git a/VolumeControl.Hotkeys/Attributes/ActionAddonAttribute.cs b/VolumeControl.Hotkeys/Attributes/ActionAddonAttribute.cs index 22a86a877..96ab64680 100644 --- a/VolumeControl.Hotkeys/Attributes/ActionAddonAttribute.cs +++ b/VolumeControl.Hotkeys/Attributes/ActionAddonAttribute.cs @@ -1,5 +1,5 @@ using VolumeControl.Core; -using VolumeControl.Core.Extensions; +using VolumeControl.TypeExtensions; namespace VolumeControl.Hotkeys.Attributes { diff --git a/VolumeControl.Hotkeys/Enum/EVirtualKeyCode.cs b/VolumeControl.Hotkeys/Enum/EVirtualKeyCode.cs index 583024471..ed2306192 100644 --- a/VolumeControl.Hotkeys/Enum/EVirtualKeyCode.cs +++ b/VolumeControl.Hotkeys/Enum/EVirtualKeyCode.cs @@ -1,14 +1,293 @@ namespace VolumeControl.Hotkeys.Enum { +# pragma warning disable CA1069 // Enums values should not be duplicated + /// + /// Windows Virtual Key Codes.
+ /// This includes every labelled virtual key used by windows.
+ /// + ///
public enum EVirtualKeyCode : byte { + /// Null None = 0x00, + /// Left mouse button + VK_LBUTTON = 0x01, + /// Right mouse button + VK_RBUTTON = 0x02, + /// Control-break processing + VK_CANCEL = 0x03, + /// Middle mouse button (three-button mouse) + VK_MBUTTON = 0x04, + /// X1 mouse button + VK_XBUTTON1 = 0x05, + /// X2 mouse button + VK_XBUTTON2 = 0x06, + /// BACKSPACE key + VK_BACK = 0x08, + /// TAB key + VK_TAB = 0x09, + /// CLEAR key + VK_CLEAR = 0x0C, + /// ENTER key + VK_RETURN = 0x0D, + /// SHIFT key + VK_SHIFT = 0x10, + /// CTRL key + VK_CONTROL = 0x11, + /// ALT key + VK_MENU = 0x12, + /// PAUSE key + VK_PAUSE = 0x13, + /// CAPS LOCK key + VK_CAPITAL = 0x14, + /// IME Kana mode + VK_KANA = 0x15, + /// IME Hanguel mode (maintained for compatibility; use VK_HANGUL) + VK_HANGUEL = 0x15, + /// IME Hangul mode + VK_HANGUL = 0x15, + /// IME On + VK_IME_ON = 0x16, + /// IME Junja mode + VK_JUNJA = 0x17, + /// IME final mode + VK_FINAL = 0x18, + /// IME Hanja mode + VK_HANJA = 0x19, + /// IME Kanji mode + VK_KANJI = 0x19, + /// IME Off + VK_IME_OFF = 0x1A, + /// ESC key + VK_ESCAPE = 0x1B, + /// IME convert + VK_CONVERT = 0x1C, + /// IME nonconvert + VK_NONCONVERT = 0x1D, + /// IME accept + VK_ACCEPT = 0x1E, + /// IME mode change request + VK_MODECHANGE = 0x1F, + /// SPACEBAR + VK_SPACE = 0x20, + /// PAGE UP key + VK_PRIOR = 0x21, + /// PAGE DOWN key + VK_NEXT = 0x22, + /// END key + VK_END = 0x23, + /// HOME key + VK_HOME = 0x24, + /// LEFT ARROW key + VK_LEFT = 0x25, + /// UP ARROW key + VK_UP = 0x26, + /// RIGHT ARROW key + VK_RIGHT = 0x27, + /// DOWN ARROW key + VK_DOWN = 0x28, + /// SELECT key + VK_SELECT = 0x29, + /// PRINT key + VK_PRINT = 0x2A, + /// EXECUTE key + VK_EXECUTE = 0x2B, + /// PRINT SCREEN key + VK_SNAPSHOT = 0x2C, + /// INS key + VK_INSERT = 0x2D, + /// DEL key + VK_DELETE = 0x2E, + /// HELP key + VK_HELP = 0x2F, + /// Left Windows key (Natural keyboard) + VK_LWIN = 0x5B, + /// Right Windows key (Natural keyboard) + VK_RWIN = 0x5C, + /// Applications key (Natural keyboard) + VK_APPS = 0x5D, + /// Computer Sleep key + VK_SLEEP = 0x5F, + /// Numeric keypad 0 key + VK_NUMPAD0 = 0x60, + /// Numeric keypad 1 key + VK_NUMPAD1 = 0x61, + /// Numeric keypad 2 key + VK_NUMPAD2 = 0x62, + /// Numeric keypad 3 key + VK_NUMPAD3 = 0x63, + /// Numeric keypad 4 key + VK_NUMPAD4 = 0x64, + /// Numeric keypad 5 key + VK_NUMPAD5 = 0x65, + /// Numeric keypad 6 key + VK_NUMPAD6 = 0x66, + /// Numeric keypad 7 key + VK_NUMPAD7 = 0x67, + /// Numeric keypad 8 key + VK_NUMPAD8 = 0x68, + /// Numeric keypad 9 key + VK_NUMPAD9 = 0x69, + /// Multiply key + VK_MULTIPLY = 0x6A, + /// Add key + VK_ADD = 0x6B, + /// Separator key + VK_SEPARATOR = 0x6C, + /// Subtract key + VK_SUBTRACT = 0x6D, + /// Decimal key + VK_DECIMAL = 0x6E, + /// Divide key + VK_DIVIDE = 0x6F, + /// F1 key + VK_F1 = 0x70, + /// F2 key + VK_F2 = 0x71, + /// F3 key + VK_F3 = 0x72, + /// F4 key + VK_F4 = 0x73, + /// F5 key + VK_F5 = 0x74, + /// F6 key + VK_F6 = 0x75, + /// F7 key + VK_F7 = 0x76, + /// F8 key + VK_F8 = 0x77, + /// F9 key + VK_F9 = 0x78, + /// F10 key + VK_F10 = 0x79, + /// F11 key + VK_F11 = 0x7A, + /// F12 key + VK_F12 = 0x7B, + /// F13 key + VK_F13 = 0x7C, + /// F14 key + VK_F14 = 0x7D, + /// F15 key + VK_F15 = 0x7E, + /// F16 key + VK_F16 = 0x7F, + /// F17 key + VK_F17 = 0x80, + /// F18 key + VK_F18 = 0x81, + /// F19 key + VK_F19 = 0x82, + /// F20 key + VK_F20 = 0x83, + /// F21 key + VK_F21 = 0x84, + /// F22 key + VK_F22 = 0x85, + /// F23 key + VK_F23 = 0x86, + /// F24 key + VK_F24 = 0x87, + /// NUM LOCK key + VK_NUMLOCK = 0x90, + /// SCROLL LOCK key + VK_SCROLL = 0x91, + /// Left SHIFT key + VK_LSHIFT = 0xA0, + /// Right SHIFT key + VK_RSHIFT = 0xA1, + /// Left CONTROL key + VK_LCONTROL = 0xA2, + /// Right CONTROL key + VK_RCONTROL = 0xA3, + /// Left MENU key + VK_LMENU = 0xA4, + /// Right MENU key + VK_RMENU = 0xA5, + /// Browser Back key + VK_BROWSER_BACK = 0xA6, + /// Browser Forward key + VK_BROWSER_FORWARD = 0xA7, + /// Browser Refresh key + VK_BROWSER_REFRESH = 0xA8, + /// Browser Stop key + VK_BROWSER_STOP = 0xA9, + /// Browser Search key + VK_BROWSER_SEARCH = 0xAA, + /// Browser Favorites key + VK_BROWSER_FAVORITES = 0xAB, + /// Browser Start and Home key + VK_BROWSER_HOME = 0xAC, + /// Volume Mute key VK_VOLUME_MUTE = 0xAD, + /// Volume Down key VK_VOLUME_DOWN = 0xAE, + /// Volume Up key VK_VOLUME_UP = 0xAF, + /// Next Track key VK_MEDIA_NEXT_TRACK = 0xB0, + /// Previous Track key VK_MEDIA_PREV_TRACK = 0xB1, + /// Stop Media key VK_MEDIA_STOP = 0xB2, + /// Play/Pause Media key VK_MEDIA_PLAY_PAUSE = 0xB3, + /// Start Mail key + VK_LAUNCH_MAIL = 0xB4, + /// Select Media key + VK_LAUNCH_MEDIA_SELECT = 0xB5, + /// Start Application 1 key + VK_LAUNCH_APP1 = 0xB6, + /// Start Application 2 key + VK_LAUNCH_APP2 = 0xB7, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key + VK_OEM_1 = 0xBA, + /// For any country/region, the '+' key + VK_OEM_PLUS = 0xBB, + /// For any country/region, the ',' key + VK_OEM_COMMA = 0xBC, + /// For any country/region, the '-' key + VK_OEM_MINUS = 0xBD, + /// For any country/region, the '.' key + VK_OEM_PERIOD = 0xBE, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key + VK_OEM_2 = 0xBF, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key + VK_OEM_3 = 0xC0, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key + VK_OEM_4 = 0xDB, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key + VK_OEM_5 = 0xDC, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key + VK_OEM_6 = 0xDD, + /// Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key + VK_OEM_7 = 0xDE, + /// Used for miscellaneous characters; it can vary by keyboard. + VK_OEM_8 = 0xDF, + /// The <> keys on the US standard keyboard, or the \\| key on the non-US 102-key keyboard + VK_OEM_102 = 0xE2, + /// IME PROCESS key + VK_PROCESSKEY = 0xE5, + /// Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP + VK_PACKET = 0xE7, + /// Attn key + VK_ATTN = 0xF6, + /// CrSel key + VK_CRSEL = 0xF7, + /// ExSel key + VK_EXSEL = 0xF8, + /// Erase EOF key + VK_EREOF = 0xF9, + /// Play key + VK_PLAY = 0xFA, + /// Zoom key + VK_ZOOM = 0xFB, + /// Reserved + VK_NONAME = 0xFC, + /// PA1 key + VK_PA1 = 0xFD, + /// Clear key + VK_OEM_CLEAR = 0xFE, } +# pragma warning restore CA1069 // Enums values should not be duplicated } \ No newline at end of file diff --git a/VolumeControl.Hotkeys/Interfaces/IActionBinding.cs b/VolumeControl.Hotkeys/Interfaces/IActionBinding.cs index 152255430..83c7e4b4e 100644 --- a/VolumeControl.Hotkeys/Interfaces/IActionBinding.cs +++ b/VolumeControl.Hotkeys/Interfaces/IActionBinding.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Reflection; namespace VolumeControl.Hotkeys.Interfaces { @@ -12,7 +13,7 @@ public interface IActionBinding /// string Name { get; } /// - /// This is the event handler for this action binding. It calls on the bound method. + /// This is the event handler for this action binding. It calls on the bound method. /// void HandleKeyEvent(object? sender, HandledEventArgs? e); } diff --git a/VolumeControl.Log/LogWriter.cs b/VolumeControl.Log/LogWriter.cs index ac7327378..62f3f8fb4 100644 --- a/VolumeControl.Log/LogWriter.cs +++ b/VolumeControl.Log/LogWriter.cs @@ -153,7 +153,7 @@ public void WriteWithTimestamp(string ts, params object?[] lines) if (line is null) continue; else if (line is Exception ex) - w.WriteLine($"{(i == 0 ? "" : tsBlank)}'Exception': {FormatExceptionMessage(ex, tsBlank)}"); + w.WriteLine($"{(i == 0 ? "" : tsBlank)}: {FormatExceptionMessage(ex, tsBlank)}"); else if (line is string s) { if (s.Length > 0) diff --git a/VolumeControl.Log/VolumeControl.Log.csproj b/VolumeControl.Log/VolumeControl.Log.csproj index 3627ee4fd..e2a86ce96 100644 --- a/VolumeControl.Log/VolumeControl.Log.csproj +++ b/VolumeControl.Log/VolumeControl.Log.csproj @@ -1,14 +1,14 @@ - - net6.0-windows - enable - enable - Library - True - Debug;Release;SDK - True - + + net6.0-windows + enable + enable + Library + True + Debug;Release;SDK + True + - - - True - True - Settings.settings - - + + + True + True + Settings.settings + + - - - PublicSettingsSingleFileGenerator - Settings.Designer.cs - - + + + PublicSettingsSingleFileGenerator + Settings.Designer.cs + + - - - + + + diff --git a/VolumeControl.TypeExtensions/ArrayExtensions.cs b/VolumeControl.TypeExtensions/ArrayExtensions.cs new file mode 100644 index 000000000..926ed4142 --- /dev/null +++ b/VolumeControl.TypeExtensions/ArrayExtensions.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +namespace VolumeControl.TypeExtensions +{ + /// Extensions for generic array types. + public static class ArrayExtensions + { + /// Performs the specified action on each element of the . + /// + public static T[] ForEach(this T[] array, Action action) + { + foreach (var item in array) + action(item); + return array; + } + /// Applies the specified function to each element of the . + /// + public static T[] ForEach(this T[] array, Func function) + { + for (int i = 0; i < array.Length; ++i) + array[i] = function(array[i]); + return array; + } + } +} diff --git a/VolumeControl.Core/Extensions/EnumExtensions.cs b/VolumeControl.TypeExtensions/EnumExtensions.cs similarity index 98% rename from VolumeControl.Core/Extensions/EnumExtensions.cs rename to VolumeControl.TypeExtensions/EnumExtensions.cs index a4fe7d729..427b5c785 100644 --- a/VolumeControl.Core/Extensions/EnumExtensions.cs +++ b/VolumeControl.TypeExtensions/EnumExtensions.cs @@ -1,4 +1,4 @@ -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Extensions for any type. diff --git a/VolumeControl.Core/Extensions/Int32Extensions.cs b/VolumeControl.TypeExtensions/Int32Extensions.cs similarity index 94% rename from VolumeControl.Core/Extensions/Int32Extensions.cs rename to VolumeControl.TypeExtensions/Int32Extensions.cs index a0a1fffa3..163c33278 100644 --- a/VolumeControl.Core/Extensions/Int32Extensions.cs +++ b/VolumeControl.TypeExtensions/Int32Extensions.cs @@ -1,4 +1,5 @@ -namespace VolumeControl.Core.Extensions +using VolumeControl.TypeExtensions; +namespace VolumeControl.TypeExtensions { /// /// Extensions for the integral type. diff --git a/VolumeControl.Core/Extensions/ListExtensions.cs b/VolumeControl.TypeExtensions/ListExtensions.cs similarity index 97% rename from VolumeControl.Core/Extensions/ListExtensions.cs rename to VolumeControl.TypeExtensions/ListExtensions.cs index ee70135e1..67da9f5c5 100644 --- a/VolumeControl.Core/Extensions/ListExtensions.cs +++ b/VolumeControl.TypeExtensions/ListExtensions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// Extensions for the generic object. public static class ListExtensions diff --git a/VolumeControl.Core/Extensions/MathExt.cs b/VolumeControl.TypeExtensions/MathExt.cs similarity index 99% rename from VolumeControl.Core/Extensions/MathExt.cs rename to VolumeControl.TypeExtensions/MathExt.cs index 2c7fc69ac..5b03eeea1 100644 --- a/VolumeControl.Core/Extensions/MathExt.cs +++ b/VolumeControl.TypeExtensions/MathExt.cs @@ -1,4 +1,4 @@ -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Methods for various mathematics operations not covered by diff --git a/VolumeControl.Core/Extensions/NullableBoolExtensions.cs b/VolumeControl.TypeExtensions/NullableBoolExtensions.cs similarity index 98% rename from VolumeControl.Core/Extensions/NullableBoolExtensions.cs rename to VolumeControl.TypeExtensions/NullableBoolExtensions.cs index fe4457074..89d121b30 100644 --- a/VolumeControl.Core/Extensions/NullableBoolExtensions.cs +++ b/VolumeControl.TypeExtensions/NullableBoolExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Extends nullable boolean and byte types with conversion methods. diff --git a/VolumeControl.Core/Extensions/ProcessExtensions.cs b/VolumeControl.TypeExtensions/ProcessExtensions.cs similarity index 99% rename from VolumeControl.Core/Extensions/ProcessExtensions.cs rename to VolumeControl.TypeExtensions/ProcessExtensions.cs index 028e7e2be..dd182701c 100644 --- a/VolumeControl.Core/Extensions/ProcessExtensions.cs +++ b/VolumeControl.TypeExtensions/ProcessExtensions.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Extension methods for the class. diff --git a/VolumeControl.Core/Extensions/RealNumberExtensions.cs b/VolumeControl.TypeExtensions/RealNumberExtensions.cs similarity index 97% rename from VolumeControl.Core/Extensions/RealNumberExtensions.cs rename to VolumeControl.TypeExtensions/RealNumberExtensions.cs index 20dfeccbd..d68c70d23 100644 --- a/VolumeControl.Core/Extensions/RealNumberExtensions.cs +++ b/VolumeControl.TypeExtensions/RealNumberExtensions.cs @@ -1,4 +1,4 @@ -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Extensions for floating-point number types. diff --git a/VolumeControl.Core/Extensions/StringExtensions.cs b/VolumeControl.TypeExtensions/StringExtensions.cs similarity index 97% rename from VolumeControl.Core/Extensions/StringExtensions.cs rename to VolumeControl.TypeExtensions/StringExtensions.cs index cef02bfc2..bfac1da01 100644 --- a/VolumeControl.Core/Extensions/StringExtensions.cs +++ b/VolumeControl.TypeExtensions/StringExtensions.cs @@ -1,6 +1,6 @@ using Semver; -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Extensions for string types. diff --git a/VolumeControl.Core/Extensions/TimerExtensions.cs b/VolumeControl.TypeExtensions/TimerExtensions.cs similarity index 96% rename from VolumeControl.Core/Extensions/TimerExtensions.cs rename to VolumeControl.TypeExtensions/TimerExtensions.cs index c99b82ea1..09650005a 100644 --- a/VolumeControl.Core/Extensions/TimerExtensions.cs +++ b/VolumeControl.TypeExtensions/TimerExtensions.cs @@ -1,4 +1,4 @@ -namespace VolumeControl.Core.Extensions +namespace VolumeControl.TypeExtensions { /// /// Extensions for the timer object. diff --git a/VolumeControl.TypeExtensions/VolumeControl.TypeExtensions.csproj b/VolumeControl.TypeExtensions/VolumeControl.TypeExtensions.csproj new file mode 100644 index 000000000..35870928a --- /dev/null +++ b/VolumeControl.TypeExtensions/VolumeControl.TypeExtensions.csproj @@ -0,0 +1,19 @@ + + + + net6.0-windows + enable + enable + true + True + + + + + + + + + + + diff --git a/VolumeControl.WPF/Bindings/MultiBinding.cs b/VolumeControl.WPF/Bindings/MultiBinding.cs index 1399f8fea..796eb7518 100644 --- a/VolumeControl.WPF/Bindings/MultiBinding.cs +++ b/VolumeControl.WPF/Bindings/MultiBinding.cs @@ -1,4 +1,5 @@ using System.Windows.Data; +using VolumeControl.TypeExtensions; namespace VolumeControl.WPF.Bindings { @@ -7,15 +8,13 @@ namespace VolumeControl.WPF.Bindings /// public class MultiBinding : System.Windows.Data.MultiBinding { + /// public MultiBinding() : base() { } - public MultiBinding(params BindingBase[] bindings) : base() - { - foreach (BindingBase b in bindings) - { - Bindings.Add(b); - } - } + /// + /// Any number of binding objects. + public MultiBinding(params BindingBase[] bindings) : base() => bindings.ForEach(b => Bindings.Add(b)); +# pragma warning disable CS1591 // Missing XML comment for publicly visible type or member // This is required because JESUS CHRIST MICROSOFT FIX YOUR FUCKING SHIT AND STOP MAKING EVERYTHING SO GODDAMN DIFFICULT FOR NO REASON: public MultiBinding(BindingBase b1) : this(new[] { b1 }) { } public MultiBinding(BindingBase b1, BindingBase b2) : this(new[] { b1, b2 }) { } @@ -27,5 +26,6 @@ public MultiBinding(BindingBase b1, BindingBase b2, BindingBase b3, BindingBase public MultiBinding(BindingBase b1, BindingBase b2, BindingBase b3, BindingBase b4, BindingBase b5, BindingBase b6, BindingBase b7, BindingBase b8) : this(new[] { b1, b2, b3, b4, b5, b6, b7, b8 }) { } public MultiBinding(BindingBase b1, BindingBase b2, BindingBase b3, BindingBase b4, BindingBase b5, BindingBase b6, BindingBase b7, BindingBase b8, BindingBase b9) : this(new[] { b1, b2, b3, b4, b5, b6, b7, b8, b9 }) { } public MultiBinding(BindingBase b1, BindingBase b2, BindingBase b3, BindingBase b4, BindingBase b5, BindingBase b6, BindingBase b7, BindingBase b8, BindingBase b9, BindingBase b10) : this(new[] { b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 }) { } +# pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } } diff --git a/VolumeControl.WPF/Collections/BindableEventType.cs b/VolumeControl.WPF/Collections/BindableEventType.cs index 6a835ff2b..61a09d6cf 100644 --- a/VolumeControl.WPF/Collections/BindableEventType.cs +++ b/VolumeControl.WPF/Collections/BindableEventType.cs @@ -5,6 +5,7 @@ using System.ComponentModel; using System.Runtime.CompilerServices; using VolumeControl.Log.Enum; +using VolumeControl.TypeExtensions; namespace VolumeControl.WPF.Collections { @@ -70,12 +71,14 @@ public BindableEventType() { _value = EventType.NONE; InitializeOptions(); + Options.CollectionChanged += ForwardCollectionChanged; } /// public BindableEventType(EventType ev) { _value = ev; InitializeOptions(); + Options.CollectionChanged += ForwardCollectionChanged; } #endregion Constructors @@ -83,13 +86,12 @@ public BindableEventType(EventType ev) /// Triggered when a property's setting is called, after the value has changed. public event PropertyChangedEventHandler? PropertyChanged; /// Triggered when the options list is changed. - public event NotifyCollectionChangedEventHandler? CollectionChanged - { - add => ((INotifyCollectionChanged)Options).CollectionChanged += value; - remove => ((INotifyCollectionChanged)Options).CollectionChanged -= value; - } + public event NotifyCollectionChangedEventHandler? CollectionChanged; /// Triggers the event. protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "") => PropertyChanged?.Invoke(this, new(propertyName)); + /// Triggers the event. + protected virtual void NotifyCollectionChanged(NotifyCollectionChangedEventArgs e) => CollectionChanged?.Invoke(this, e); + private void ForwardCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) => CollectionChanged?.Invoke(sender, e); #endregion Events #region Indexers @@ -115,6 +117,7 @@ public EventType Value { _value = value; NotifyPropertyChanged(); + NotifyCollectionChanged(new(NotifyCollectionChangedAction.Replace)); } } /// @@ -146,8 +149,13 @@ private void InitializeOptions() { foreach (EventType e in (EventType[])Enum.GetValues(typeof(EventType))) { - if (e != EventType.NONE && e != EventType.ALL && e != EventType.ALL_EXCEPT_DEBUG) - Options.Add(new(this, e)); + int eval = (int)e; + if (eval != 0 && eval % 2 == 0) + { + double exponent = Math.Log2(eval); + if (exponent.EqualsWithin((int)exponent)) + Options.Add(new(this, e)); + } } } /// diff --git a/VolumeControl.WPF/Collections/ObservableList.cs b/VolumeControl.WPF/Collections/ObservableList.cs index 6db70c10d..34685fd01 100644 --- a/VolumeControl.WPF/Collections/ObservableList.cs +++ b/VolumeControl.WPF/Collections/ObservableList.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Collections.ObjectModel; namespace VolumeControl.WPF.Collections @@ -19,5 +20,14 @@ public void AddRange(IEnumerable range) { foreach (T item in range) Add(item); } + /// + public void RemoveAll(Predicate predicate) + { + for (int i = this.Count - 1; i >= 0; --i) + { + if (predicate(this[i])) + this.RemoveAt(i); + } + } } } diff --git a/VolumeControl.WPF/Collections/ObservableListExtensions.cs b/VolumeControl.WPF/Collections/ObservableListExtensions.cs deleted file mode 100644 index 603da2ce5..000000000 --- a/VolumeControl.WPF/Collections/ObservableListExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace VolumeControl.WPF.Collections -{ - public static class ObservableListExtensions - { - public static void RemoveAll(this ObservableList collection, Predicate predicate) - { - for (int i = collection.Count - 1; i >= 0; --i) - { - if (predicate(collection[i])) - collection.RemoveAt(i); - } - } - } -} diff --git a/VolumeControl.WPF/Controls/NumericUpDown.cs b/VolumeControl.WPF/Controls/NumericUpDown.cs index 51c4eefb3..42abdcffb 100644 --- a/VolumeControl.WPF/Controls/NumericUpDown.cs +++ b/VolumeControl.WPF/Controls/NumericUpDown.cs @@ -12,6 +12,7 @@ namespace VolumeControl.WPF.Controls [TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))] [TemplatePart(Name = "PART_IncreaseButton", Type = typeof(RepeatButton))] [TemplatePart(Name = "PART_DecreaseButton", Type = typeof(RepeatButton))] +# pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public class NumericUpDown : Control { #region Properties @@ -445,9 +446,9 @@ public CornerRadius CornerRadius static NumericUpDown() => DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericUpDown), new FrameworkPropertyMetadata(typeof(NumericUpDown))); -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. +# pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public NumericUpDown() -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. +# pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. { Culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); @@ -684,4 +685,5 @@ private void DecreaseValue(bool minor) #endregion } +# pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } \ No newline at end of file diff --git a/VolumeControl.WPF/Converters/ConverterChain.cs b/VolumeControl.WPF/Converters/ConverterChain.cs index 6d7bce8b3..690e629a2 100644 --- a/VolumeControl.WPF/Converters/ConverterChain.cs +++ b/VolumeControl.WPF/Converters/ConverterChain.cs @@ -5,6 +5,9 @@ namespace VolumeControl.WPF.Converters { + /// + /// Any number of objects that are used in assembly-line fashion on a given value. + /// public class ConverterChain : List, IValueConverter { /// diff --git a/VolumeControl.WPF/Converters/MultiBindingBooleanConverter.cs b/VolumeControl.WPF/Converters/MultiBindingBooleanConverter.cs index 779b92fbb..32dbedf13 100644 --- a/VolumeControl.WPF/Converters/MultiBindingBooleanConverter.cs +++ b/VolumeControl.WPF/Converters/MultiBindingBooleanConverter.cs @@ -5,6 +5,10 @@ namespace VolumeControl.WPF.Converters { + /// + /// for multiple boolean inputs that accepts and returns a list of booleans.
+ /// Any non-boolean types are converted using . + ///
public class MultiBindingBooleanConverter : IMultiValueConverter { /// diff --git a/VolumeControl.WPF/Converters/NumericUpDownCornerRadiusConverter.cs b/VolumeControl.WPF/Converters/SquaredCornerRadiusConverter.cs similarity index 81% rename from VolumeControl.WPF/Converters/NumericUpDownCornerRadiusConverter.cs rename to VolumeControl.WPF/Converters/SquaredCornerRadiusConverter.cs index 6cd6fec6e..0d662b9d1 100644 --- a/VolumeControl.WPF/Converters/NumericUpDownCornerRadiusConverter.cs +++ b/VolumeControl.WPF/Converters/SquaredCornerRadiusConverter.cs @@ -19,15 +19,19 @@ public class SquaredCornerRadiusConverter : IValueConverter /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + Corner corners = Squared; + if (parameter is Corner c) + corners = c; + var cr = (CornerRadius)value; - if (Squared.HasFlag(Corner.TopLeft)) + if (corners.HasFlag(Corner.TopLeft)) cr.TopLeft = 0; - if (Squared.HasFlag(Corner.TopRight)) + if (corners.HasFlag(Corner.TopRight)) cr.TopRight = 0; - if (Squared.HasFlag(Corner.BottomLeft)) + if (corners.HasFlag(Corner.BottomLeft)) cr.BottomLeft = 0; - if (Squared.HasFlag(Corner.BottomRight)) + if (corners.HasFlag(Corner.BottomRight)) cr.BottomRight = 0; return cr; diff --git a/VolumeControl.WPF/Markup/ConvertExtension.cs b/VolumeControl.WPF/Markup/ConvertExtension.cs new file mode 100644 index 000000000..9904cea82 --- /dev/null +++ b/VolumeControl.WPF/Markup/ConvertExtension.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Markup; + +namespace VolumeControl.WPF.Markup +{ + /// + /// XAML Extension that adds the ability to use implementations without binding to an actual source. + /// + public class ConvertExtension : MarkupExtension + { + /// Constructs a new instance of + public ConvertExtension() + { + + } + + /// + public override object ProvideValue(IServiceProvider serviceProvider) => throw new NotImplementedException(); + } +} diff --git a/VolumeControl.WPF/PInvoke/MINMAXINFO.cs b/VolumeControl.WPF/PInvoke/MINMAXINFO.cs index d0c97ec10..66867ce73 100644 --- a/VolumeControl.WPF/PInvoke/MINMAXINFO.cs +++ b/VolumeControl.WPF/PInvoke/MINMAXINFO.cs @@ -3,6 +3,7 @@ namespace VolumeControl.WPF { [StructLayout(LayoutKind.Sequential)] +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public struct MINMAXINFO { public POINT ptReserved; @@ -11,4 +12,5 @@ public struct MINMAXINFO public POINT ptMinTrackSize; public POINT ptMaxTrackSize; }; +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } \ No newline at end of file diff --git a/VolumeControl.WPF/Themes/Generic.xaml b/VolumeControl.WPF/Themes/Generic.xaml index fcf8af9cc..bc25b16a0 100644 --- a/VolumeControl.WPF/Themes/Generic.xaml +++ b/VolumeControl.WPF/Themes/Generic.xaml @@ -22,11 +22,11 @@ Name="nudBorder" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" - Margin="0" - MinHeight="{TemplateBinding MinHeight}" MinWidth="{TemplateBinding MinWidth}" - MaxHeight="{TemplateBinding MaxHeight}" + MinHeight="{TemplateBinding MinHeight}" MaxWidth="{TemplateBinding MaxWidth}" + MaxHeight="{TemplateBinding MaxHeight}" + Margin="0" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" diff --git a/VolumeControl.WPF/VolumeControl.WPF.csproj b/VolumeControl.WPF/VolumeControl.WPF.csproj index 5275ef4b2..b71815867 100644 --- a/VolumeControl.WPF/VolumeControl.WPF.csproj +++ b/VolumeControl.WPF/VolumeControl.WPF.csproj @@ -10,13 +10,12 @@ - + + diff --git a/VolumeControl/App.xaml.cs b/VolumeControl/App.xaml.cs index 2e9c145bc..e320b3d25 100644 --- a/VolumeControl/App.xaml.cs +++ b/VolumeControl/App.xaml.cs @@ -17,6 +17,9 @@ public App() var assembly = Assembly.GetAssembly(typeof(Mixer)); string version = $"v{assembly?.GetCustomAttribute()?.Version}"; + // Add a log handler to the dispatcher's unhandled exception event + DispatcherUnhandledException += (s, e) => Log.Error($"An unhandled exception occurred!", $" Sender: '{s}' ({s.GetType()})", e.Exception); + // Tray icon TrayIcon = new($"Volume Control {version}", (s, e) => MainWindow.Visibility == Visibility.Visible); TrayIcon.Clicked += HandleTrayIconClick; @@ -24,8 +27,6 @@ public App() TrayIcon.HideClicked += (s, e) => HideMainWindow(); TrayIcon.BringToFrontClicked += (s, e) => ActivateMainWindow(); TrayIcon.CloseClicked += (s, e) => Shutdown(); - - DispatcherUnhandledException += (s, e) => Log.Error($"An unhandled exception occurred!", $" Sender: '{s}' ({s.GetType()})", e.Exception); } #endregion Constructors @@ -44,7 +45,6 @@ private void Application_Exit(object sender, ExitEventArgs e) // delete the tray icon TrayIcon.Dispose(); } - private void HideMainWindow() => MainWindow.Hide(); private void ShowMainWindow() { diff --git a/VolumeControl/Helpers/Update/Release.cs b/VolumeControl/Helpers/Update/Release.cs index 4fe786c11..7aa0b32de 100644 --- a/VolumeControl/Helpers/Update/Release.cs +++ b/VolumeControl/Helpers/Update/Release.cs @@ -3,7 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using VolumeControl.Core.Extensions; +using VolumeControl.TypeExtensions; namespace VolumeControl.Helpers.Update { diff --git a/VolumeControl/Helpers/VolumeControlSettings.cs b/VolumeControl/Helpers/VolumeControlSettings.cs index 76e10644b..fcdb07d55 100644 --- a/VolumeControl/Helpers/VolumeControlSettings.cs +++ b/VolumeControl/Helpers/VolumeControlSettings.cs @@ -11,7 +11,6 @@ using VolumeControl.Audio; using VolumeControl.Core; using VolumeControl.Core.Enum; -using VolumeControl.Core.Extensions; using VolumeControl.Core.Helpers; using VolumeControl.Helpers.Addon; using VolumeControl.Helpers.Update; @@ -19,6 +18,7 @@ using VolumeControl.Hotkeys.Addons; using VolumeControl.WPF; using static VolumeControl.Audio.AudioAPI; +using VolumeControl.TypeExtensions; namespace VolumeControl.Helpers { diff --git a/VolumeControl/ListNotification.xaml.cs b/VolumeControl/ListNotification.xaml.cs index f7e3efe6c..1a442fc82 100644 --- a/VolumeControl/ListNotification.xaml.cs +++ b/VolumeControl/ListNotification.xaml.cs @@ -1,10 +1,9 @@ using System; using System.ComponentModel; using System.Windows; -using System.Windows.Media; using VolumeControl.Core.Enum; -using VolumeControl.Core.Extensions; using VolumeControl.Helpers; +using VolumeControl.TypeExtensions; namespace VolumeControl { diff --git a/VolumeControl/Mixer.xaml b/VolumeControl/Mixer.xaml index 56c5a27c0..76e736439 100644 --- a/VolumeControl/Mixer.xaml +++ b/VolumeControl/Mixer.xaml @@ -43,6 +43,7 @@ + 22 @@ -60,6 +61,8 @@ LightGray #3d3d3d + + #1F1F1F WhiteSmoke @@ -70,8 +73,8 @@ #222 - #444 - #999 + #0000 + +