Exemple #1
0
        private async void Login1_Click(object sender, RoutedEventArgs e)
        {
            if (Equator.Properties.Settings.Default.FirstRun)
            {
                CreateSaveLocation();
                CreateSaveThumbLocation();
                CreateSaveUserImageLocation();
                CreateSaveUserCredsLocation();
                Equator.Properties.Settings.Default.FirstRun = false;
                Settings.Default.Save();
            }
#if DEBUG
            CreateSaveLocation();
            CreateSaveThumbLocation();
            CreateSaveUserImageLocation();
            CreateSaveUserCredsLocation();
            Equator.Properties.Settings.Default.FirstRun = false;
            Settings.Default.Save();
#endif
            if (Directory.GetFiles(FilePaths.UserCredLocation).Length == 0)
            {
                File.Delete(FilePaths.UserImageLocation + "\\Userimage.png");
                await GoogleServices.AuthUserCredential(true);
            }
            else
            {
                await GoogleServices.AuthUserCredential(false);
            }
            var window = new MusicPanel();
            GoogleServices.YoutubeService =
                GoogleServices.CreateYoutubeService(GoogleServices.ApiKey, true, GoogleServices.Credential);
            window.Show();
            Close();
        }
        /// <summary>
        ///     Returns a string split into the format "link to the music/video" + "song name"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private async void LeftMouseDown(object sender, MouseButtonEventArgs e)
        {
            MusicCardContent        = (Canvas)sender;
            Play.Opacity            = 100;
            MusicPanel.PlayingSongs = true;
            MusicPanel.PlayedIndiciesBackwards.Add(Index);
            try
            {
                await Music.Music.PlaySpecifiedSong(_backgroundRect, _musicLink, Index, SongTitle.Text, _songLabel,
                                                    _youtubePlayer, _playButton);
            }
            catch (HttpRequestException httpRequestException)
            {
                Console.WriteLine(httpRequestException);
                await GoogleServices.AuthUserCredential(false);

                GoogleServices.YoutubeService =
                    GoogleServices.CreateYoutubeService(GoogleServices.ApiKey, true, GoogleServices.Credential);
                await Music.Music.PlaySpecifiedSong(_backgroundRect, _musicLink, Index, SongTitle.Text, _songLabel,
                                                    _youtubePlayer, _playButton);
            }
        }