Ejemplo n.º 1
0
 private void OnStateBegin(object sender, ValueEventArgs <PaintDotNet.Updates.State> e)
 {
     if ((e.Value is UpdateAvailableState) && (this.updatesDialog == null))
     {
         bool flag = true;
         IUpdatesMainFormSite site = this.host.FindMainForm();
         if ((site != null) && !site.IsCurrentModalForm)
         {
             flag = false;
         }
         if (flag)
         {
             this.ShowUpdatesDialog();
         }
         else
         {
             if (this.retryDialogTimer != null)
             {
                 this.retryDialogTimer.Enabled = false;
                 this.retryDialogTimer.Dispose();
                 this.retryDialogTimer = null;
             }
             this.retryDialogTimer          = new System.Windows.Forms.Timer();
             this.retryDialogTimer.Interval = 0xbb8;
             this.retryDialogTimer.Tick    += delegate(object sender2, EventArgs e2) {
                 bool flag = false;
                 if (base.IsDisposed)
                 {
                     flag = true;
                 }
                 IUpdatesMainFormSite site = this.host.FindMainForm();
                 if (site == null)
                 {
                     flag = true;
                 }
                 else if (this.updatesDialog != null)
                 {
                     flag = true;
                 }
                 else if (site.IsCurrentModalForm && site.Enabled)
                 {
                     this.ShowUpdatesDialog();
                     flag = true;
                 }
                 if (flag && (this.retryDialogTimer != null))
                 {
                     this.retryDialogTimer.Enabled = false;
                     this.retryDialogTimer.Dispose();
                     this.retryDialogTimer = null;
                 }
             };
             this.retryDialogTimer.Enabled = true;
         }
     }
     else if ((e.Value is ReadyToCheckState) && (this.updatesDialog == null))
     {
         this.DisposeUpdates();
     }
 }
Ejemplo n.º 2
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);
                    }
                }
            }
        }