Example #1
0
        private async void ButtonTurnOnSynchronization_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            try
            {
                ButtonTurnOnSynchronization.IsLoading = true;

                AccountSession session = await oneDriveClient.AuthenticateAsync();

                if (session.AccountType == AccountType.MicrosoftAccount)
                {
                    ISynchronizer synchronizer = new OneDriveSynchronizer(oneDriveClient);
                    await synchronizer.Setup();

                    mainPage.Navigate(typeof(SetupSynchronizationPage), new object[] { synchronizer, mainPage });
                }
            }
            catch (OneDriveException ex)
            {
                ButtonTurnOnSynchronization.IsLoading = false;

                if (!ex.IsMatch(OneDriveErrorCode.Unauthenticated.ToString()) && !ex.IsMatch(OneDriveErrorCode.AccessDenied.ToString()) && !ex.IsMatch(OneDriveErrorCode.AuthenticationCancelled.ToString()) && !ex.IsMatch(OneDriveErrorCode.AuthenticationFailure.ToString()))
                {
                    MainPage.AddBanner(new Banner(BannerType.Danger, ResourceLoader.GetForCurrentView().GetString("UnknownErrorWhileAuthenticating"), true));
                }
            }
        }
Example #2
0
        private async void ButtonRemoveCloudSynchronization_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            MessageDialog dialog = new MessageDialog(ResourceLoader.GetForCurrentView().GetString("RemoveSynchronizationMessage"), ResourceLoader.GetForCurrentView().GetString("RemoveSynchronizationTitle"));

            dialog.Commands.Add(new UICommand()
            {
                Label = ResourceLoader.GetForCurrentView().GetString("Delete"), Id = 0
            });
            dialog.Commands.Add(new UICommand()
            {
                Label = ResourceLoader.GetForCurrentView().GetString("Cancel"), Id = 1
            });

            dialog.CancelCommandIndex  = 1;
            dialog.DefaultCommandIndex = 1;

            IUICommand selectedCommand = await dialog.ShowAsync();

            if ((int)selectedCommand.Id == 0)
            {
                Banner banner = new Banner();
                bool   result = false;

                try
                {
                    MainPage.ShowLoader(ResourceLoader.GetForCurrentView().GetString("AccountsAreBeingRemovedFromCloud"));

                    ISynchronizer synchronizer = new OneDriveSynchronizer(oneDriveClient);
                    result = await synchronizer.Remove();
                }
                catch (NetworkException)
                {
                    result = false;
                }

                if (result)
                {
                    banner.BannerText  = ResourceLoader.GetForCurrentView().GetString("SynchronizationRemoved");
                    banner.BannerType  = BannerType.Success;
                    banner.Dismissable = true;
                }
                else
                {
                    banner.BannerText  = ResourceLoader.GetForCurrentView().GetString("SynchronizationRemovedError");
                    banner.BannerType  = BannerType.Danger;
                    banner.Dismissable = true;
                }

                MainPage.AddBanner(banner);

                await DisableSynchronization();

                ShowInformation();

                MainPage.HideLoader();
            }
        }