Пример #1
0
        /// <summary>
        /// Button action for downloading
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private async void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            HideButtons();
            try
            {
                var progressHandler = new Progress <LiveOperationProgress>(
                    (progress) => { SynchroProgressBar.Value = progress.ProgressPercentage; });
                await OneDriveManager.GetFolderIdAsync();

                StatusBlock.Text  += DateTime.Now.ToString("HH:mm") + " Downloading please wait...\n";
                Cancel2.Visibility = Visibility.Visible;
                await OneDriveManager.DownloadFilesAsync(progressHandler);

                StatusBlock.Text += DateTime.Now.ToString("HH:mm") + " Files were downloaded successfully to Music Directory\n";
            }
            catch (LiveConnectException exception)
            {
                StatusBlock.Text += DateTime.Now.ToString("HH:mm") + " Failed to download files, check your Internet connection.\n";
            }
            catch (System.Threading.Tasks.TaskCanceledException)
            {
                StatusBlock.Text += DateTime.Now.ToString("HH:mm") + " Download of files was cancelled.\n";
            }
            finally
            {
                ShowButtons();
            }
        }
Пример #2
0
        /// <summary>
        /// Live login button action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>


        private async void LiveLoginButton_Click(object sender, RoutedEventArgs e)
        {
            LiveLoginButton.Visibility = Visibility.Collapsed;
            try
            {
                await OneDriveManager.SignInOneDriveAsync();

                await OneDriveManager.GetFolderIdAsync();

                ShowButtons();
                StatusBlock.Text = DateTime.Now.ToString("HH:mm") + " Successfully logged in.\n";
            }
            catch (LiveAuthException ex)
            {
                LiveLoginButton.Content = "Retry";
                HideAllButtons();
                StatusBlock.Text = DateTime.Now.ToString("HH:mm") + " Failed to log in. Try again. \n";
            }
            catch (LiveConnectException ex)
            {
                LiveLoginButton.Content = "Retry";
                HideAllButtons();
                StatusBlock.Text = DateTime.Now.ToString("HH:mm") + " Failed to log in. Try again. \n";
            }
            catch (NullReferenceException)
            {
                LiveLoginButton.Content = "Retry";
                HideAllButtons();
                StatusBlock.Text = DateTime.Now.ToString("HH:mm") + " Failed to log in. Try again. Did You accept the OneDrive license? \n";
            }
            CancelUpload.Visibility = Visibility.Collapsed;
        }
Пример #3
0
        /// <summary>
        /// Delete button action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private async void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await OneDriveManager.GetFolderIdAsync();

                StatusBlock.Text += DateTime.Now.ToString("HH:mm") + " Deleting BBLyrics folder please wait...\n";
                await OneDriveManager.DeleteFolderAsync(OneDriveManager._folderId);

                StatusBlock.Text += DateTime.Now.ToString("HH:mm") + " Folder deleted.\n";
            }
            catch (LiveConnectException exception)
            {
                StatusBlock.Text += DateTime.Now.ToString("HH:mm") + " Failed to delete folder, check your Internet connection.\n";
            }
        }