From cb2c612e81362ac41190b3aad2717c15435be1f2 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 10:56:19 -0400 Subject: [PATCH 01/15] refactor(Profile::Trigger): Reformat the code --- .../Profile/Trigger/TriggerFactory.cs | 80 +++++++++---------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs index 9a21ab7a89..dfda14851f 100644 --- a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs +++ b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs @@ -1,8 +1,5 @@ -using System; -using System.Windows.Forms; -using SoundSwitch.Framework.Factory; +using SoundSwitch.Framework.Factory; using SoundSwitch.Localization; -using SoundSwitch.Util; namespace SoundSwitch.Framework.Profile.Trigger { @@ -15,7 +12,8 @@ public enum Enum Process, Steam, Startup, - UwpApp + UwpApp, + TrayMenu } private static readonly IEnumImplList Impl = @@ -66,68 +64,68 @@ public override string ToString() return Label; } - public virtual TriggerFactory.Enum TypeEnum { get; } - public virtual string Label { get; } - public virtual int MaxOccurence { get; } = -1; - public virtual int MaxGlobalOccurence { get; } = -1; - public abstract string Description { get; } - public virtual bool CanRestoreDevices { get; } = false; - public virtual bool AlwaysDefaultAndRestoreDevice { get; } = false; + public virtual TriggerFactory.Enum TypeEnum { get; } + public virtual string Label { get; } + public virtual int MaxOccurence => -1; + public virtual int MaxGlobalOccurence => -1; + public abstract string Description { get; } + public virtual bool CanRestoreDevices => false; + public virtual bool AlwaysDefaultAndRestoreDevice => false; } public class HotKeyTrigger : BaseTrigger { - public override TriggerFactory.Enum TypeEnum { get; } = TriggerFactory.Enum.HotKey; - public override string Label => SettingsStrings.hotkeys; - public override string Description { get; } = SettingsStrings.profile_trigger_hotkey_desc; - public override int MaxOccurence { get; } = 1; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.HotKey; + public override string Label => SettingsStrings.hotkeys; + public override string Description { get; } = SettingsStrings.profile_trigger_hotkey_desc; + public override int MaxOccurence => 1; } public class WindowTrigger : BaseTrigger { - public override TriggerFactory.Enum TypeEnum { get; } = TriggerFactory.Enum.Window; - public override string Label => SettingsStrings.profile_trigger_window; - public override string Description { get; } = SettingsStrings.profile_trigger_window_desc; - public override bool CanRestoreDevices { get; } = true; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.Window; + public override string Label => SettingsStrings.profile_trigger_window; + public override string Description { get; } = SettingsStrings.profile_trigger_window_desc; + public override bool CanRestoreDevices => true; } public class ProcessTrigger : BaseTrigger { - public override TriggerFactory.Enum TypeEnum { get; } = TriggerFactory.Enum.Process; - public override string Label => SettingsStrings.profile_trigger_process; - public override string Description { get; } = SettingsStrings.profile_trigger_process_desc; - public override bool CanRestoreDevices { get; } = true; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.Process; + public override string Label => SettingsStrings.profile_trigger_process; + public override string Description { get; } = SettingsStrings.profile_trigger_process_desc; + public override bool CanRestoreDevices => true; } public class SteamBigPictureTrigger : BaseTrigger { - public override TriggerFactory.Enum TypeEnum { get; } = TriggerFactory.Enum.Steam; - public override string Label => SettingsStrings.profile_trigger_steam; - - public override int MaxOccurence { get; } = 1; - public override int MaxGlobalOccurence { get; } = 1; - public override string Description { get; } = SettingsStrings.profile_trigger_steam_desc; - public override bool CanRestoreDevices { get; } = true; - public override bool AlwaysDefaultAndRestoreDevice { get; } = true; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.Steam; + public override string Label => SettingsStrings.profile_trigger_steam; + + public override int MaxOccurence => 1; + public override int MaxGlobalOccurence => 1; + public override string Description { get; } = SettingsStrings.profile_trigger_steam_desc; + public override bool CanRestoreDevices => true; + public override bool AlwaysDefaultAndRestoreDevice => true; } public class Startup : BaseTrigger { - public override TriggerFactory.Enum TypeEnum { get; } = TriggerFactory.Enum.Startup; - public override string Label => SettingsStrings.profile_trigger_startup; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.Startup; + public override string Label => SettingsStrings.profile_trigger_startup; - public override int MaxOccurence { get; } = 1; - public override int MaxGlobalOccurence { get; } = 1; + public override int MaxOccurence => 1; + public override int MaxGlobalOccurence => 1; public override string Description { get; } = SettingsStrings.profile_trigger_startup_desc; } public class UwpApp : BaseTrigger { - public override TriggerFactory.Enum TypeEnum { get; } = TriggerFactory.Enum.UwpApp; - public override string Label => SettingsStrings.profile_trigger_uwp; - public override bool CanRestoreDevices { get; } = true; - public override string Description => SettingsStrings.profile_trigger_uwp_desc; - public override bool AlwaysDefaultAndRestoreDevice { get; } = true; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.UwpApp; + public override string Label => SettingsStrings.profile_trigger_uwp; + public override bool CanRestoreDevices => true; + public override string Description => SettingsStrings.profile_trigger_uwp_desc; + public override bool AlwaysDefaultAndRestoreDevice => true; } } \ No newline at end of file From 4ecd0fa2003d391b7fa75b30aea4ef844765a14a Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 11:00:40 -0400 Subject: [PATCH 02/15] refactor(Profile::Trigger): Add localization to new trigger --- .../Profile/Trigger/TriggerFactory.cs | 4 ++++ .../Localization/SettingsStrings.Designer.cs | 18 ++++++++++++++++++ .../Localization/SettingsStrings.fr.resx | 6 ++++++ SoundSwitch/Localization/SettingsStrings.resx | 6 ++++++ 4 files changed, 34 insertions(+) diff --git a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs index dfda14851f..8aa74b4400 100644 --- a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs +++ b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs @@ -128,4 +128,8 @@ public class UwpApp : BaseTrigger public override string Description => SettingsStrings.profile_trigger_uwp_desc; public override bool AlwaysDefaultAndRestoreDevice => true; } + public class TrayMenu : BaseTrigger + { + public override string Description { get; } + } } \ No newline at end of file diff --git a/SoundSwitch/Localization/SettingsStrings.Designer.cs b/SoundSwitch/Localization/SettingsStrings.Designer.cs index 932654644b..68d9569e46 100644 --- a/SoundSwitch/Localization/SettingsStrings.Designer.cs +++ b/SoundSwitch/Localization/SettingsStrings.Designer.cs @@ -837,6 +837,24 @@ internal static string profile_trigger_steam_desc { } } + /// + /// Looks up a localized string similar to In the app menu. + /// + internal static string profile_trigger_trayMenu { + get { + return ResourceManager.GetString("profile.trigger.trayMenu", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This trigger make the profile visible in the tray icon menu. Left-click on the systray icon to see your profile.. + /// + internal static string profile_trigger_trayMenu_desc { + get { + return ResourceManager.GetString("profile.trigger.trayMenu.desc", resourceCulture); + } + } + /// /// Looks up a localized string similar to Microsoft Store app. /// diff --git a/SoundSwitch/Localization/SettingsStrings.fr.resx b/SoundSwitch/Localization/SettingsStrings.fr.resx index 796d0d0ffb..b4f9cbe13c 100644 --- a/SoundSwitch/Localization/SettingsStrings.fr.resx +++ b/SoundSwitch/Localization/SettingsStrings.fr.resx @@ -439,4 +439,10 @@ Restaurer l'état du système quand l'application est fermée. Sourdine + + Menu de l'application + + + Le profile sera visible dans le menu de l'application. Cliquer avec le bouton gauche sur l'icone de l'application. + \ No newline at end of file diff --git a/SoundSwitch/Localization/SettingsStrings.resx b/SoundSwitch/Localization/SettingsStrings.resx index 333e5ca78d..4387dee91a 100644 --- a/SoundSwitch/Localization/SettingsStrings.resx +++ b/SoundSwitch/Localization/SettingsStrings.resx @@ -459,4 +459,10 @@ Restore the state of the system when the application is closed. Toggle mute + + In the app menu + + + This trigger make the profile visible in the tray icon menu. Left-click on the systray icon to see your profile. + \ No newline at end of file From 7d4e3d00f8d2ba7417c6fe1cddd800a71d84af10 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 11:02:12 -0400 Subject: [PATCH 03/15] boost(Profile::Trigger): Add new TrayMenu trigger to available triggers --- SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs index 8aa74b4400..5fecbb2e6c 100644 --- a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs +++ b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs @@ -24,7 +24,8 @@ public enum Enum new WindowTrigger(), new SteamBigPictureTrigger(), new Startup(), - new UwpApp() + new UwpApp(), + new TrayMenu() }; public TriggerFactory() : base(Impl) @@ -128,8 +129,11 @@ public class UwpApp : BaseTrigger public override string Description => SettingsStrings.profile_trigger_uwp_desc; public override bool AlwaysDefaultAndRestoreDevice => true; } + public class TrayMenu : BaseTrigger { - public override string Description { get; } + public override string Description => SettingsStrings.profile_trigger_trayMenu_desc; + public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.TrayMenu; + public override string Label => SettingsStrings.profile_trigger_trayMenu; } } \ No newline at end of file From 156cea959f1c92216677013c45779d18f3b14b88 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 11:06:54 -0400 Subject: [PATCH 04/15] refactor(Profile::Trigger): Improve the Switch & Match code for Trigger type --- .../Profile/Trigger/TriggerEnumExtensions.cs | 59 ++++--------------- 1 file changed, 12 insertions(+), 47 deletions(-) diff --git a/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs b/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs index 93bf908bdb..8438f3c416 100644 --- a/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs +++ b/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs @@ -7,64 +7,29 @@ public static class TriggerEnumExtensions /// /// Switch on the given enum /// - /// - /// - /// - /// - /// - /// - /// /// - public static void Switch(this TriggerFactory.Enum @enum, Action hotkey, Action window, Action process, Action steam, Action startup, Action uwpApp) + public static void Switch(this TriggerFactory.Enum @enum, Action hotkey, Action window, Action process, Action steam, Action startup, Action uwpApp, Action trayMenu) { - switch (@enum) - { - case TriggerFactory.Enum.HotKey: - hotkey(); - break; - case TriggerFactory.Enum.Window: - window(); - break; - case TriggerFactory.Enum.Process: - process(); - break; - case TriggerFactory.Enum.Steam: - steam(); - break; - case TriggerFactory.Enum.Startup: - startup(); - break; - case TriggerFactory.Enum.UwpApp: - uwpApp(); - break; - default: - throw new ArgumentOutOfRangeException(nameof(@enum), @enum, null); - } + Match(@enum, () => hotkey, () => window, () => process, () => steam, () => startup, () => uwpApp, () => trayMenu); } /// /// Match on the enum /// - /// - /// - /// - /// - /// - /// - /// - /// /// - public static T Match(this TriggerFactory.Enum @enum, Func hotkey, Func window, Func process, Func steam, Func startup, Func uwpApp) + /// + public static T Match(this TriggerFactory.Enum @enum, Func hotkey, Func window, Func process, Func steam, Func startup, Func uwpApp, Func trayMenu) { return @enum switch { - TriggerFactory.Enum.HotKey => hotkey(), - TriggerFactory.Enum.Window => window(), - TriggerFactory.Enum.Process => process(), - TriggerFactory.Enum.Steam => steam(), - TriggerFactory.Enum.Startup => startup(), - TriggerFactory.Enum.UwpApp => uwpApp(), - _ => throw new ArgumentOutOfRangeException(nameof(@enum), @enum, null) + TriggerFactory.Enum.HotKey => hotkey(), + TriggerFactory.Enum.Window => window(), + TriggerFactory.Enum.Process => process(), + TriggerFactory.Enum.Steam => steam(), + TriggerFactory.Enum.Startup => startup(), + TriggerFactory.Enum.UwpApp => uwpApp(), + TriggerFactory.Enum.TrayMenu => trayMenu(), + _ => throw new ArgumentOutOfRangeException(nameof(@enum), @enum, null) }; } } From 1041452d0ae1802261bf200eec7e77bdaea49ece Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 11:08:25 -0400 Subject: [PATCH 05/15] refactor(Profile::Trigger): Add action for TrayIcon Basically do nothing for now --- .../Framework/Profile/ProfileManager.cs | 8 ++- SoundSwitch/UI/Forms/UpsertProfileExtended.cs | 59 +++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/SoundSwitch/Framework/Profile/ProfileManager.cs b/SoundSwitch/Framework/Profile/ProfileManager.cs index ca7c3dc8d0..e04bc9b6a5 100644 --- a/SoundSwitch/Framework/Profile/ProfileManager.cs +++ b/SoundSwitch/Framework/Profile/ProfileManager.cs @@ -76,7 +76,8 @@ private void RegisterTriggers(Profile profile, bool onInit = false) } SwitchAudio(profile); - }, () => { _profilesByUwpApp.Add(trigger.WindowName.ToLower(), (profile, trigger)); }); + }, () => { _profilesByUwpApp.Add(trigger.WindowName.ToLower(), (profile, trigger)); }, + () => {}); } } @@ -92,7 +93,8 @@ private void UnRegisterTriggers(Profile profile) () => { _profilesByWindowName.Remove(trigger.WindowName.ToLower()); }, () => { _profileByApplication.Remove(trigger.ApplicationPath.ToLower()); }, () => { _steamProfile = null; }, () => { }, - () => { _profilesByUwpApp.Remove(trigger.WindowName.ToLower()); }); + () => { _profilesByUwpApp.Remove(trigger.WindowName.ToLower()); }, + () => {}); } } @@ -425,7 +427,7 @@ private Result ValidateProfile(Profile profile) } return null; - }); + }, () => null); if (error != null) { return error; diff --git a/SoundSwitch/UI/Forms/UpsertProfileExtended.cs b/SoundSwitch/UI/Forms/UpsertProfileExtended.cs index 88de07938e..05a2a2181c 100644 --- a/SoundSwitch/UI/Forms/UpsertProfileExtended.cs +++ b/SoundSwitch/UI/Forms/UpsertProfileExtended.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using System.Windows.Forms; using RailSharp; -using Serilog.Formatting.Compact; using SoundSwitch.Common.Framework.Audio.Device; using SoundSwitch.Framework.Profile; using SoundSwitch.Framework.Profile.Trigger; @@ -17,19 +15,19 @@ namespace SoundSwitch.UI.Forms { public partial class UpsertProfileExtended : Form { - private readonly Profile _profile; - private readonly Profile _oldProfile; - private readonly SettingsForm _settingsForm; - private readonly bool _editing; + private readonly Profile _profile; + private readonly Profile _oldProfile; + private readonly SettingsForm _settingsForm; + private readonly bool _editing; private readonly TriggerFactory _triggerFactory; - private ToolTip _restoreDeviceToolTip; + private ToolTip _restoreDeviceToolTip; public UpsertProfileExtended(Profile profile, IEnumerable playbacks, IEnumerable recordings, SettingsForm settingsForm, bool editing = false) { - _oldProfile = editing ? profile : null; - _profile = editing ? profile.Copy() : profile; - _settingsForm = settingsForm; - _editing = editing; + _oldProfile = editing ? profile : null; + _profile = editing ? profile.Copy() : profile; + _settingsForm = settingsForm; + _editing = editing; _triggerFactory = new TriggerFactory(); InitializeComponent(); @@ -75,7 +73,7 @@ private void InitRecordingPlaybackComboBoxes(IEnumerable playbac .Select(info => new IconTextComboBox.DropDownItem { Icon = info.SmallIcon, - Tag = info, + Tag = info, Text = info.NameClean } ).ToArray(); @@ -87,12 +85,12 @@ private void InitRecordingPlaybackComboBoxes(IEnumerable playbac .Select(info => new IconTextComboBox.DropDownItem { Icon = info.SmallIcon, - Tag = info, + Tag = info, Text = info.NameClean } ).ToArray(); communicationComboBox.DataSource = playbackItems; - playbackComboBox.DataSource = playbackItems.ToArray(); + playbackComboBox.DataSource = playbackItems.ToArray(); communicationComboBox.DataBindings.Add(nameof(ComboBox.SelectedValue), _profile, nameof(Profile.Communication), false, DataSourceUpdateMode.OnPropertyChanged); recordingComboBox.DataBindings.Add(nameof(ComboBox.SelectedValue), _profile, nameof(Profile.Recording), false, DataSourceUpdateMode.OnPropertyChanged); @@ -101,26 +99,26 @@ private void InitRecordingPlaybackComboBoxes(IEnumerable playbac private void LocalizeForm() { - descriptionBox.Text = SettingsStrings.profile_desc; + descriptionBox.Text = SettingsStrings.profile_desc; availableTriggersText.Text = SettingsStrings.profile_trigger_available; - activeTriggerLabel.Text = SettingsStrings.profile_trigger_actives; - - recordingLabel.Text = SettingsStrings.recording; - playbackLabel.Text = SettingsStrings.playback; - communicationLabel.Text = SettingsStrings.communication; - Text = SettingsStrings.profile_feature_add; - selectProgramDialog.Filter = $@"{SettingsStrings.profile_feature_executable}|*.exe"; - nameLabel.Text = SettingsStrings.profile_name; - notifyCheckbox.Text = SettingsStrings.profile_notify_on_activation; - switchDefaultCheckBox.Text = SettingsStrings.profile_defaultDevice_checkbox; - saveButton.Text = SettingsStrings.profile_button_save; + activeTriggerLabel.Text = SettingsStrings.profile_trigger_actives; + + recordingLabel.Text = SettingsStrings.recording; + playbackLabel.Text = SettingsStrings.playback; + communicationLabel.Text = SettingsStrings.communication; + Text = SettingsStrings.profile_feature_add; + selectProgramDialog.Filter = $@"{SettingsStrings.profile_feature_executable}|*.exe"; + nameLabel.Text = SettingsStrings.profile_name; + notifyCheckbox.Text = SettingsStrings.profile_notify_on_activation; + switchDefaultCheckBox.Text = SettingsStrings.profile_defaultDevice_checkbox; + saveButton.Text = SettingsStrings.profile_button_save; restoreDevicesCheckBox.Text = SettingsStrings.profile_trigger_restoreDevices; new ToolTip().SetToolTip(switchDefaultCheckBox, SettingsStrings.profile_defaultDevice_checkbox_tooltip); _restoreDeviceToolTip = new ToolTip(); _restoreDeviceToolTip.SetToolTip( - restoreDevicesCheckBox, + restoreDevicesCheckBox, string.Format(SettingsStrings.profile_trigger_restoreDevices_desc, SettingsStrings.profile_defaultDevice_checkbox) ); } @@ -179,10 +177,10 @@ private void setTriggerBox_SelectedIndexChanged(object sender, EventArgs e) HideTriggerComponents(); - var trigger = (Trigger) setTriggerBox.SelectedItem; + var trigger = (Trigger) setTriggerBox.SelectedItem; var triggerDefinition = _triggerFactory.Get(trigger.Type); descriptionLabel.Text = $@"{triggerDefinition.Description} (Max: {(triggerDefinition.MaxGlobalOccurence == -1 ? "∞" : triggerDefinition.MaxGlobalOccurence.ToString())})"; - triggerLabel.Text = triggerDefinition.Label; + triggerLabel.Text = triggerDefinition.Label; descriptionLabel.Show(); triggerLabel.Show(); @@ -213,7 +211,8 @@ private void setTriggerBox_SelectedIndexChanged(object sender, EventArgs e) textInput.DataBindings.Clear(); textInput.DataBindings.Add(nameof(TextBox.Text), trigger, nameof(Trigger.WindowName), true, DataSourceUpdateMode.OnPropertyChanged); textInput.Show(); - }); + }, + () => { }); } private void HideTriggerComponents() From c98bb1dcd1e0ed638bc06828108ad4d073c8b52b Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 11:13:05 -0400 Subject: [PATCH 06/15] refactor(Profile::Trigger): TrayMenu only once per profile --- SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs index 5fecbb2e6c..d110159dc5 100644 --- a/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs +++ b/SoundSwitch/Framework/Profile/Trigger/TriggerFactory.cs @@ -135,5 +135,6 @@ public class TrayMenu : BaseTrigger public override string Description => SettingsStrings.profile_trigger_trayMenu_desc; public override TriggerFactory.Enum TypeEnum => TriggerFactory.Enum.TrayMenu; public override string Label => SettingsStrings.profile_trigger_trayMenu; + public override int MaxOccurence => 1; } } \ No newline at end of file From e3ac0898ba18d5a8a26c2261b51f45385cb0ab6a Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 11:37:26 -0400 Subject: [PATCH 07/15] refactor(Profile::Trigger): Add builder for the tray icon menu --- .../Framework/Profile/ProfileManager.cs | 2 +- .../Profile/UI/ProfileToolStripMenuItem.cs | 32 +++++++++ .../Profile/UI/ProfileTrayIconBuilder.cs | 66 +++++++++++++++++++ SoundSwitch/SoundSwitch.csproj | 3 + 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs create mode 100644 SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs diff --git a/SoundSwitch/Framework/Profile/ProfileManager.cs b/SoundSwitch/Framework/Profile/ProfileManager.cs index e04bc9b6a5..7aae8f50fd 100644 --- a/SoundSwitch/Framework/Profile/ProfileManager.cs +++ b/SoundSwitch/Framework/Profile/ProfileManager.cs @@ -294,7 +294,7 @@ private void SwitchAudio(Profile profile, uint processId) } - private void SwitchAudio(Profile profile) + public void SwitchAudio(Profile profile) { _notificationManager.NotifyProfileChanged(profile, null); foreach (var device in profile.Devices) diff --git a/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs b/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs new file mode 100644 index 0000000000..dfd7bea1a1 --- /dev/null +++ b/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs @@ -0,0 +1,32 @@ +/******************************************************************** +* Copyright (C) 2015 Jeroen Pelgrims +* Copyright (C) 2015-2017 Antoine Aflalo +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +********************************************************************/ + +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace SoundSwitch.Framework.Profile.UI +{ + internal class ProfileToolStripMenuItem : ToolStripMenuItem + { + public Profile Profile { get; } + + public ProfileToolStripMenuItem(Profile profile, Image image, Action onClick) + : base(profile.Name, image, (_, _) => onClick(profile)) + { + Profile = profile; + } + } +} \ No newline at end of file diff --git a/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs b/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs new file mode 100644 index 0000000000..ae40c403e8 --- /dev/null +++ b/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using SoundSwitch.Common.Framework.Icon; +using SoundSwitch.Framework.Profile.Trigger; +using SoundSwitch.Model; + +namespace SoundSwitch.Framework.Profile.UI +{ + public class ProfileTrayIconBuilder + { + private readonly IAudioDeviceLister _audioDeviceLister; + private readonly ProfileManager _profileManager; + + public ProfileTrayIconBuilder(IAudioDeviceLister audioDeviceLister, ProfileManager profileManager) + { + _audioDeviceLister = audioDeviceLister; + _profileManager = profileManager; + } + + /// + /// Get the menu items for profile that needs to be shown in the menu + /// + /// + public IEnumerable GetMenuItems() + { + return _profileManager.Profiles + .Where(profile => profile.Triggers.Any(trigger => trigger.Type == TriggerFactory.Enum.TrayMenu)) + .Select(BuildMenuItem); + } + + private ProfileToolStripMenuItem BuildMenuItem(Profile profile) + { + Image image = null; + try + { + var appTrigger = profile.Triggers.FirstOrDefault(trigger => trigger.ApplicationPath != null); + if (appTrigger != null) + { + image = IconExtractor.Extract(appTrigger.ApplicationPath, 0, false).ToBitmap(); + } + } + catch (Exception) + { + // ignored + } + + if (image == null) + { + try + { + var playback = _audioDeviceLister.PlaybackDevices.FirstOrDefault(info => info.Equals(profile.Playback)); + image = playback?.SmallIcon.ToBitmap(); + } + catch (Exception) + { + // ignored + } + } + + return new ProfileToolStripMenuItem(profile, image, profileClicked => _profileManager.SwitchAudio(profileClicked)); + } + } +} \ No newline at end of file diff --git a/SoundSwitch/SoundSwitch.csproj b/SoundSwitch/SoundSwitch.csproj index fc33f17cf2..69514c6fe9 100644 --- a/SoundSwitch/SoundSwitch.csproj +++ b/SoundSwitch/SoundSwitch.csproj @@ -87,6 +87,9 @@ + + Component + From 4b75a25f91220cdc8d037cae5b251fb5d2664729 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 12:36:20 -0400 Subject: [PATCH 08/15] fix(Profile::Trigger): Fix not calling the method in switch --- SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs b/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs index 8438f3c416..0c55df78a7 100644 --- a/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs +++ b/SoundSwitch/Framework/Profile/Trigger/TriggerEnumExtensions.cs @@ -10,7 +10,7 @@ public static class TriggerEnumExtensions /// public static void Switch(this TriggerFactory.Enum @enum, Action hotkey, Action window, Action process, Action steam, Action startup, Action uwpApp, Action trayMenu) { - Match(@enum, () => hotkey, () => window, () => process, () => steam, () => startup, () => uwpApp, () => trayMenu); + Match(@enum, () => hotkey, () => window, () => process, () => steam, () => startup, () => uwpApp, () => trayMenu)(); } /// From 4a43fa5d66406dfb6120c57ef4ef3728885a43b0 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:09:17 -0400 Subject: [PATCH 09/15] feat(Profile::Trigger::TrayIcon): Add tray icon as trigger The profile will be displayed in the toolstrip when left-clicking on the SoundSwitch tray icon. See #492 --- .../Profile/UI/ProfileTrayIconBuilder.cs | 26 +++++++++--------- SoundSwitch/UI/Component/TrayIcon.cs | 27 ++++++++++++++----- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs b/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs index ae40c403e8..8202bc15f7 100644 --- a/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs +++ b/SoundSwitch/Framework/Profile/UI/ProfileTrayIconBuilder.cs @@ -11,14 +11,9 @@ namespace SoundSwitch.Framework.Profile.UI { public class ProfileTrayIconBuilder { - private readonly IAudioDeviceLister _audioDeviceLister; - private readonly ProfileManager _profileManager; + private ProfileManager ProfileManager => AppModel.Instance.ProfileManager; - public ProfileTrayIconBuilder(IAudioDeviceLister audioDeviceLister, ProfileManager profileManager) - { - _audioDeviceLister = audioDeviceLister; - _profileManager = profileManager; - } + private IAudioDeviceLister AudioDeviceLister => AppModel.Instance.ActiveAudioDeviceLister; /// /// Get the menu items for profile that needs to be shown in the menu @@ -26,9 +21,9 @@ public ProfileTrayIconBuilder(IAudioDeviceLister audioDeviceLister, ProfileManag /// public IEnumerable GetMenuItems() { - return _profileManager.Profiles - .Where(profile => profile.Triggers.Any(trigger => trigger.Type == TriggerFactory.Enum.TrayMenu)) - .Select(BuildMenuItem); + return ProfileManager.Profiles + .Where(profile => profile.Triggers.Any(trigger => trigger.Type == TriggerFactory.Enum.TrayMenu)) + .Select(BuildMenuItem); } private ProfileToolStripMenuItem BuildMenuItem(Profile profile) @@ -47,12 +42,15 @@ private ProfileToolStripMenuItem BuildMenuItem(Profile profile) // ignored } - if (image == null) + foreach (var wrapper in profile.Devices) { + if (image != null) + break; + try { - var playback = _audioDeviceLister.PlaybackDevices.FirstOrDefault(info => info.Equals(profile.Playback)); - image = playback?.SmallIcon.ToBitmap(); + var device = AudioDeviceLister.PlaybackDevices.FirstOrDefault(info => info.Equals(wrapper.DeviceInfo)); + image = device?.SmallIcon.ToBitmap(); } catch (Exception) { @@ -60,7 +58,7 @@ private ProfileToolStripMenuItem BuildMenuItem(Profile profile) } } - return new ProfileToolStripMenuItem(profile, image, profileClicked => _profileManager.SwitchAudio(profileClicked)); + return new ProfileToolStripMenuItem(profile, image, profileClicked => ProfileManager.SwitchAudio(profileClicked)); } } } \ No newline at end of file diff --git a/SoundSwitch/UI/Component/TrayIcon.cs b/SoundSwitch/UI/Component/TrayIcon.cs index 9eda2baba5..2f7f711a43 100644 --- a/SoundSwitch/UI/Component/TrayIcon.cs +++ b/SoundSwitch/UI/Component/TrayIcon.cs @@ -17,6 +17,7 @@ using System.Diagnostics; using System.Drawing; using System.IO; +using System.Linq; using System.Reflection; using System.Threading; using System.Windows.Forms; @@ -25,6 +26,7 @@ using SoundSwitch.Common.Framework.Audio.Device; using SoundSwitch.Framework; using SoundSwitch.Framework.Configuration; +using SoundSwitch.Framework.Profile.UI; using SoundSwitch.Framework.TrayIcon.Icon; using SoundSwitch.Framework.TrayIcon.TooltipInfoManager; using SoundSwitch.Framework.Updater; @@ -52,19 +54,20 @@ public sealed class TrayIcon : IDisposable private static readonly Icon SoundSwitchLogoIcon = Resources.Switch_SoundWave; private static readonly Icon ResourceDiscord = Resources.DiscordIcon; - private readonly ContextMenuStrip _selectionMenu = new ContextMenuStrip(); - private readonly ContextMenuStrip _settingsMenu = new ContextMenuStrip(); + private readonly ContextMenuStrip _selectionMenu = new(); + private readonly ContextMenuStrip _settingsMenu = new(); private readonly SynchronizationContext _context = SynchronizationContext.Current ?? new SynchronizationContext(); - public NotifyIcon NotifyIcon { get; } = new NotifyIcon + public NotifyIcon NotifyIcon { get; } = new() { Visible = true, Text = Application.ProductName }; private readonly TooltipInfoManager _tooltipInfoManager; + private readonly ProfileTrayIconBuilder _profileTrayIconBuilder; private readonly ToolStripMenuItem _updateMenuItem; private TimerForm _animationTimer; @@ -74,6 +77,7 @@ public TrayIcon() { UpdateIcon(); _tooltipInfoManager = new TooltipInfoManager(NotifyIcon); + _profileTrayIconBuilder = new ProfileTrayIconBuilder(); _updateMenuItem = new ToolStripMenuItem(AppConfigs.Configuration.UpdateMode == UpdateMode.Never ? TrayIconStrings.updateDisabled : TrayIconStrings.noUpdate, RessourceUpdateBitmap, OnUpdateClick) { @@ -161,9 +165,7 @@ private void PopulateSettingsMenu() var applicationDirectory = Path.GetDirectoryName(ApplicationPath.Executable); Debug.Assert(applicationDirectory != null, "applicationDirectory != null"); var readmeHtml = Path.Combine(applicationDirectory, "Readme.html"); - _settingsMenu.Items.Add( - Application.ProductName + ' ' + AssemblyUtils.GetReleaseState() + " (" + Application.ProductVersion + - ")", SoundSwitchLogoIcon.ToBitmap()); + _settingsMenu.Items.Add(Application.ProductName + ' ' + AssemblyUtils.GetReleaseState() + " (" + Application.ProductVersion + ")", SoundSwitchLogoIcon.ToBitmap()); _settingsMenu.Items.Add("-"); _settingsMenu.Items.Add(TrayIconStrings.playbackDevices, RessourcePlaybackDevicesBitmap, (sender, e) => { Process.Start(new ProcessStartInfo("control", "mmsys.cpl sounds")); }); @@ -294,8 +296,20 @@ public void ShowSettings() /// public void UpdateDeviceSelectionList() { + _selectionMenu.Items.Clear(); var playbackDevices = AppModel.Instance.AvailablePlaybackDevices; var recordingDevices = AppModel.Instance.AvailableRecordingDevices; + var profiles = _profileTrayIconBuilder.GetMenuItems().ToArray(); + + + if (profiles.Length > 0) + { + var profileMenu = new ContextMenuStrip(); + var profileMenuItem = new ToolStripMenuItem(SettingsStrings.profile_tab) {DropDown = profileMenu}; + profileMenu.Items.AddRange(profiles); + _selectionMenu.Items.Add(profileMenuItem); + _selectionMenu.Items.Add(new ToolStripSeparator()); + } if (playbackDevices.Count < 0 && recordingDevices.Count < 0) { @@ -303,7 +317,6 @@ public void UpdateDeviceSelectionList() return; } - _selectionMenu.Items.Clear(); Log.Information("Set tray icon menu devices"); foreach (var item in playbackDevices) { From fc3bda1336209ed7c4b9b0df6f6bef49d45fffb2 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:10:34 -0400 Subject: [PATCH 10/15] refactor(TrayIcon): Improve the code by removing old way to do separator --- SoundSwitch/UI/Component/TrayIcon.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SoundSwitch/UI/Component/TrayIcon.cs b/SoundSwitch/UI/Component/TrayIcon.cs index 2f7f711a43..7be74e299e 100644 --- a/SoundSwitch/UI/Component/TrayIcon.cs +++ b/SoundSwitch/UI/Component/TrayIcon.cs @@ -166,15 +166,15 @@ private void PopulateSettingsMenu() Debug.Assert(applicationDirectory != null, "applicationDirectory != null"); var readmeHtml = Path.Combine(applicationDirectory, "Readme.html"); _settingsMenu.Items.Add(Application.ProductName + ' ' + AssemblyUtils.GetReleaseState() + " (" + Application.ProductVersion + ")", SoundSwitchLogoIcon.ToBitmap()); - _settingsMenu.Items.Add("-"); + _settingsMenu.Items.Add(new ToolStripSeparator()); _settingsMenu.Items.Add(TrayIconStrings.playbackDevices, RessourcePlaybackDevicesBitmap, (sender, e) => { Process.Start(new ProcessStartInfo("control", "mmsys.cpl sounds")); }); _settingsMenu.Items.Add(TrayIconStrings.mixer, RessourceMixerBitmap, (sender, e) => { Process.Start(new ProcessStartInfo("sndvol.exe")); }); - _settingsMenu.Items.Add("-"); + _settingsMenu.Items.Add(new ToolStripSeparator()); _settingsMenu.Items.Add(_updateMenuItem); _settingsMenu.Items.Add(TrayIconStrings.settings, RessourceSettingsSmallBitmap, (sender, e) => ShowSettings()); - _settingsMenu.Items.Add("-"); + _settingsMenu.Items.Add(new ToolStripSeparator()); _settingsMenu.Items.Add(TrayIconStrings.help, RessourceInfoHelpBitmap, (sender, e) => { if (!File.Exists(readmeHtml)) @@ -192,7 +192,7 @@ private void PopulateSettingsMenu() _settingsMenu.Items.Add(TrayIconStrings.donate, ResourceDonateBitmap, (sender, e) => BrowserUtil.OpenUrl($"https://soundswitch.aaflalo.me/?utm_campaign=application&utm_source={Application.ProductVersion}#donate")); _settingsMenu.Items.Add(TrayIconStrings.about, RessourceHelpSmallBitmap, (sender, e) => new About().Show()); - _settingsMenu.Items.Add("-"); + _settingsMenu.Items.Add(new ToolStripSeparator()); _settingsMenu.Items.Add(TrayIconStrings.exit, RessourceExitBitmap, (sender, e) => Application.Exit()); } @@ -325,7 +325,7 @@ public void UpdateDeviceSelectionList() if (recordingDevices.Count > 0) { - _selectionMenu.Items.Add("-"); + _selectionMenu.Items.Add(new ToolStripSeparator()); foreach (var item in recordingDevices) { _selectionMenu.Items.Add(new ToolStripDeviceItem(DeviceClicked, item)); From 49cee296f440a5fbc068a2e15503e9d1d4dcb9a9 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:11:47 -0400 Subject: [PATCH 11/15] refactor(Profile): Add new icon for profile --- SoundSwitch/Properties/Resources.Designer.cs | 10 ++++++++++ SoundSwitch/Properties/Resources.resx | 3 +++ .../Resources/user-circle-solid-profile.png | Bin 0 -> 442 bytes 3 files changed, 13 insertions(+) create mode 100644 SoundSwitch/Resources/user-circle-solid-profile.png diff --git a/SoundSwitch/Properties/Resources.Designer.cs b/SoundSwitch/Properties/Resources.Designer.cs index c0e3457f1b..051d41191d 100644 --- a/SoundSwitch/Properties/Resources.Designer.cs +++ b/SoundSwitch/Properties/Resources.Designer.cs @@ -209,6 +209,16 @@ internal static System.Drawing.Icon profile { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap profile_menu_icon { + get { + object obj = ResourceManager.GetObject("profile-menu-icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// diff --git a/SoundSwitch/Properties/Resources.resx b/SoundSwitch/Properties/Resources.resx index 730cc88d32..f5cc769c55 100644 --- a/SoundSwitch/Properties/Resources.resx +++ b/SoundSwitch/Properties/Resources.resx @@ -190,4 +190,7 @@ ..\Resources\microphone-alt-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\user-circle-solid-profile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/SoundSwitch/Resources/user-circle-solid-profile.png b/SoundSwitch/Resources/user-circle-solid-profile.png new file mode 100644 index 0000000000000000000000000000000000000000..d3149464c821f91ad04a5f34c81c66935349072e GIT binary patch literal 442 zcmV;r0Y(0aP)^Uwfgkt}Ng`C)XT-`#f^eeoL#ir3tfLr*0F*L9o zVll3b$x^JYXmqMi+((gQXzPfi7(W3)gD=+LhxZG zJ_$eNXD!vkC-{@$w5kM4z;ej8fsZ}lomK#D>nC?`fYC&0$Jh_Ru@E~&4KsL@;2cm~ zxA;0OCcv@13fOM$GyWayr5?meYj*JtL-t@w=j!dEzX!1a>;=wmOvHe9I?LfJUZXD| z)Q2}X(^(G9@@Fjqzr+UahVSp#2?tQ@zgfldr5K?mwyH`Q!m8>8+r|n8V{)8fw+-N_ k;t6;VV&^(fKr2PM1|aCUWInF?#Q*>R07*qoM6N<$f(3ucvj6}9 literal 0 HcmV?d00001 From 4cf5ab2b31b87af5fbd521687737fb257878fd6a Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:19:18 -0400 Subject: [PATCH 12/15] boost(Profile): Update the icon of the profile Be consistent with the menu icon --- SoundSwitch/UI/Component/TrayIcon.cs | 2 +- SoundSwitch/UI/Forms/UpsertProfileExtended.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SoundSwitch/UI/Component/TrayIcon.cs b/SoundSwitch/UI/Component/TrayIcon.cs index 7be74e299e..717ff7afb1 100644 --- a/SoundSwitch/UI/Component/TrayIcon.cs +++ b/SoundSwitch/UI/Component/TrayIcon.cs @@ -305,7 +305,7 @@ public void UpdateDeviceSelectionList() if (profiles.Length > 0) { var profileMenu = new ContextMenuStrip(); - var profileMenuItem = new ToolStripMenuItem(SettingsStrings.profile_tab) {DropDown = profileMenu}; + var profileMenuItem = new ToolStripMenuItem(SettingsStrings.profile_tab) {DropDown = profileMenu, Image = Resources.profile_menu_icon}; profileMenu.Items.AddRange(profiles); _selectionMenu.Items.Add(profileMenuItem); _selectionMenu.Items.Add(new ToolStripSeparator()); diff --git a/SoundSwitch/UI/Forms/UpsertProfileExtended.cs b/SoundSwitch/UI/Forms/UpsertProfileExtended.cs index 05a2a2181c..e70b95a0f5 100644 --- a/SoundSwitch/UI/Forms/UpsertProfileExtended.cs +++ b/SoundSwitch/UI/Forms/UpsertProfileExtended.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Windows.Forms; using RailSharp; @@ -36,7 +37,8 @@ public UpsertProfileExtended(Profile profile, IEnumerable playba hotKeyControl.Location = textInput.Location; LocalizeForm(); - Icon = Resources.profile; + using var iconBitmap = new Bitmap(Resources.profile_menu_icon); + Icon = Icon.FromHandle(iconBitmap.GetHicon()); InitializeFromProfile(); try From 4e9e105878ed4111ee0a328affff883a35c38da7 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:22:58 -0400 Subject: [PATCH 13/15] chore(license): Add license for Font-Awesome --- README.de.md | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.de.md b/README.de.md index 77bcb5671c..7a33d12409 100644 --- a/README.de.md +++ b/README.de.md @@ -97,6 +97,7 @@ Sie möchten etwas verbessern oder eine neue Sprache hinzufügen? Übersetzungen - Portuguese (Brazilian) translation [#258](https://github.com/Belphemur/SoundSwitch/pull/258) [@aleczk](https://github.com/aleczk) - Awesome Logo [#278](https://github.com/Belphemur/SoundSwitch/pull/278) [@linadesteem](https://github.com/linadesteem) - Icons [Pastel SVG icon set](https://codefisher.org/pastel-svg/), by Michael Buckley ([CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/)) +- Icons [Font Awesome](https://fontawesome.com/), Creative Commons Attribution 4.0 International license: [License](https://fontawesome.com/license) ### 🤝 JetBrains ![JetBrain Tooling](https://i.imgur.com/SN2qAuL.png "JetBrain Tooling") diff --git a/README.md b/README.md index 0a8c3cc043..f7394ac220 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Improve an existing or add another language? Translations are online editable [r - Awesome Logo [#278](https://github.com/Belphemur/SoundSwitch/pull/278) [@linadesteem](https://github.com/linadesteem) - Icons [Pastel SVG icon set](https://codefisher.org/pastel-svg/), by Michael Buckley ([CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/)) - Discovered and reported a security vulnerability with the updater and its code signature checker [#415](https://github.com/Belphemur/SoundSwitch/issues/415) [@JarLob](https://github.com/JarLob) - +- Free Icons from [Font Awesome](https://fontawesome.com/), Creative Commons Attribution 4.0 International license: [License](https://fontawesome.com/license) ### 🤝 JetBrains ![JetBrain Tooling](https://i.imgur.com/SN2qAuL.png "JetBrain Tooling") Thanks for their Open-Source licence to their amazing IDEs and addons like [ReSharper](https://www.jetbrains.com/resharper) for Visual Studio. From 37b1f2251dc8456f6b052d8fbcdcb8ce09c0e0d2 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:26:37 -0400 Subject: [PATCH 14/15] boost(Profile): Update the icons for the Profile feature --- SoundSwitch/Properties/Resources.Designer.cs | 30 +++++++++ SoundSwitch/Properties/Resources.resx | 9 +++ SoundSwitch/Resources/user-edit-solid.png | Bin 0 -> 416 bytes SoundSwitch/Resources/user-plus-solid.png | Bin 0 -> 412 bytes SoundSwitch/Resources/user-times-solid.png | Bin 0 -> 433 bytes SoundSwitch/UI/Forms/Settings.cs | 4 ++ SoundSwitch/UI/Forms/Settings.resx | 66 ++++++++++++++++++- 7 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 SoundSwitch/Resources/user-edit-solid.png create mode 100644 SoundSwitch/Resources/user-plus-solid.png create mode 100644 SoundSwitch/Resources/user-times-solid.png diff --git a/SoundSwitch/Properties/Resources.Designer.cs b/SoundSwitch/Properties/Resources.Designer.cs index 051d41191d..5409fbac03 100644 --- a/SoundSwitch/Properties/Resources.Designer.cs +++ b/SoundSwitch/Properties/Resources.Designer.cs @@ -209,6 +209,36 @@ internal static System.Drawing.Icon profile { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap profile_menu_add { + get { + object obj = ResourceManager.GetObject("profile-menu-add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap profile_menu_delete { + get { + object obj = ResourceManager.GetObject("profile-menu-delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap profile_menu_edit { + get { + object obj = ResourceManager.GetObject("profile-menu-edit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/SoundSwitch/Properties/Resources.resx b/SoundSwitch/Properties/Resources.resx index f5cc769c55..68ff303ff0 100644 --- a/SoundSwitch/Properties/Resources.resx +++ b/SoundSwitch/Properties/Resources.resx @@ -193,4 +193,13 @@ ..\Resources\user-circle-solid-profile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\user-plus-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\user-edit-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\user-times-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/SoundSwitch/Resources/user-edit-solid.png b/SoundSwitch/Resources/user-edit-solid.png new file mode 100644 index 0000000000000000000000000000000000000000..331a8382329c0d942a06a3c95d63a16f8e9c3d8c GIT binary patch literal 416 zcmV;R0bl-!P)P000yS1^@s6cz2e)00006VoOIv0RI60 z0RN!9r;`8x0aZyvK~y-6wbj8&8&MR-@t>m7swiEScBu%puGDqGb=y}ceSo6)0KP$V z(2H*0{JcI7w#6Op|_a7IW`C_kYj1=iDJ(V_3%z zG;xJ87Bbcs)>G`Gm0}IN9|UA80}xvs&-($4@+!9)w>Ckb}tl3oc9v`;sc&V z2dH5VUf{YQAht3_Jl;X812h{)@p*uN*eaMv=JBi#Kw3{#;}j)zR}k>CD8N5N@lB}2 z&hZQ3f$h?;@YgG%KX}P000yS1^@s6cz2e)00006VoOIv0RI60 z0RN!9r;`8x0Z~arK~y-6t<+B|1yLBs@eddI7fT5X8w-DSta$<0%8qv+FTldm#zsjg z8zt|65|NE;$ijw@B<#pVcQF<-bem@G-0S+)ubDYL^L)>F&Up^WYQQ`$@QD{}V<;uQ zVm09aL4rRp`5%zw6u^&P(OC_k8Sfd801K5Qt&M&6N1!YXR|5$u`8h$0QI4ZhkW1vt zNOqbs-V=K!Lh@M40K8$njER&~Ble{q;fYxM60Re^MsbCrvBNY_J?3yGY{n;SVIUzk zt*3rnQ|U4jG>x(7eGGlVl5Ry~kHwHy%wiPnIL9vT(S|{c3vYxgY~mya+`tTO(Ho!5 z2p(iNVce_8#UKH0ij(Kig=2Ii7NfL=Q71eo&?2nDUgTe`{9y&f{!+$Wc2^}N5bi^& zYK7&hR^3^UT&aLERhI>M`3J~zR=`vg^q0LTU`NP000yS1^@s6cz2e)00006VoOIv0RI60 z0RN!9r;`8x0cJ@=K~y-6t<*hC6+sk+;Rh}dE-^wwVW6@w!JiHyosFGJOGm(t&e&@Q zB{mu>8e<^#6xe7B+98xw+R;h{ps4W=@i%_&U?b!ITm%`!hZ4XE9u*~F zF#}3t2cso^{dj^e!eczdI&PIE2qoIeK^|P-udNo|IDhgErn8;Df(6{eFuvkF_Hh-r zh1$3AO=#?P%zcd2INrq?mW7+Omjb46P_UD#cpXnMf=_W{X%7~0hB+7$u3ue18cT7} zKB1RcwbQ}N27m;oF7Yq>-Vl;t{vtrHP_CvLuY$C?0O_lO9Crb7RArcrrvK^1A8ZP5 btW^I1x-hiX5)qjk00000NkvXXu0mjf5bL)f literal 0 HcmV?d00001 diff --git a/SoundSwitch/UI/Forms/Settings.cs b/SoundSwitch/UI/Forms/Settings.cs index 8f926e27c9..26ff5c40cd 100644 --- a/SoundSwitch/UI/Forms/Settings.cs +++ b/SoundSwitch/UI/Forms/Settings.cs @@ -338,6 +338,10 @@ private void LocalizeForm() closeButton.Text = SettingsStrings.close; toggleMuteLabel.Text = SettingsStrings.mute_toggle_label; muteHotKeyCheckbox.Text = SettingsStrings.hotkeyEnabled; + + addProfileButton.Image = Resources.profile_menu_add; + editProfileButton.Image = Resources.profile_menu_edit; + deleteProfileButton.Image = Resources.profile_menu_delete; } diff --git a/SoundSwitch/UI/Forms/Settings.resx b/SoundSwitch/UI/Forms/Settings.resx index f298a7be80..774ae44454 100644 --- a/SoundSwitch/UI/Forms/Settings.resx +++ b/SoundSwitch/UI/Forms/Settings.resx @@ -1,4 +1,64 @@ - + + + @@ -52,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file From 8d2abc982f60da7a26c7ba25eac380b64ddfc903 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sat, 17 Apr 2021 13:37:07 -0400 Subject: [PATCH 15/15] perf(Profile::Trigger): Remove unneeded var --- SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs b/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs index dfd7bea1a1..876dc64590 100644 --- a/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs +++ b/SoundSwitch/Framework/Profile/UI/ProfileToolStripMenuItem.cs @@ -21,12 +21,10 @@ namespace SoundSwitch.Framework.Profile.UI { internal class ProfileToolStripMenuItem : ToolStripMenuItem { - public Profile Profile { get; } public ProfileToolStripMenuItem(Profile profile, Image image, Action onClick) : base(profile.Name, image, (_, _) => onClick(profile)) { - Profile = profile; } } } \ No newline at end of file