Esempio n. 1
0
        private void ShowUpdatesDialog(bool calledFromExit)
        {
            if (!calledFromExit)
            {
                if (this.installOnExit && ShellUtil.IsActivityQueuedForRestart)
                {
                    ShellUtil.IsActivityQueuedForRestart = false;
                }
                this.installOnExit = false;
            }
            IUpdatesMainFormSite site = this.host.FindMainForm();

            if (site != null)
            {
                site.FormClosing -= new FormClosingEventHandler(this.OnMainFormFormClosing);
            }
            if (this.retryDialogTimer != null)
            {
                this.retryDialogTimer.Enabled = false;
                this.retryDialogTimer.Dispose();
                this.retryDialogTimer = null;
            }
            bool flag = true;
            UpdateAvailableState currentState = this.stateMachineExecutor.CurrentState as UpdateAvailableState;

            if (currentState != null)
            {
                PdnVersionInfo newVersionInfo = currentState.NewVersionInfo;
                string         friendlyName   = newVersionInfo.FriendlyName;
                string         infoUrl        = newVersionInfo.InfoUrl;
                switch (this.AskInstallNowOrOnExit(this.host.UISite.Win32Window, friendlyName, infoUrl))
                {
                case DialogResult.Yes:
                    this.stateMachineExecutor.ProcessInput(UpdatesAction.Continue);
                    flag = true;
                    goto Label_0134;

                case DialogResult.OK:
                {
                    this.stateMachineExecutor.ProcessInput(UpdatesAction.Continue);
                    flag = false;
                    this.installOnExit = true;
                    ShellUtil.IsActivityQueuedForRestart = true;
                    IUpdatesMainFormSite site2 = this.host.FindMainForm();
                    if (site2 != null)
                    {
                        site2.FormClosing += new FormClosingEventHandler(this.OnMainFormFormClosing);
                    }
                    else
                    {
                        flag = true;
                    }
                    goto Label_0134;
                }
                }
                this.stateMachineExecutor.ProcessInput(UpdatesAction.Cancel);
                flag = false;
                this.DisposeUpdates();
            }
Label_0134:
            if (flag)
            {
                IWin32Window window;
                if (this.updatesDialog != null)
                {
                    this.updatesDialog.Close();
                    this.updatesDialog = null;
                }
                this.updatesDialog = new UpdatesDialog();
                this.updatesDialog.InstallingOnExit    = calledFromExit;
                this.updatesDialog.UpdatesStateMachine = this.stateMachineExecutor;
                if (!this.stateMachineExecutor.IsStarted)
                {
                    this.stateMachineExecutor.Start();
                }
                try
                {
                    IntPtr handle = this.host.UISite.Win32Window.Handle;
                    window = this.host.UISite.Win32Window;
                }
                catch (Exception)
                {
                    window = null;
                }
                this.updatesDialog.StartPosition = calledFromExit ? FormStartPosition.CenterScreen : this.updatesDialog.StartPosition;
                this.updatesDialog.ShowInTaskbar = calledFromExit;
                this.updatesDialog.Shown        += (s, e) => UIUtil.FlashForm(this.updatesDialog);
                this.updatesDialog.ShowDialog(window);
                DialogResult dialogResult = this.updatesDialog.DialogResult;
                this.updatesDialog.Dispose();
                this.updatesDialog = null;
                if (((this.stateMachineExecutor != null) && (dialogResult == DialogResult.Yes)) && (this.stateMachineExecutor.CurrentState is ReadyToInstallState))
                {
                    this.stateMachineExecutor.ProcessInput(UpdatesAction.Continue);
                    while (!this.calledFinish)
                    {
                        Application.DoEvents();
                        Thread.Sleep(10);
                    }
                }
            }
        }
        private void ShowUpdatesDialog()
        {
            if (this.retryDialogTimer != null)
            {
                this.retryDialogTimer.Enabled = false;
                this.retryDialogTimer.Dispose();
                this.retryDialogTimer = null;
            }

            this.updatesDialog = new UpdatesDialog();
            this.updatesDialog.UpdatesStateMachine = this.stateMachineExecutor;

            if (!this.stateMachineExecutor.IsStarted)
            {
                //this.stateMachineExecutor.LowPriorityExecution = true;
                this.stateMachineExecutor.Start();
            }

            updatesDialog.ShowDialog(AppWorkspace);
            DialogResult dr = updatesDialog.DialogResult;

            this.updatesDialog.Dispose();
            this.updatesDialog = null;

            if (this.stateMachineExecutor != null)
            {
                if (dr == DialogResult.Yes &&
                    this.stateMachineExecutor.CurrentState is Updates.ReadyToInstallState)
                {
                    this.stateMachineExecutor.ProcessInput(Updates.UpdatesAction.Continue);

                    while (!this.calledFinish)
                    {
                        Application.DoEvents();
                        Thread.Sleep(10);
                    }
                }
            }
        }