Exemplo n.º 1
0
 public override void Execute(object sender, HandledEventArgs e)
 {
     if (playbackManager.PlayingTrack != null)
     {
         _output.OutputTrackModel(playbackManager.PlayingTrack);
     }
     else
     {
         _output.OutputMessage(StringStore.NoTrackCurrentlyBeingPlayed);
     }
 }
Exemplo n.º 2
0
 public override void Execute(object sender, HandledEventArgs e)
 {
     _output.OutputMessage(StringStore.ExitingProgram);
     if (parent.InvokeRequired)
     {
         parent.Invoke(new Action(() => { parent.Close(); }));
     }
     else
     {
         parent.Close();
     }
 }
Exemplo n.º 3
0
        public override void Execute(object sender, HandledEventArgs e)
        {
            var item      = buffers.CurrentList.CurrentItem;
            var playQueue = buffers[0];

            if (item is TrackBufferItem)
            {
                playQueue.Add(item);
                _output.OutputMessage(StringStore.AddedToQueue, true);
            }
            else
            {
            }
        }
Exemplo n.º 4
0
        public override void Execute(object sender, HandledEventArgs e)
        {
            var currentBuffer = buffers.CurrentList;

            if (!currentBuffer.IsDismissable)
            {
                _output.OutputMessage(String.Format("{0} {1}", StringStore.CannotDismissBuffer, currentBuffer.Name));
            }
            else
            {
                buffers.PreviousList();
                buffers.Remove(currentBuffer);
                _output.OutputBufferListState(buffers, NavigationDirection.Left);
            }
            // if it's a buffer with a search or other unmanaged resources, dispose it
            if (currentBuffer is IDisposable)
            {
                ((IDisposable)currentBuffer).Dispose();
            }
        }
        public override void Execute(object sender, HandledEventArgs e)
        {
            var trackItem    = _buffers.CurrentList.CurrentItem as TrackBufferItem;
            var playlistList = _buffers.CurrentList as PlaylistBufferList;

            if (trackItem == null || playlistList == null)
            {
                return;
            }
            var trackIndex = playlistList.CurrentItemIndex;

            var response = spotify.RemoveTrackFromPlaylist(trackIndex, playlistList.Model.Pointer);

            if (!response.IsError)
            {
                output.OutputMessage(StringStore.TrackRemoved);
            }
            else
            {
                MessageBox.Show(response.Message, StringStore.UnableToRemoveTrack, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 6
0
        public override void Execute(object sender, HandledEventArgs e)
        {
            var item = buffers.CurrentList.CurrentItem;

            if (item is TrackBufferItem)
            {
                ActivateTrackItem(item);
            }
            else if (item is PlaylistBufferItem)
            {
                LoadPlaylist(item);
            }
            else if (item is AlbumBufferItem)
            {
                LoadAlbum(item);
            }
            else if (item is ArtistBufferItem)
            {
                LoadArtist(item);
            }
            else
            {
                _output.OutputMessage(String.Format("{0} {1}", item.ToString(), StringStore.ItemActivated), false);
            }
        }
Exemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            if (settings.UpdatesInterestedIn != UserSettings.UpdateType.None)
            {
                updater.CheckForNewVersion();
            }

            if (downloadedUpdate)
            {
                this.Close();
                return;
            }
            SpotifyController.Initialize();
            var appKeyBytes = Properties.Resources.spotify_appkey;

            LoadBufferWindowCommands();
            KeyManager = BufferHotkeyManager.LoadFromTextFile(this);
            string username = "", password = "";
            // the first one controls the loop, the second is the response from Libspotify's login call
            bool isLoggedIn = false, logInResponse = false;

            while (!isLoggedIn)
            {
                using (LoginWindow logon = new LoginWindow())
                {
                    var response = logon.ShowDialog();
                    if (response != DialogResult.OK)
                    {
                        this.Close();
                        output.OutputMessage(StringStore.ExitingProgram);
                        return;
                    }
                    username = logon.Username;
                    password = logon.Password;
                }
                try
                {
                    output.OutputMessage(StringStore.LoggingIn);
                    logInResponse = SpotifyController.Login(appKeyBytes, username, password);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(StringStore.ErrorDuringLoad + "\\r\\nInitialization: " + ex.Message, StringStore.Oops, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }
                if (logInResponse)
                {
                    output.OutputMessage(StringStore.LoggedInToSpotify);
                    UserSettings.Instance.Username = username;
                    UserSettings.Save();
                    spotify.SetPrivateSession(UserSettings.Instance.StartInPrivateSession);
                    isLoggedIn = true;
                }
                else
                {
                    var reason = spotify.GetLoginError().Message;
                    MessageBox.Show(reason, StringStore.LogInFailure, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            output.OutputMessage(StringStore.LoadingPlaylists, false);
            var playlists = LoadUserPlaylists();

            if (playlists == null)
            {
                return;
            }

            var playlistsBuffer = Buffers[1] as PlaylistContainerBufferList;

            if (playlistsBuffer == null)
            {
                throw new NullReferenceException("PlaylistsBuffer is null");
            }

            playlistsBuffer.Clear();
            playlists.ForEach(p =>
            {
                playlistsBuffer.Add(new PlaylistBufferItem(p));
            });
            // we put a reference to the session container on the playlists buffer
            // so that it can subscribe to playlist added and removed events and in future maybe other things
            playlistsBuffer.Model = PlaylistContainer.GetSessionContainer();

            output.OutputMessage(String.Format("{0} {1}", playlists.Count, StringStore.PlaylistsLoaded), false);
            Buffers.CurrentListIndex = 1; // start on the playllists list
            output.OutputBufferListState(Buffers, NavigationDirection.None, false);
        }