示例#1
0
 private void SetEventHandlers()
 {
     AppModel.Instance.ErrorTriggered += (sender, @event) =>
     {
         using (AppLogger.Log.ErrorCall())
         {
             if (@event.Exception is AppModel.NoDevicesException)
             {
                 ShowNoDevices();
             }
             else
             {
                 AppLogger.Log.Error("Exception managed", @event.Exception);
                 ShowError(@event.Exception.Message, @event.Exception.GetType().Name);
             }
         }
     };
     AppModel.Instance.DefaultDeviceChanged += (sender, audioChangeEvent) =>
     {
         if (AppConfigs.Configuration.KeepSystrayIcon)
         {
             return;
         }
         NotifyIcon.Icon = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(audioChangeEvent.Device, false);
     };
     AppModel.Instance.NewVersionReleased += (sender, @event) =>
     {
         if (@event.UpdateMode == UpdateMode.Notify)
         {
             _context.Send(s => { NewReleaseAvailable(sender, @event); }, null);
         }
     };
 }
示例#2
0
        private void SetEventHandlers()
        {
            AppModel.Instance.ErrorTriggered += (sender, @event) =>
            {
                using (AppLogger.Log.ErrorCall())
                {
                    if (@event.Exception is AppModel.NoDevicesException)
                    {
                        ShowNoDevices();
                    }
                    else
                    {
                        AppLogger.Log.Error("Exception managed", @event.Exception);
                        ShowError(@event.Exception.Message, @event.Exception.GetType().Name);
                    }
                }
            };
            AppModel.Instance.DefaultDeviceChanged +=
                (sender, audioChangeEvent) =>
            {
                if (audioChangeEvent.role != Role.Console)
                {
                    return;
                }
                _needToUpdateList = true;
                NotifyIcon.Icon   = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(audioChangeEvent.device, false);
            };
            AppModel.Instance.SelectedDeviceChanged +=
                (sender, @event) => { _needToUpdateList = true; };
            AppModel.Instance.NewVersionReleased += (sender, @event) =>
            {
                if (@event.UpdateState == UpdateState.Normal)
                {
                    _context.Send(s => { NewReleaseAvailable(sender, @event); }, null);
                }
            };

            AppModel.Instance.DeviceRemoved +=
                (sender, @event) => { _needToUpdateList = true; };

            AppModel.Instance.DeviceAdded +=
                (sender, @event) => { _needToUpdateList = true; };

            AppModel.Instance.DeviceStateChanged +=
                (sender, @event) => { _needToUpdateList = true; };
        }
示例#3
0
        public void UpdateIcon()
        {
            if (AppConfigs.Configuration.KeepSystrayIcon)
            {
                NotifyIcon.Icon = Icon.FromHandle(Resources.SoundSwitch16.GetHicon());
                return;
            }

            try
            {
                var defaultDevice = AppModel.Instance.ActiveAudioDeviceLister.GetPlaybackDevices()
                                    .First(device => AudioController.IsDefault(device.ID, (DeviceType)device.DataFlow, DeviceRole.Console));
                NotifyIcon.Icon = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(defaultDevice, false);
            }
            catch (InvalidOperationException)
            {
            }
        }
示例#4
0
        public void UpdateIcon()
        {
            if (AppConfigs.Configuration.KeepSystrayIcon)
            {
                ReplaceIcon(SoundSwitchLogoIcon);
                return;
            }

            try
            {
                using (var devices = AppModel.Instance.ActiveAudioDeviceLister.GetPlaybackDevices())
                {
                    var defaultDevice = devices
                                        .First(device =>
                                               AudioController.IsDefault(device.ID, (DeviceType)device.DataFlow, DeviceRole.Console));
                    ReplaceIcon(AudioDeviceIconExtractor.ExtractIconFromAudioDevice(defaultDevice, false));
                }
            }
            catch (InvalidOperationException)
            {
            }
        }