Ejemplo n.º 1
0
        private void UpdateDynamicUI()
        {
            this.Text                 = PdnResources.GetString("UpdatesDialog.Text");
            this.closeButton.Text     = 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)
                {
                    this.closeButton.Text = PdnResources.GetString("UpdatesDialog.CloseButton.Text");
                }
                else
                {
                    this.closeButton.Text = 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;
                }
            }

            Update();
        }
Ejemplo n.º 2
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            UpdatesState currentState;
            int          bottom;

            this.layoutQueued = false;
            if (!this.setFonts && base.IsHandleCreated)
            {
                this.setFonts = true;
                this.versionNameLabel.Font = new Font(this.Font.FontFamily, this.Font.Size * 1.25f, FontStyle.Regular);
            }
            this.Text = PdnResources.GetString("UpdatesDialog.Text");
            string str = PdnResources.GetString("UpdatesDialog.CloseButton.Text");

            this.moreInfoLink.Text = PdnResources.GetString("UpdatesDialog.MoreInfoLink.Text");
            if ((this.updatesStateMachine == null) || (this.updatesStateMachine.CurrentState == null))
            {
                currentState = null;
            }
            else
            {
                currentState = (UpdatesState)this.updatesStateMachine.CurrentState;
            }
            INewVersionInfo info = currentState as INewVersionInfo;

            if (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;
                goto Label_0265;
            }
            if (currentState is ReadyToInstallState)
            {
                ((ReadyToInstallState)currentState).InstallingOnExit = this.InstallingOnExit;
            }
            if ((currentState is ReadyToInstallState) || (currentState is UpdateAvailableState))
            {
                using (Icon icon = UIUtil.GetStockIcon(UIUtil.StockIcon.Shield, UIUtil.StockIconFlags.SmallIcon))
                {
                    this.continueButton.Image = icon.ToBitmap();
                    goto Label_017B;
                }
            }
            this.continueButton.Image = null;
Label_017B:
            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))
            {
                str = PdnResources.GetString("UpdatesDialog.CloseButton.Text");
            }
            else
            {
                str = PdnResources.GetString("Form.CancelButton.Text");
            }
            if (info != null)
            {
                this.versionNameLabel.Text = info.NewVersionInfo.FriendlyName;
                this.moreInfoTarget        = new Uri(info.NewVersionInfo.InfoUrl);
            }
