Beispiel #1
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();
            }
        }
Beispiel #2
0
 public override void Execute(object sender, HandledEventArgs e)
 {
     buffers.CurrentList.LastItem();
     _output.OutputBufferListState(buffers, NavigationDirection.Down);
 }
Beispiel #3
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);
        }