From f1b6601054ca22deb3b578ee4dec4010716aa167 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Fri, 15 May 2020 01:16:58 +0200 Subject: [PATCH] added ability to swap between audio devices --- FModel/Properties/Settings.Designer.cs | 12 ++++++++ FModel/Properties/Settings.settings | 3 ++ FModel/Utils/Keys.cs | 4 +-- .../SoundPlayer/InputFileViewModel.cs | 9 +++--- FModel/Windows/SoundPlayer/AudioPlayer.xaml | 4 +-- .../Windows/SoundPlayer/AudioPlayer.xaml.cs | 21 +++++++++++++- .../SoundPlayer/Visualization/OutputSource.cs | 29 +++++++++++++++++++ 7 files changed, 73 insertions(+), 9 deletions(-) diff --git a/FModel/Properties/Settings.Designer.cs b/FModel/Properties/Settings.Designer.cs index 0ea03269..cbb88ac6 100644 --- a/FModel/Properties/Settings.Designer.cs +++ b/FModel/Properties/Settings.Designer.cs @@ -83,6 +83,18 @@ namespace FModel.Properties { } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string AudioPlayerDevice { + get { + return ((string)(this["AudioPlayerDevice"])); + } + set { + this["AudioPlayerDevice"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("")] diff --git a/FModel/Properties/Settings.settings b/FModel/Properties/Settings.settings index 50f224ed..770e014e 100644 --- a/FModel/Properties/Settings.settings +++ b/FModel/Properties/Settings.settings @@ -17,6 +17,9 @@ True + + + diff --git a/FModel/Utils/Keys.cs b/FModel/Utils/Keys.cs index 69872aec..2910a99d 100644 --- a/FModel/Utils/Keys.cs +++ b/FModel/Utils/Keys.cs @@ -52,7 +52,7 @@ namespace FModel.Utils { // i can use TestAesKey here but that means it's gonna test here then right after to set the key // so a try catch when setting the key seems better - menuItem.PakFile.AesKey = sKey.ToBytesKey(); + menuItem.PakFile.AesKey = sKey.Trim().ToBytesKey(); } catch (System.Exception e) { @@ -72,7 +72,7 @@ namespace FModel.Utils { // i can use TestAesKey here but that means it's gonna test here then right after to set the key // so a try catch when setting the key seems better - menuItem.PakFile.AesKey = dKey.ToBytesKey(); + menuItem.PakFile.AesKey = dKey.Trim().ToBytesKey(); } catch (System.Exception e) { diff --git a/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs b/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs index ea7ffa41..2213e7ac 100644 --- a/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs +++ b/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs @@ -1,4 +1,5 @@ using FModel.Windows.SoundPlayer.Visualization; +using System.Collections.ObjectModel; using System.Windows; namespace FModel.ViewModels.SoundPlayer @@ -32,18 +33,18 @@ namespace FModel.ViewModels.SoundPlayer public class InputFileViewModel : PropertyChangedBase { - private Device _device = Device.GetDefaultDevice(); + private ObservableCollection _devices = new ObservableCollection(Device.GetOutputDevices()); private bool _isEnabled = true; private string _content; private string _bytes; private string _duration; private float _volume = 0.5f; - public Device Device + public ObservableCollection Devices { - get { return _device; } + get { return _devices; } - set { this.SetProperty(ref this._device, value); } + set { this.SetProperty(ref this._devices, value); } } public bool IsEnabled { diff --git a/FModel/Windows/SoundPlayer/AudioPlayer.xaml b/FModel/Windows/SoundPlayer/AudioPlayer.xaml index 4b05994c..0f8f8148 100644 --- a/FModel/Windows/SoundPlayer/AudioPlayer.xaml +++ b/FModel/Windows/SoundPlayer/AudioPlayer.xaml @@ -81,8 +81,8 @@