예제 #1
0
        internal static void ActionHookCallback(Hotkey hotkey)
        {
            // Bug 9421: ignore this keypress if it is the same as the previous one and it's been less than
            //           WAIT_BETWEEN_HOTKEY_PRESS since the last press. Note that we do not update
            //           _lastHotkeyPressTime in this case to avoid being trapped in a never ending cycle of
            //           ignoring keypresses if the user (for some reason) decides to press really quickly,
            //           really often on the hotkey
            if (hotkey == _lastHotkey && DateTime.Now.Subtract(_lastHotkeyPressTime).TotalMilliseconds < WAIT_BETWEEN_HOTKEY_PRESS)
            {
                return;
            }

            _lastHotkey          = hotkey;
            _lastHotkeyPressTime = DateTime.Now;

            string currentTrack = string.Empty;

            try
            {
                Song songBeforeAction = Toast.Current.currentSong;

                if (hotkey.Action == SpotifyAction.CopyTrackInfo && songBeforeAction != null)
                {
                    Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.CopyTrackInfo);

                    CopySongToClipboard(songBeforeAction);
                }
                else if (hotkey.Action == SpotifyAction.PasteTrackInfo && songBeforeAction != null)
                {
                    Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.PasteTrackInfo);

                    CopySongToClipboard(songBeforeAction);

                    SendPasteKey(hotkey);
                }
                else
                {
                    Spotify.SendAction(hotkey.Action);
                }

                Toast.Current.DisplayAction(hotkey.Action, songBeforeAction);
            }
            catch (Exception ex)
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }

                System.Diagnostics.Debug.WriteLine("Exception with hooked key! " + ex);
                Toast.Current.Title1.Text = "Unable to communicate with Spotify";
                Toast.Current.Title2.Text = "";
                Toast.Current.FadeIn();
            }
        }
예제 #2
0
        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                dragging = true;
                DragMove();
                return;
            }

            FadeOut(now: true);

            Spotify.SendAction(SpotifyAction.ShowSpotify);
        }
예제 #3
0
        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                dragging = true;
                DragMove();
                return;
            }

            FadeOut(now: true);

            if (isUpdateToast)
            {
                Process.Start(new ProcessStartInfo(versionChecker.UpdateUrl));
            }
            else
            {
                Spotify.SendAction(SpotifyAction.ShowSpotify);
            }
        }
예제 #4
0
        internal static void ActionHookCallback(Hotkey hotkey)
        {
            // Bug 9421: ignore this keypress if it is the same as the previous one and it's been less than
            //           WAIT_BETWEEN_HOTKEY_PRESS since the last press. Note that we do not update
            //           _lastHotkeyPressTime in this case to avoid being trapped in a never ending cycle of
            //           ignoring keypresses if the user (for some reason) decides to press really quickly,
            //           really often on the hotkey
            if (hotkey == _lastHotkey && DateTime.Now.Subtract(_lastHotkeyPressTime).TotalMilliseconds < WAIT_BETWEEN_HOTKEY_PRESS)
            {
                return;
            }

            _lastHotkey          = hotkey;
            _lastHotkeyPressTime = DateTime.Now;

            string currentTrack = string.Empty;

            try
            {
                string trackBeforeAction = Spotify.GetCurrentTrack();
                if (hotkey.Action == SpotifyAction.CopyTrackInfo && !string.IsNullOrEmpty(trackBeforeAction))
                {
                    Clipboard.SetText(string.Format(SettingsXml.Current.ClipboardTemplate, trackBeforeAction));
                }
                else
                {
                    Spotify.SendAction(hotkey.Action);
                }

                Toast.Current.DisplayAction(hotkey.Action, trackBeforeAction);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception with hooked key! " + ex);
                Toast.Current.Title1.Text = "Unable to communicate with Spotify";
                Toast.Current.Title2.Text = "";
                Toast.Current.FadeIn();
            }
        }
예제 #5
0
 private void MuteSpotify()
 {
     Spotify.SendAction(SpotifyAction.Mute);
     isMute = !isMute;
 }
예제 #6
0
 private void Window_MouseDown(object sender, MouseButtonEventArgs e)
 {
     FadeOut();
     Spotify.SendAction(SpotifyAction.ShowSpotify);
 }