Example #1
0
        private async Task NavigateBackAsync()
        {
            if (_currentFolder != null)
            {
                IOneDriveStorageFolder currentFolder = null;
                Shell.Current.DisplayWaitRing = true;
                try
                {
                    if (!string.IsNullOrEmpty(_currentFolder.Path))
                    {
                        currentFolder = await _rootFolder.GetFolderAsync(_currentFolder.Path);
                    }
                    else
                    {
                        currentFolder = _rootFolder;
                    }

                    OneDriveItemsList.ItemsSource = currentFolder.GetItemsAsync();
                    _currentFolder = currentFolder;
                }
                catch (ServiceException ex)
                {
                    await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
                }
                finally
                {
                    Shell.Current.DisplayWaitRing = false;
                }
            }
        }
Example #2
0
        private async Task NavigateToFolderAsync(IOneDriveStorageItem item)
        {
            if (item.IsFolder())
            {
                Shell.Current.DisplayWaitRing = true;
                try
                {
                    var currentFolder = await _currentFolder.GetFolderAsync(item.Name);

                    OneDriveItemsList.ItemsSource = currentFolder.GetItemsAsync();
                    _currentFolder = currentFolder;
                }
                catch (ServiceException ex)
                {
                    await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
                }
                finally
                {
                    Shell.Current.DisplayWaitRing = false;
                }
            }
        }
Example #3
0
        private async Task SigninAsync(int indexProvider, string appClientId)
        {
            if (!await Tools.CheckInternetConnectionAsync())
            {
                return;
            }

            Shell.Current.DisplayWaitRing = true;
            bool succeeded = false;

            try
            {
                // OnlineId
                if (indexProvider == 0)
                {
                    OneDriveService.Instance.Initialize();
                }
                else if (indexProvider == 1)
                {
                    OneDriveService.Instance.Initialize(appClientId, AccountProviderType.Msa, OneDriveScopes.OfflineAccess | OneDriveScopes.ReadWrite);
                }
                else if (indexProvider == 2)
                {
                    OneDriveService.Instance.Initialize(appClientId, AccountProviderType.Adal);
                }
                else if (indexProvider == 3)
                {
                    OneDriveService.Instance.Initialize(appClientId, AccountProviderType.Msal);
                }

                if (!await OneDriveService.Instance.LoginAsync())
                {
                    throw new Exception("Unable to sign in");
                }

                _currentFolder = _rootFolder = await OneDriveService.Instance.RootFolderAsync();

                OneDriveItemsList.ItemsSource = _rootFolder.GetItemsAsync();
                succeeded = true;
            }
            catch (ServiceException serviceEx)
            {
                await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(serviceEx);
            }
            catch (Exception ex)
            {
                await OneDriveSampleHelpers.DisplayMessageAsync(ex.Message);

                TrackingManager.TrackException(ex);
            }
            finally
            {
                Shell.Current.DisplayWaitRing = false;
            }

            if (succeeded)
            {
                FilesBox.Visibility       = Visibility.Visible;
                UserBox.Visibility        = Visibility.Visible;
                ClientIdBox.Visibility    = Visibility.Collapsed;
                ClientIdHelper.Visibility = Visibility.Collapsed;
                LogOutButton.Visibility   = Visibility.Visible;
                ConnectButton.Visibility  = Visibility.Collapsed;
                menuButton.Visibility     = Visibility.Visible;
                BackButton.Visibility     = Visibility.Visible;
            }
            else
            {
                FilesBox.Visibility       = Visibility.Collapsed;
                UserBox.Visibility        = Visibility.Collapsed;
                ClientIdBox.Visibility    = Visibility.Visible;
                ClientIdHelper.Visibility = Visibility.Visible;
                LogOutButton.Visibility   = Visibility.Collapsed;
                ConnectButton.Visibility  = Visibility.Visible;
                menuButton.Visibility     = Visibility.Collapsed;
                BackButton.Visibility     = Visibility.Collapsed;
            }
        }