Exemplo n.º 1
0
 public void VolumeDown()
 {
     VolumeHelper.DecrementVolume(Settings.Current.WindowsVolumeMixerIncrement);
 }
Exemplo n.º 2
0
        public void SendAction(ToastifyActionEnum action)
        {
            if (!this.IsRunning)
            {
                return;
            }

            bool sendAppCommandMessage = false;
            bool sendMediaKey          = false;

            switch (action)
            {
#if DEBUG
            case ToastifyActionEnum.ShowDebugView:
#endif
            case ToastifyActionEnum.None:
            case ToastifyActionEnum.CopyTrackInfo:
            case ToastifyActionEnum.PasteTrackInfo:
            case ToastifyActionEnum.ThumbsUp:
            case ToastifyActionEnum.ThumbsDown:
            case ToastifyActionEnum.ShowToast:
            case ToastifyActionEnum.SettingsSaved:
            case ToastifyActionEnum.Exit:
                break;

            case ToastifyActionEnum.ShowSpotify:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.ShowSpotify);
                if (this.IsMinimized)
                {
                    this.ShowSpotify();
                }
                else
                {
                    this.Minimize();
                }
                break;

            case ToastifyActionEnum.VolumeUp:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.VolumeUp);
                switch ((ToastifyVolumeControlMode)Settings.Current.VolumeControlMode)
                {
                // The Spotify volume control mode has been dropped since Spotify version 1.0.75.483.g7ff4a0dc due to issue #31
                //case ToastifyVolumeControlMode.Spotify:
                //    this.SendShortcut(action);
                //    break;

                case ToastifyVolumeControlMode.SystemSpotifyOnly:
                    VolumeHelper.IncrementVolume(Settings.Current.WindowsVolumeMixerIncrement);
                    break;

                case ToastifyVolumeControlMode.SystemGlobal:
                    sendMediaKey = true;
                    break;

                default:
                    sendMediaKey = true;
                    break;
                }

                break;

            case ToastifyActionEnum.VolumeDown:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.VolumeDown);
                switch ((ToastifyVolumeControlMode)Settings.Current.VolumeControlMode)
                {
                // The Spotify volume control mode has been dropped since Spotify version 1.0.75.483.g7ff4a0dc due to issue #31
                //case ToastifyVolumeControlMode.Spotify:
                //    this.SendShortcut(action);
                //    break;

                case ToastifyVolumeControlMode.SystemSpotifyOnly:
                    VolumeHelper.DecrementVolume(Settings.Current.WindowsVolumeMixerIncrement);
                    break;

                case ToastifyVolumeControlMode.SystemGlobal:
                default:
                    sendMediaKey = true;
                    break;
                }

                break;

            case ToastifyActionEnum.Mute:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, Analytics.ToastifyEvent.Action.Mute);
                switch ((ToastifyVolumeControlMode)Settings.Current.VolumeControlMode)
                {
                case ToastifyVolumeControlMode.SystemSpotifyOnly:
                    VolumeHelper.ToggleMute();
                    break;

                // The Spotify volume control mode has been dropped since Spotify version 1.0.75.483.g7ff4a0dc due to issue #31
                //case ToastifyVolumeControlMode.Spotify:
                case ToastifyVolumeControlMode.SystemGlobal:
                default:
                    sendMediaKey = true;
                    break;
                }

                break;

            case ToastifyActionEnum.FastForward:
            case ToastifyActionEnum.Rewind:
            case ToastifyActionEnum.Stop:
            case ToastifyActionEnum.PlayPause:
            case ToastifyActionEnum.PreviousTrack:
            case ToastifyActionEnum.NextTrack:
                goto default;

            default:
                Analytics.TrackEvent(Analytics.ToastifyEventCategory.Action, $"{Analytics.ToastifyEvent.Action.Default}{action}");
                sendAppCommandMessage = true;
                break;
            }

            if (sendAppCommandMessage)
            {
                Windows.SendAppCommandMessage(this.GetMainWindowHandle(), (IntPtr)action, true);
            }
            if (sendMediaKey)
            {
                Win32API.SendMediaKey(action);
            }
        }