コード例 #1
0
        /// <summary>
        /// Handles the Click event of the Connect button, this initiates authenticating with
        /// Dropbox and authorizing the application.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void ConnectBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await DropboxOAuth.Authorize();

                await this.SetConnected();
            }
            catch (Exception)
            {
                this.SetDisconnected();
            }
        }
コード例 #2
0
        /// <summary>
        /// Raises the <see cref="E:Activated" /> event.
        /// </summary>
        /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            if (args is WebAuthenticationBrokerContinuationEventArgs)
            {
                try
                {
                    DropboxOAuth.ProcessContinuation((WebAuthenticationBrokerContinuationEventArgs)args);
                }
                catch (Exception)
                {
                    // authentication was cancelled or failed, there's no useful way to surface this
                    // information.
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Handles the Click event on the setting app bar button, this displays the
        /// <see cref="SettingsDialog"/> used to manage the Dropbox connection.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void SettingsClick(object sender, RoutedEventArgs args)
        {
            var settings = new SettingsDialog();
            var result   = await settings.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                var app = (App)Application.Current;
                if (string.IsNullOrEmpty(app.AccessToken))
                {
                    DropboxOAuth.AuthorizeAndContinue();
                }
                else
                {
                    app.AccessToken = string.Empty;
                    this.NotConnected.Visibility = Visibility.Visible;
                    this.RefreshButton.IsEnabled = false;
                }
            }
        }