Skip to content

Commit

Permalink
Logs Exception in TrayIcon. See #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Aflalo committed Aug 24, 2015
1 parent 52d8ffe commit 217acf6
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions SoundSwitch/Util/TrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,35 @@ public void Dispose()

private void SetEventHandlers()
{
_main.ErrorTriggered += (sender, exception) =>
_main.ErrorTriggered += (sender, @event) =>
{
if (exception.Exception is Main.NoDevicesException)
using (AppLogger.Log.ErrorCall())
{
ShowNoDevices();
}
else
{
ShowError(exception.Exception.Message);
if (@event.Exception is Main.NoDevicesException)
{
ShowNoDevices();
}
else
{
AppLogger.Log.Error("Exception managed", @event.Exception);
ShowError(@event.Exception.Message, @event.Exception.GetType().Name);
}
}
};
_main.AudioDeviceChanged +=
(sender, audioDeviceWrapper) =>
(sender, audioChangeEvent) =>
{
ShowAudioChanged(audioDeviceWrapper.AudioDevice.FriendlyName);
ShowAudioChanged(audioChangeEvent.AudioDevice.FriendlyName);
foreach (ToolStripDeviceItem item in _selectionMenu.Items)
{
item.Image = item.AudioDevice.FriendlyName == audioDeviceWrapper.AudioDevice.FriendlyName ? Resources.GreenCheck : null;
item.Image = item.AudioDevice.FriendlyName == audioChangeEvent.AudioDevice.FriendlyName ? Resources.GreenCheck : null;
}
};
_main.SelectedDeviceChanged += (sender, changed) =>
_main.SelectedDeviceChanged += (sender, deviceListChanged) =>
{
UpdateAvailableDeviceList();
};
WindowsAPIAdapter.DeviceChanged += (sender, @event) =>
WindowsAPIAdapter.DeviceChanged += (sender, deviceChangeEvent) =>
{
UpdateAvailableDeviceList();
};
Expand Down Expand Up @@ -188,6 +192,7 @@ public void ShowAudioChanged(string deviceName)
/// </summary>
public void ShowNoDevices()
{
AppLogger.Log.Error("No devices available");
_trayIcon.ShowBalloonTip(3000, "SoundSwitch: Configuration needed",
"No devices available to switch to. Open configuration by right-clicking on the SoundSwitch icon. ",
ToolTipIcon.Warning);
Expand Down

0 comments on commit 217acf6

Please sign in to comment.