Skip to content

Commit

Permalink
Implements double click to switch device.
Browse files Browse the repository at this point in the history
Fixes #80
  • Loading branch information
Antoine Aflalo committed Mar 18, 2016
1 parent 4acfab9 commit fa764ca
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions SoundSwitch/Util/TrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,22 @@ public TrayIcon()

_selectionMenu.Items.Add(TrayIconStrings.NoDevSel, Resources.Settings, (sender, e) => ShowSettings());

NotifyIcon.MouseDoubleClick += (sender, args) =>
{
AppModel.Instance.CycleActiveDevice(AudioDeviceType.Playback);
};

NotifyIcon.MouseClick += (sender, e) =>
{
if (e.Button == MouseButtons.Left)
{
UpdateDeviceSelectionList();
NotifyIcon.ContextMenuStrip = _selectionMenu;
var mi = typeof (NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(NotifyIcon, null);
if (e.Button != MouseButtons.Left) return;

NotifyIcon.ContextMenuStrip = _settingsMenu;
}
UpdateDeviceSelectionList();
NotifyIcon.ContextMenuStrip = _selectionMenu;
var mi = typeof (NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(NotifyIcon, null);

NotifyIcon.ContextMenuStrip = _settingsMenu;
};
SetEventHandlers();
}
Expand Down

0 comments on commit fa764ca

Please sign in to comment.