Example #1
0
        private void UpdateDynamicUI()
        {
            this.Text = PdnResources.GetString("UpdatesDialog.Text");
            string closeButtonText = PdnResources.GetString("UpdatesDialog.CloseButton.Text");

            this.optionsButton.Text   = PdnResources.GetString("UpdatesDialog.OptionsButton.Text");
            this.moreInfoLink.Text    = PdnResources.GetString("UpdatesDialog.MoreInfoLink.Text");
            this.newVersionLabel.Text = PdnResources.GetString("UpdatesDialog.NewVersionLabel.Text");

            if (this.updatesStateMachine == null || this.updatesStateMachine.CurrentState == null)
            {
                this.infoText.Text            = string.Empty;
                this.continueButton.Text      = string.Empty;
                this.continueButton.Enabled   = false;
                this.continueButton.Visible   = false;
                this.moreInfoLink.Visible     = false;
                this.moreInfoLink.Enabled     = false;
                this.versionNameLabel.Visible = false;
                this.versionNameLabel.Enabled = false;
            }
            else
            {
                UpdatesState currentState = (UpdatesState)this.updatesStateMachine.CurrentState;

                this.infoText.Text          = currentState.InfoText;
                this.continueButton.Text    = currentState.ContinueButtonText;
                this.continueButton.Visible = currentState.ContinueButtonVisible;
                this.continueButton.Enabled = currentState.ContinueButtonVisible;
                this.progressBar.Style      = (currentState.MarqueeStyle == MarqueeStyle.Marquee) ? ProgressBarStyle.Marquee : ProgressBarStyle.Continuous;
                this.progressBar.Visible    = (currentState.MarqueeStyle != MarqueeStyle.None);
                this.progressLabel.Visible  = this.progressBar.Visible;

                if (this.continueButton.Enabled || currentState is ErrorState || currentState is DoneState)
                {
                    closeButtonText = PdnResources.GetString("UpdatesDialog.CloseButton.Text");
                }
                else
                {
                    closeButtonText = PdnResources.GetString("Form.CancelButton.Text");
                }

                if (currentState is ErrorState)
                {
                    Size size          = new Size(this.infoText.Width, 1);
                    Size preferredSize = this.infoText.GetPreferredSize(size);
                    this.infoText.Size = preferredSize;
                }

                INewVersionInfo asInvi = currentState as INewVersionInfo;

                if (asInvi != null)
                {
                    this.versionNameLabel.Text    = asInvi.NewVersionInfo.FriendlyName;
                    this.versionNameLabel.Visible = true;
                    this.versionNameLabel.Enabled = true;
                    this.moreInfoTarget           = new Uri(asInvi.NewVersionInfo.InfoUrl);
                    this.moreInfoLink.Visible     = true;
                    this.moreInfoLink.Enabled     = true;

                    this.newVersionLabel.Visible = true;
                    this.newVersionLabel.Font    = new Font(this.newVersionLabel.Font, this.newVersionLabel.Font.Style | FontStyle.Bold);
                    this.versionNameLabel.Left   = this.newVersionLabel.Right;
                    this.moreInfoLink.Left       = this.versionNameLabel.Left;
                }
                else
                {
                    this.newVersionLabel.Visible  = false;
                    this.versionNameLabel.Visible = false;
                    this.versionNameLabel.Enabled = false;
                    this.moreInfoLink.Visible     = false;
                    this.moreInfoLink.Enabled     = false;
                }
            }

            this.closeButton.Text = closeButtonText;

            Update();
        }