public void Bind()

in sources/Google.Solutions.IapDesktop.Application/Windows/Auth/AuthorizeView.cs [55:176]


        public void Bind(AuthorizeViewModel viewModel, IBindingContext bindingContext)
        {
            //
            // Bind controls.
            //
            this.BindReadonlyObservableProperty(
                c => c.Text,
                viewModel,
                m => m.WindowTitle,
                bindingContext);
            this.introLabel.BindReadonlyObservableProperty(
                c => c.Text,
                viewModel,
                m => m.IntroductionText,
                bindingContext);
            this.spinner.BindReadonlyObservableProperty(
                c => c.Visible,
                viewModel,
                m => m.IsWaitControlVisible,
                bindingContext);
            this.signInButton.BindReadonlyObservableProperty(
                c => c.Visible,
                viewModel,
                m => m.IsSignOnControlVisible,
                bindingContext);
            viewModel.IsSignOnControlVisible.PropertyChanged += (_, __) =>
            {
                if (viewModel.IsSignOnControlVisible.Value)
                {
                    this.signInButton.Focus();
                }
            };

            this.cancelSignInLabel.BindReadonlyObservableProperty(
                c => c.Visible,
                viewModel,
                m => m.IsCancelButtonVisible,
                bindingContext);
            this.cancelSignInLink.BindReadonlyObservableProperty(
                c => c.Visible,
                viewModel,
                m => m.IsCancelButtonVisible,
                bindingContext);
            this.helpLink.BindReadonlyObservableProperty(
                c => c.Visible,
                viewModel,
                m => m.IsCancelButtonVisible,
                bindingContext);
            this.versionLabel.BindReadonlyObservableProperty(
                c => c.Text,
                viewModel,
                m => m.Version,
                bindingContext);

            //
            // Bind sign-in commands.
            //
            this.cancelSignInLink.BindObservableCommand(
                viewModel,
                m => m.CancelSignInCommand,
                bindingContext);
            this.helpLink.BindObservableCommand(
                viewModel,
                m => m.HelpCommand,
                bindingContext);
            this.signInButton.BindObservableCommand(
                viewModel,
                m => m.SignInWithDefaultBrowserCommand,
                bindingContext);
            this.signInWithDefaultBrowserMenuItem.BindObservableCommand(
                viewModel,
                m => m.SignInWithDefaultBrowserCommand,
                bindingContext);
            this.signInWithChromeMenuItem.BindObservableCommand(
                viewModel,
                m => m.SignInWithChromeCommand,
                bindingContext);
            this.signInWithChromeGuestMenuItem.BindObservableCommand(
                viewModel,
                m => m.SignInWithChromeGuestModeCommand,
                bindingContext);
            this.showOptionsToolStripMenuItem.BindObservableCommand(
                viewModel,
                m => m.ShowOptionsCommand,
                bindingContext);

            viewModel.IsAuthorizationComplete.PropertyChanged += (_, __) =>
            {
                if (viewModel.IsAuthorizationComplete.Value)
                {
                    //
                    // We're all set, close the dialog.
                    //
                    this.DialogResult = DialogResult.OK;
                    Close();
                }
            };

            //
            // Hide focus rectangle.
            //
            this.signInButton.NotifyDefault(false);

            if (viewModel.Authorization == null)
            {
                //
                // There's no authorization object yet, so this isn't a
                // reauthorization, but an initial authorization.
                //
                // Try to authorize using saved credentials.
                //
                // NB. Wait until handle has been created so that BeginInvoke
                // calls work properly.
                //
                this.HandleCreated += (_, __) => viewModel
                    .TryLoadExistingAuthorizationCommand
                    .ExecuteAsync(CancellationToken.None)
                    .ContinueWith(
                        t => Debug.Assert(false, "Should never throw an exception"),
                        TaskContinuationOptions.OnlyOnFaulted);
            }
        }