Label_0265:
            this.closeButton.Text = str;
            int  num   = UIUtil.ScaleWidth(8);
            int  num2  = UIUtil.ScaleHeight(8);
            int  x     = UIUtil.ScaleWidth(8);
            int  y     = UIUtil.ScaleHeight(8);
            int  num5  = UIUtil.ScaleWidth(8);
            int  num6  = Math.Max(0, num2);
            int  width = (base.ClientSize.Width - x) - num5;
            Size size  = UIUtil.ScaleSize(0x55, 0x18);
            int  num9  = base.IsGlassEffectivelyEnabled ? -1 : x;

            this.infoText.Location = new Point(x, y);
            this.infoText.Width    = width;
            this.infoText.Size     = this.infoText.GetPreferredSize(this.infoText.Width, 1);
            if (((currentState is UpdateAvailableState) || (currentState is DownloadingState)) || ((currentState is ReadyToInstallState) || (info != null)))
            {
                this.versionNameLabel.Size    = this.versionNameLabel.GetPreferredSize(width, 1);
                this.versionNameLabel.Enabled = true;
                this.versionNameLabel.Visible = true;
                this.moreInfoLink.Size        = this.moreInfoLink.GetPreferredSize(width, 1);
                this.moreInfoLink.Enabled     = true;
                this.moreInfoLink.Visible     = true;
            }
            else
            {
                this.versionNameLabel.Size    = new Size(width, 0);
                this.versionNameLabel.Enabled = false;
                this.versionNameLabel.Visible = false;
                this.moreInfoLink.Size        = new Size(width, 0);
                this.moreInfoLink.Enabled     = false;
                this.moreInfoLink.Visible     = false;
            }
            this.versionNameLabel.Location = new Point(this.infoText.Left, this.infoText.Bottom + num2);
            if ((width - this.versionNameLabel.Width) < (num + this.moreInfoLink.Width))
            {
                this.moreInfoLink.Location = new Point(this.versionNameLabel.Left, this.versionNameLabel.Bottom + (num2 / 2));
            }
            else
            {
                this.moreInfoLink.Location = new Point(this.versionNameLabel.Right + num, (this.versionNameLabel.Bottom - this.moreInfoLink.Height) - 1);
            }
            int num10 = this.versionNameLabel.Visible ? (this.moreInfoLink.Bottom + ((num2 * 3) / 2)) : (this.infoText.Bottom + num2);

            if (((currentState is CheckingState) || (currentState is DownloadingState)) || (currentState is ExtractingState))
            {
                if (currentState is CheckingState)
                {
                    this.progressLabel.Enabled = false;
                    this.progressLabel.Visible = false;
                }
                else
                {
                    this.progressLabel.Enabled = true;
                    this.progressLabel.Visible = true;
                }
                this.progressBar.Enabled = true;
                this.progressBar.Visible = true;
            }
            else
            {
                this.progressLabel.Enabled = false;
                this.progressLabel.Visible = false;
                this.progressBar.Enabled   = false;
                this.progressBar.Visible   = false;
            }
            this.progressLabel.Size = this.progressLabel.GetPreferredSize(width, 1);
            if (!this.progressLabel.Visible)
            {
                this.progressLabel.Width = 0;
            }
            this.progressLabel.Location = new Point((base.ClientSize.Width - num5) - this.progressLabel.Width, num10);
            this.progressBar.Location   = new Point(x, this.progressLabel.Top + ((this.progressLabel.Height - this.progressBar.Height) / 2));
            this.progressBar.Height     = UIUtil.ScaleHeight(0x12);
            this.progressBar.Width      = this.progressLabel.Visible ? ((this.progressLabel.Left - x) - num) : width;
            int[] vals  = new int[] { this.versionNameLabel.Visible ? (this.versionNameLabel.Bottom + (num2 / 2)) : 0, this.moreInfoLink.Visible ? this.moreInfoLink.Bottom : 0, this.progressLabel.Visible ? this.progressLabel.Bottom : 0, this.progressBar.Visible ? this.progressBar.Bottom : 0 };
            int   num11 = num2 + Int32Util.Max(this.infoText.Bottom, vals);

            this.separator.Location = new Point(x, num11);
            this.separator.Size     = this.separator.GetPreferredSize(width, 1);
            if ((currentState is ReadyToInstallState) || (currentState is UpdateAvailableState))
            {
                this.closeButton.Enabled    = false;
                this.closeButton.Visible    = false;
                this.continueButton.Enabled = true;
                this.continueButton.Visible = true;
                this.continueButton.Size    = size;
                this.continueButton.PerformLayout();
                this.continueButton.Location = new Point((base.ClientSize.Width - num9) - this.continueButton.Width, this.separator.Bottom + num2);
                bottom = this.continueButton.Bottom;
            }
            else
            {
                this.closeButton.Enabled = true;
                this.closeButton.Visible = true;
                this.closeButton.Size    = size;
                this.closeButton.PerformLayout();
                this.closeButton.Location   = new Point((base.ClientSize.Width - num9) - this.closeButton.Width, this.separator.Bottom + num2);
                this.continueButton.Enabled = false;
                this.continueButton.Visible = false;
                bottom = this.closeButton.Bottom;
            }
            base.ClientSize = new Size(base.ClientSize.Width, bottom + num6);
            if (base.IsGlassEffectivelyEnabled)
            {
                this.separator.Visible = false;
                base.GlassInset        = new Padding(0, 0, 0, base.ClientSize.Height - this.separator.Top);
            }
            else
            {
                this.separator.Visible = true;
                base.GlassInset        = new Padding(0);
            }
            base.OnLayout(levent);
        }