Example #1
0
 //Refresh the Tab-List when the Refresh-Button is Clicked.
 private void refreshTabsButton_Click(object sender, EventArgs e)
 {
     //Clear the current items.
     tabSelector.Items.Clear();
     //Get the all tabs from the TabManager and put then into the list.
     foreach (string tab in TabManager.getTabNames(getSelectedSource()))
     {
         tabSelector.Items.Add(tab);
     }
 }
Example #2
0
        //Function for getting the Current song.
        private string getSong()
        {
            //Check which Source is selected.
            switch (_settings.source)
            {
            //If Spotify is selected.
            case SongSource.SPOTIFY:
                //Check if Spotify is Running.
                if (SpotifyLocalAPI.IsSpotifyRunning())
                {
                    //Check if Spotify is Connected.
                    if (_spotify.Connect())
                    {
                        //Check if a Song is playing.
                        if (_spotify.GetStatus().Playing)
                        {
                            //Return the name of the Playing Song.
                            return(_spotify.GetStatus().Track.TrackResource.Name);
                        }
                    }
                }
                return(_settings.invalidSongMessage);

            //If InternetExplorer is selected.
            case SongSource.IE:
                //Get all tabs from the TabManager.
                string[] tabs = TabManager.getTabNames(_settings.source);
                //If the selected tab is in the List.
                if (_selectedTab >= 0 && (_selectedTab + 1) <= tabs.Length)
                {
                    //Get the name of the selected tab.
                    string song = TabManager.getTabNames(_settings.source)[_selectedTab];

                    //Trim Names/Logos from start and end.
                    if (song.EndsWith(" - YouTube"))
                    {
                        song = song.TrimEnd(" - YouTube".ToCharArray());
                    }
                    else if (song.StartsWith("▶ "))
                    {
                        song = song.TrimStart("▶ ".ToCharArray());
                    }

                    //Return the edited tab title.
                    return(song);
                }
                return(_settings.invalidSongMessage);

            default:
                return(_settings.invalidSongMessage);
            }
        }