public void Dispatch(JukeboxCommand cmd) { var player = GetCurrentPlayer(); if (player == null) { return; } if (cmd == JukeboxCommand.PlayAfterPaused) { if (_wasPaused) { cmd = JukeboxCommand.Play; } else { return; } } _wasPaused = (cmd == JukeboxCommand.Pause && player.IsPlaying); player.PerformAction(cmd); _lastJukebox = player; }
private void BubbleReactOnEvent(JukeboxCommand obj) { if (this.ReactOnEvent != null) { this.ReactOnEvent(obj); } }
public void dispatch_events_to_single_player(bool isPlaying, JukeboxCommand cmd) { itunes.SetupGet(m => m.IsPlaying).Returns(isPlaying); EventDispatcher dsp = new EventDispatcher(new[] { itunes.Object }); dsp.Dispatch(cmd); itunes.Verify(m => m.PerformAction(cmd)); }
public void dispatch_events_to_single_player(bool isPlaying, JukeboxCommand cmd) { itunes.SetupGet(m => m.IsPlaying).Returns(isPlaying); EventDispatcher dsp = new EventDispatcher(new[]{itunes.Object}); dsp.Dispatch(cmd); itunes.Verify(m => m.PerformAction(cmd)); }
public void PerformAction(JukeboxCommand cmd) { if (!_messageMapping.ContainsKey(cmd)) { return; } _socket.SendMessage(_messageMapping[cmd]); }
public void PerformAction(JukeboxCommand cmd) { if (iTunes == null) return; var itunes = this.iTunes; if (!_actionMapping.ContainsKey(cmd)) return; var methodToCall = _actionMapping[cmd]; itunes.GetType().GetMethod(methodToCall).Invoke(itunes, new object[0]); }
public void dispatch_events_to_single_of_multiple_players(JukeboxCommand cmd) { itunes.SetupGet(m => m.IsPlaying).Returns(false); superplayer.SetupGet(m => m.IsPlaying).Returns(false); spotify.SetupGet(m => m.IsPlaying).Returns(true); EventDispatcher dsp = new EventDispatcher(new[] { itunes.Object, spotify.Object, superplayer.Object }); dsp.Dispatch(cmd); superplayer.Verify(m => m.PerformAction(cmd), Times.Never()); itunes.Verify(m => m.PerformAction(cmd), Times.Never()); spotify.Verify(m => m.PerformAction(cmd), Times.Once()); }
public void PerformAction(JukeboxCommand cmd) { if (_remote == null) { return; } if (!_actionMapping.ContainsKey(cmd)) { return; } var methodToCall = _actionMapping[cmd]; _remote.GetType().GetMethod(methodToCall).Invoke(_remote, new object[0]); }
public void PerformAction(JukeboxCommand cmd) { if (iTunes == null) { return; } var itunes = this.iTunes; if (!_actionMapping.ContainsKey(cmd)) { return; } var methodToCall = _actionMapping[cmd]; itunes.GetType().GetMethod(methodToCall).Invoke(itunes, new object[0]); }
public void Dispatch(JukeboxCommand cmd) { var player = GetCurrentPlayer(); if (player == null) return; if (cmd == JukeboxCommand.PlayAfterPaused) { if (_wasPaused) cmd = JukeboxCommand.Play; else return; } _wasPaused = (cmd == JukeboxCommand.Pause && player.IsPlaying); player.PerformAction(cmd); _lastJukebox = player; }
private void RegisterHotKey(string hotkeyCombination, JukeboxCommand spotifyCommand) { var k = ParseKeyString(hotkeyCombination); if (k == Keys.None) { return; } var hotkey = new ManagedWinapi.Hotkey(); if (hotkey.Enabled) { hotkey.Enabled = false; } hotkey.Alt = hotkeyCombination.Contains("ALT"); hotkey.Ctrl = hotkeyCombination.Contains("CTRL") || hotkeyCombination.Contains("STRG"); hotkey.Shift = hotkeyCombination.Contains("SHIFT"); if (!hotkey.Alt && !hotkey.Ctrl && !hotkey.Shift) { hotkey.Dispose(); return; } hotkey.KeyCode = k; hotkey.HotkeyPressed += (s, e) => { if (ReactOnEvent != null) { ReactOnEvent(spotifyCommand); } }; this._hotkeys.Add(hotkey); }
public void PerformAction(JukeboxCommand cmd) { if (!_messageMapping.ContainsKey(cmd)) return; _socket.SendMessage(_messageMapping[cmd]); }
public void PerformAction(JukeboxCommand cmd) { }
public void PerformAction(JukeboxCommand cmd) { _actionMapping[cmd](); }
public void PerformAction(JukeboxCommand cmd) { if (_remote == null) return; if (!_actionMapping.ContainsKey(cmd)) return; var methodToCall = _actionMapping[cmd]; _remote.GetType().GetMethod(methodToCall).Invoke(_remote, new object[0]); }
private void RegisterHotKey(string hotkeyCombination, JukeboxCommand spotifyCommand) { var k = ParseKeyString(hotkeyCombination); if (k == Keys.None) return; var hotkey = new ManagedWinapi.Hotkey(); if (hotkey.Enabled) hotkey.Enabled = false; hotkey.Alt = hotkeyCombination.Contains("ALT"); hotkey.Ctrl = hotkeyCombination.Contains("CTRL") || hotkeyCombination.Contains("STRG"); hotkey.Shift = hotkeyCombination.Contains("SHIFT"); if (!hotkey.Alt && !hotkey.Ctrl && !hotkey.Shift) { hotkey.Dispose(); return; } hotkey.KeyCode = k; hotkey.HotkeyPressed += (s, e) => { if (ReactOnEvent != null) ReactOnEvent(spotifyCommand); }; this._hotkeys.Add(hotkey); }