Esempio n. 1
0
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(AutoUpdater.DownloadUrl))
            {
                MessageBox.Show(this, "The update cannot be done as the download URL is empty.", AutoUpdater.DialogTitle,
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (AutoUpdater.OpenDownloadPage)
            {
                var processStartInfo = new ProcessStartInfo(AutoUpdater.DownloadUrl);

                Process.Start(processStartInfo);
            }
            else
            {
                var downloadDialog = new DownloadUpdate(AutoUpdater.DownloadUrl);

                try
                {
                    downloadDialog.ShowDialog();
                }
                catch (TargetInvocationException)
                {
                }
            }
        }
Esempio n. 2
0
        private void buttonRemindLater_Click(object sender, RoutedEventArgs e)
        {
            if (AutoUpdater.LetUserSelectRemindLater)
            {
                var remindLaterForm = new RemindLater();

                var dialogResult = remindLaterForm.ShowDialog();

                switch (dialogResult)
                {
                case true:
                    AutoUpdater.RemindLaterTimeSpan = remindLaterForm.RemindLaterFormat;
                    AutoUpdater.RemindLaterAt       = remindLaterForm.RemindLaterAt;
                    break;

                case false:
                    var downloadDialog = new DownloadUpdate(AutoUpdater.DownloadUrl);

                    try
                    {
                        downloadDialog.ShowDialog();
                    }
                    catch (TargetInvocationException)
                    {
                        return;
                    }
                    return;

                default:
                    DialogResult = null;
                    return;
                }
            }

            var updateKey = Registry.CurrentUser.CreateSubKey(AutoUpdater.RegistryLocation);

            if (updateKey == null)
            {
                return;
            }

            updateKey.SetValue("version", AutoUpdater.CurrentVersion);
            updateKey.SetValue("skip", 0);

            var remindLaterDateTime = DateTime.Now;

            switch (AutoUpdater.RemindLaterTimeSpan)
            {
            case RemindLaterFormat.Days:
                remindLaterDateTime = DateTime.Now + TimeSpan.FromDays(AutoUpdater.RemindLaterAt);
                break;

            case RemindLaterFormat.Hours:
                remindLaterDateTime = DateTime.Now + TimeSpan.FromHours(AutoUpdater.RemindLaterAt);
                break;

            case RemindLaterFormat.Minutes:
                remindLaterDateTime = DateTime.Now + TimeSpan.FromMinutes(AutoUpdater.RemindLaterAt);
                break;
            }
            updateKey.SetValue("remindlater", remindLaterDateTime.ToString(CultureInfo.CreateSpecificCulture("en-US")));
            SetTimer(remindLaterDateTime);
            updateKey.Close();
        }