Ejemplo n.º 1
0
        private void LoadAlbumSearch()
        {
            if (CheckLoggedInAndOnline())
            {
                CFDialogParams  searchDialogParams = new CFDialogParams("Search by album name");
                CFDialogResults results            = new CFDialogResults();
                DialogResult    result             = CF_displayDialog(CF_Dialogs.OSK, searchDialogParams, results);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    string searchText = results.resultvalue;
                    CF_systemCommand(CF_Actions.SHOWINFO, "Searching...");
                    ThreadPool.QueueUserWorkItem(delegate(object param)
                    {
                        try
                        {
                            var search = SpotifySession.SearchAlbums(searchText, 0, 20);

                            SleepUntilTrue(() => search.IsComplete);

                            List <IAlbum> albums = new List <IAlbum>();
                            foreach (var album in search.Albums)
                            {
                                if (album.IsAvailable)
                                {
                                    albums.Add(album);
                                }
                            }
                            search.Dispose();
                            var table = LoadAlbumsIntoTable(albums, false);

                            this.ParentForm.BeginInvoke(new MethodInvoker(delegate()
                            {
                                CF_systemCommand(CF_Actions.HIDEINFO);
                                SwitchToTab(Tabs.Search, GroupingType.Albums, table, "Search", null, true);
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.ParentForm.BeginInvoke(new MethodInvoker(() =>
                            {
                                CF_systemCommand(CF_Actions.HIDEINFO);
                                WriteError(ex);
                                CF_displayMessage(ex.Message);
                            }));
                        }
                    });
                }
            }
        }
        private void LoadAlbumSearch()
        {
            if (CheckLoggedInAndOnline())
            {
                CFDialogParams searchDialogParams = new CFDialogParams("Search by album name");
                CFDialogResults results = new CFDialogResults();
                DialogResult result = CF_displayDialog(CF_Dialogs.OSK, searchDialogParams, results);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    string searchText = results.resultvalue;
                    CF_systemCommand(CF_Actions.SHOWINFO, "Searching...");
                    ThreadPool.QueueUserWorkItem(delegate(object param)
                    {
                        try
                        {
                            var search = SpotifySession.SearchAlbums(searchText, 0, 20);

                            SleepUntilTrue(() => search.IsComplete);

                            List<IAlbum> albums = new List<IAlbum>();
                            foreach (var album in search.Albums)
                            {
                                if (album.IsAvailable)
                                {
                                    albums.Add(album);
                                }
                            }
                            search.Dispose();
                            var table = LoadAlbumsIntoTable(albums, false);

                            this.ParentForm.BeginInvoke(new MethodInvoker(delegate()
                            {
                                CF_systemCommand(CF_Actions.HIDEINFO);
                                SwitchToTab(Tabs.Search, GroupingType.Albums, table, "Search", null, true);
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.ParentForm.BeginInvoke(new MethodInvoker(() =>
                            {
                                CF_systemCommand(CF_Actions.HIDEINFO);
                                WriteError(ex);
                                CF_displayMessage(ex.Message);
                            }));
                        }
                    });
                }
            }
        }
Ejemplo n.º 3
0
        private void SetLocation(ref object value)
        {
            string location = GetLocation();

            CFDialogParams dialogParams = new CFDialogParams("Choose a folder for Spotify data", location);

            dialogParams.browseable       = true;
            dialogParams.enablesubactions = true;
            dialogParams.showfiles        = false;

            CFDialogResults results = new CFDialogResults();

            if (this.CF_displayDialog(CF_Dialogs.FileBrowser, dialogParams, results) == DialogResult.OK)
            {
                string newPath = results.resultvalue;
                this.pluginConfig.WriteField("/APPCONFIG/LOCATION", newPath);
                ButtonValue[(int)value] = newPath;
            }
        }
Ejemplo n.º 4
0
        private void SetLocation(ref object value)
        {
            string location = GetLocation();

            CFDialogParams dialogParams = new CFDialogParams("Choose a folder for Spotify data", location);
            dialogParams.browseable = true;
            dialogParams.enablesubactions = true;
            dialogParams.showfiles = false;

            CFDialogResults results = new CFDialogResults();
            if (this.CF_displayDialog(CF_Dialogs.FileBrowser, dialogParams, results) == DialogResult.OK)
            {
                string newPath = results.resultvalue;
                this.pluginConfig.WriteField("/APPCONFIG/LOCATION", newPath);
                ButtonValue[(int)value] = newPath;
            }
        }
        private void StationSearch()
        {
            WriteLog();

            if (_clientIsBusy)
                return;

            if (!EnsureAuthenticated("StationSearch"))
                return;

            CFDialogParams dialogParams = new CFDialogParams();
            dialogParams.displaytext = "Enter the name of an artist or song";
            CFDialogResults dialogResults = new CFDialogResults();

            DialogResult dialogResult = CF_displayDialog(CF_Dialogs.OSK, dialogParams, dialogResults);

            if (dialogResult == DialogResult.OK && !IsNullOrWhiteSpace(dialogResults.resultvalue))
            {
                CF_systemCommand(CF_Actions.SHOWINFO, "Searching...");
                _clientIsBusy = true;
                _pandoraClient.SearchAsync(dialogResults.resultvalue);
            }
        }
        private void ShowSearchResults(List<SearchResult> searchResults)
        {
            WriteLog();

            if (searchResults == null || searchResults.Count == 0)
                return;

            searchResults.Sort(delegate(SearchResult searchResult1, SearchResult searchResult2)
            {
                if (searchResult1.SearchResultType == searchResult2.SearchResultType)
                    return 0;
                else if (searchResult1.SearchResultType == SearchResultTypes.Artist &&
                            searchResult2.SearchResultType == SearchResultTypes.Song)
                    return -1;
                else if (searchResult1.SearchResultType == SearchResultTypes.Song &&
                            searchResult2.SearchResultType == SearchResultTypes.Artist)
                    return 1;
                else
                    return 0; //Shouldn't happen
            });

            CFControls.CFListViewItem[] listItems = new CFControls.CFListViewItem[searchResults.Count];

            for (int i = 0; i < searchResults.Count; i++)
                listItems[i] = new CFControls.CFListViewItem(searchResults[i].ResultText, searchResults[i].MusicId, 0, false, searchResults[i] as object);

            CFDialogParams dialogParams = new CFDialogParams();
            CFDialogResults dialogResults = new CFDialogResults();
            dialogParams.displaytext = "Choose a result from the list to create a station.";
            dialogParams.listitems = listItems;

            DialogResult dialogResult = CF_displayDialog(CF_Dialogs.FileBrowser, dialogParams, dialogResults);

            if (dialogResult != DialogResult.OK)
                return;

            if (!EnsureAuthenticated("CreateStation"))
                return;

            _clientIsBusy = true;
            _pandoraClient.CreateStationAsync(dialogResults.resultvalue);
        }
        private void ToggleGuest()
        {
            WriteLog();

            if (_guest)
            {
                CFDialogParams dialogParams = new CFDialogParams();
                dialogParams.displaytext = String.Format("Are you sure you want to logoff of the guest account {0} ?", _userName);
                DialogResult dialogResult = CF_displayDialog(CF_Dialogs.YesNo, dialogParams);

                if (dialogResult == DialogResult.OK)
                {
                    EndSession();
                    _guest = false;
                    CF_setPictureImage("GuestActive", null);

                    //Load the stored credentials, favorites, etc back in
                    LoadSettings();

                    RefreshStations();
                }
            }
            else
            {
                string guestUsername = null;
                string guestPassword = null;

                CFDialogParams dialogParams = new CFDialogParams();
                CFDialogResults dialogResults = new CFDialogResults();
                DialogResult dialogResult;

                dialogParams.displaytext = this.pluginLang.ReadField("/APPLANG/PANDORA/USERNAMEPROMPT");
                dialogResult = CF_displayDialog(CF_Dialogs.OSK, dialogParams, dialogResults);

                if (dialogResult == DialogResult.Cancel)
                    return;

                if (IsNullOrWhiteSpace(dialogResults.resultvalue))
                {
                    CF_displayMessage("Invalid user name.");
                    return;
                }

                guestUsername = dialogResults.resultvalue;

                //UGH! More SDK inconsistencies... passing "PASSWORD" as param2 here doesn't invoke the password
                //masking feature, so I have to use the full blown CF_systemDisplayDialog method instead. Lame.
                //dialogParams.displaytext = this.pluginLang.ReadField("/APPLANG/PANDORA/PASSWORDPROMPT");
                //dialogParams.param2 = "PASSWORD";
                //dialogResult = CF_displayDialog(CF_Dialogs.OSK, dialogParams, dialogResults);
                object tempObject;
                string resultValue, resultText;
                dialogResult = this.CF_systemDisplayDialog(CF_Dialogs.OSK, this.pluginLang.ReadField("/APPLANG/PANDORA/PASSWORDPROMPT"), String.Empty, "PASSWORD", out resultValue, out resultText, out tempObject, null, true, true, true, true, false, false, 1);

                if (dialogResult == DialogResult.Cancel)
                    return;

                if (IsNullOrWhiteSpace(resultValue))
                {
                    CF_displayMessage("Invalid password.");
                    return;
                }

                guestPassword = resultValue;

                EndSession();
                _guest = true;
                CF_setPictureImage("GuestActive", _activeGuestIcon);
                _userName = guestUsername;
                _password = guestPassword;
                RefreshStations();
            }
        }