Skip to content

Commit

Permalink
Implement the KeepSystray feature
Browse files Browse the repository at this point in the history
Fixes #128
  • Loading branch information
Antoine Aflalo committed Dec 8, 2016
1 parent 1b07605 commit 4b36f01
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 16 deletions.
9 changes: 9 additions & 0 deletions SoundSwitch/Properties/SettingsString.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SoundSwitch/Properties/SettingsString.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,10 @@
<data name="cycleDevice" xml:space="preserve">
<value>Switcher entre</value>
</data>
<data name="keepSystrayIconHelp" xml:space="preserve">
<value>Si coché, l'icone dans la barre de tache restera celle de l'application quand le périférique par défault est changé.</value>
</data>
<data name="keepSystrayIcon" xml:space="preserve">
<value>Garder l'icone intacte</value>
</data>
</root>
3 changes: 3 additions & 0 deletions SoundSwitch/Properties/SettingsString.resx
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,7 @@
<data name="keepSystrayIcon" xml:space="preserve">
<value>Keep systray icon</value>
</data>
<data name="keepSystrayIconHelp" xml:space="preserve">
<value>If selected, the Systray Icon won't change when the default device changes.</value>
</data>
</root>
29 changes: 15 additions & 14 deletions SoundSwitch/UI/Forms/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions SoundSwitch/UI/Forms/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public Settings()
new DeviceCyclerFactory().ConfigureListControl(cyclerComboBox);
cyclerComboBox.SelectedValue = DeviceCyclerManager.CurrentCycler;

var toolTipSystray = new ToolTip();
toolTipSystray.SetToolTip(checkboxSystrayIcon, SettingsString.keepSystrayIconHelp);
checkboxSystrayIcon.Checked = AppConfigs.Configuration.KeepSystrayIcon;

_loaded = true;
}

Expand Down Expand Up @@ -446,5 +450,11 @@ private void stealthUpdateCheckbox_CheckedChanged(object sender, EventArgs e)
{
AppModel.Instance.StealthUpdate = stealthUpdateCheckbox.Checked;
}

private void checkboxSystrayIcon_CheckedChanged(object sender, EventArgs e)
{
AppConfigs.Configuration.KeepSystrayIcon = checkboxSystrayIcon.Checked;
AppConfigs.Configuration.Save();
}
}
}
14 changes: 12 additions & 2 deletions SoundSwitch/Util/TrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using AudioEndPointControllerWrapper;
using SoundSwitch.Framework;
using SoundSwitch.Framework.Audio;
using SoundSwitch.Framework.Configuration;
using SoundSwitch.Framework.TooltipInfoManager;
using SoundSwitch.Framework.Updater;
using SoundSwitch.Model;
Expand All @@ -39,6 +40,7 @@ public sealed class TrayIcon : IDisposable
private readonly ContextMenuStrip _settingsMenu = new ContextMenuStrip();
private readonly SynchronizationContext _context = SynchronizationContext.Current ?? new SynchronizationContext();
private volatile bool _needToUpdateList = true;
private bool _iconChanged = false;
public NotifyIcon NotifyIcon { get; } = new NotifyIcon
{
Icon = Icon.FromHandle(Resources.SoundSwitch16.GetHicon()),
Expand Down Expand Up @@ -164,8 +166,16 @@ private void SetEventHandlers()
{
return;
}
_needToUpdateList = true;
NotifyIcon.Icon = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(audioChangeEvent.device, false);
if (!AppConfigs.Configuration.KeepSystrayIcon)
{
NotifyIcon.Icon = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(audioChangeEvent.device, false);
_iconChanged = true;
}
else if (_iconChanged)
{
NotifyIcon.Icon = Icon.FromHandle(Resources.SoundSwitch16.GetHicon());
_iconChanged = false;
}
};
AppModel.Instance.SelectedDeviceChanged +=
(sender, @event) => { _needToUpdateList = true; };
Expand Down

0 comments on commit 4b36f01

Please sign in to comment.