예제 #1
0
파일: Updater.cs 프로젝트: zucatti/VidCoder
        public void PromptToApplyUpdate()
        {
            if (BuildSupportsUpdates)
            {
                // If updates are enabled, and we are the last process instance, prompt to apply the update.
                if (Config.UpdatesEnabled && Utilities.CurrentProcessInstances == 1)
                {
                    // See if the user has already applied the update manually
                    string updateVersion = Config.UpdateVersion;
                    if (!string.IsNullOrEmpty(updateVersion) && Utilities.CompareVersions(updateVersion, Utilities.CurrentVersion) <= 0)
                    {
                        // If we already have the newer version clear all the update info and cancel
                        ClearUpdateMetadata();
                        DeleteUpdatesFolder();
                        return;
                    }

                    string installerPath = Config.UpdateInstallerLocation;

                    if (installerPath != string.Empty && File.Exists(installerPath))
                    {
                        // An update is ready, to give a prompt to apply it.
                        var updateConfirmation = new ApplyUpdateConfirmation();
                        updateConfirmation.Owner = Ioc.Container.GetInstance <View.MainWindow>();
                        updateConfirmation.ShowDialog();

                        if (updateConfirmation.Result == "Yes")
                        {
                            this.ApplyUpdate();
                        }
                        else if (updateConfirmation.Result == "Disable")
                        {
                            Config.UpdatesEnabled = false;
                        }
                    }
                    else
                    {
                        if (updateDownloader != null)
                        {
                            updateDownloader.CancelAsync();
                        }
                    }
                }
            }
        }
예제 #2
0
        public bool PromptToApplyUpdate(bool relaunchWhenComplete)
        {
            if (Utilities.SupportsUpdates)
            {
                // If updates are enabled, and we are the last process instance, prompt to apply the update.
                if (Config.UpdatesEnabled && Utilities.CurrentProcessInstances == 1)
                {
                    // See if the user has already applied the update manually
                    Version updateVersion;
                    if (Version.TryParse(Config.UpdateVersion, out updateVersion) && updateVersion.FillInWithZeroes() <= Utilities.CurrentVersion)
                    {
                        // If we already have the newer version clear all the update info and cancel
                        ClearUpdateMetadata();
                        DeleteUpdatesFolder();
                        return(false);
                    }

                    string installerPath = Config.UpdateInstallerLocation;

                    if (installerPath != string.Empty && File.Exists(installerPath))
                    {
                        // An update is ready, to give a prompt to apply it.
                        var updateConfirmation = new ApplyUpdateConfirmation();
                        updateConfirmation.Owner = StaticResolver.Resolve <View.Main>();
                        updateConfirmation.ShowDialog();

                        if (updateConfirmation.Result == "Yes")
                        {
                            this.ApplyUpdate(relaunchWhenComplete);
                            return(true);
                        }
                        else if (updateConfirmation.Result == "Disable")
                        {
                            Config.UpdatesEnabled = false;
                        }
                    }
                    else
                    {
                        this.updateDownloadCancellationTokenSource?.Cancel();
                    }
                }
            }

            return(false);
        }
예제 #3
0
파일: Updater.cs 프로젝트: Runcy/VidCoder
		public void PromptToApplyUpdate()
		{
			if (BuildSupportsUpdates)
			{
				// If updates are enabled, and we are the last process instance, prompt to apply the update.
				if (Config.UpdatesEnabled && Utilities.CurrentProcessInstances == 1)
				{
					// See if the user has already applied the update manually
					string updateVersion = Config.UpdateVersion;
					if (!string.IsNullOrEmpty(updateVersion) && Utilities.CompareVersions(updateVersion, Utilities.CurrentVersion) <= 0)
					{
						// If we already have the newer version clear all the update info and cancel
						ClearUpdateMetadata();
						DeleteUpdatesFolder();
						return;
					}

					string installerPath = Config.UpdateInstallerLocation;

					if (installerPath != string.Empty && File.Exists(installerPath))
					{
						// An update is ready, to give a prompt to apply it.
						var updateConfirmation = new ApplyUpdateConfirmation();
						updateConfirmation.Owner = Ioc.Container.GetInstance<View.MainWindow>();
						updateConfirmation.ShowDialog();

						if (updateConfirmation.Result == "Yes")
						{
							this.ApplyUpdate();
						}
						else if (updateConfirmation.Result == "Disable")
						{
							Config.UpdatesEnabled = false;
						}
					}
					else
					{
						if (updateDownloader != null)
						{
							updateDownloader.CancelAsync();
						}
					}
				}
			}
		}