Пример #1
0
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            if (SelectedJunk.Any(x => x is RegistryJunkNode))
            {
                switch (MessageBoxes.BackupRegistryQuestion())
                {
                case MessageBoxes.PressedButton.Yes:
                    var enus = new CultureInfo("en-US", false).DateTimeFormat;
                    saveFileDialogBackupRegistry.FileName = defaultRegBackupFilename + "_" +
                                                            DateTime.Now.ToString(enus.SortableDateTimePattern.Replace(':', '-').Replace('T', '_'));
                    if (saveFileDialogBackupRegistry.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    break;

                case MessageBoxes.PressedButton.No:
                    break;

                default:
                    return;
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Пример #2
0
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            var filters = SelectedJunk.OfType <DriveJunkNode>().Select(x => x.FullName).ToArray();

            if (!Uninstaller.CheckForRunningProcesses(filters, false, this))
            {
                return;
            }

            if (SelectedJunk.Any(x => !(x is DriveJunkNode)))
            {
                switch (MessageBoxes.BackupRegistryQuestion(this))
                {
                case MessageBoxes.PressedButton.Yes:
                    if (backupDirDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    var dir = Path.Combine(backupDirDialog.SelectedPath, GetUniqueBackupName());
                    try
                    {
                        Directory.CreateDirectory(dir);
                    }
                    catch (Exception ex)
                    {
                        PremadeDialogs.GenericError(ex);
                        goto case MessageBoxes.PressedButton.Yes;
                    }

                    try
                    {
                        FilesystemTools.CompressDirectory(dir);
                    }
                    catch
                    {
                        // Ignore, not important
                    }

                    if (!RunBackup(dir))
                    {
                        return;
                    }

                    break;

                case MessageBoxes.PressedButton.No:
                    break;

                default:
                    return;
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            Enabled = false;
            try
            {
                var filters = SelectedJunk.OfType <FileSystemJunk>().Select(x => x.Path.FullName).Distinct().ToArray();
                if (!AppUninstaller.CheckForRunningProcesses(filters, false, this))
                {
                    return;
                }

                if (SelectedJunk.Any(x => !(x is FileSystemJunk)))
                {
                    if (Settings.Default.BackupLeftovers == YesNoAsk.Ask)
                    {
                        switch (MessageBoxes.BackupRegistryQuestion(this))
                        {
                        case MessageBoxes.PressedButton.Yes:
                            var path = MessageBoxes.SelectFolder(
                                Localisable.JunkRemoveWindow_SelectBackupDirectoryTitle);

                            if (string.IsNullOrEmpty(path))
                            {
                                return;
                            }

                            try
                            {
                                CreateBackup(path);
                                Settings.Default.BackupLeftoversDirectory = path;
                            }
                            catch (OperationCanceledException)
                            {
                                goto case MessageBoxes.PressedButton.Yes;
                            }

                            break;

                        case MessageBoxes.PressedButton.No:
                            break;

                        default:
                            return;
                        }
                    }
                    else if (Settings.Default.BackupLeftovers == YesNoAsk.Yes)
                    {
                        while (true)
                        {
                            if (Directory.Exists(Settings.Default.BackupLeftoversDirectory))
                            {
                                try
                                {
                                    CreateBackup(Settings.Default.BackupLeftoversDirectory);
                                    break;
                                }
                                catch (OperationCanceledException)
                                {
                                }
                            }

                            Settings.Default.BackupLeftoversDirectory =
                                MessageBoxes.SelectFolder(Localisable.JunkRemoveWindow_SelectBackupDirectoryTitle);

                            if (string.IsNullOrEmpty(Settings.Default.BackupLeftoversDirectory))
                            {
                                Settings.Default.BackupLeftoversDirectory = string.Empty;
                                Settings.Default.BackupLeftovers          = YesNoAsk.Ask;
                                return;
                            }
                        }
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            finally
            {
                Enabled = true;
            }
        }
Пример #4
0
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            var filters = SelectedJunk.OfType <FileSystemJunk>().Select(x => x.Path.FullName).Distinct().ToArray();

            if (!Uninstaller.CheckForRunningProcesses(filters, false, this))
            {
                return;
            }

            if (SelectedJunk.Any(x => !(x is FileSystemJunk)))
            {
                if (Settings.Default.BackupLeftovers == YesNoAsk.Ask)
                {
                    switch (MessageBoxes.BackupRegistryQuestion(this))
                    {
                    case MessageBoxes.PressedButton.Yes:
                        if (backupDirDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        try
                        {
                            CreateBackup(backupDirDialog.SelectedPath);
                            Settings.Default.BackupLeftoversDirectory = backupDirDialog.SelectedPath;
                        }
                        catch (OperationCanceledException)
                        {
                            goto case MessageBoxes.PressedButton.Yes;
                        }

                        break;

                    case MessageBoxes.PressedButton.No:
                        break;

                    default:
                        return;
                    }
                }
                else if (Settings.Default.BackupLeftovers == YesNoAsk.Yes)
                {
                    while (true)
                    {
                        var path = Settings.Default.BackupLeftoversDirectory;

                        if (Directory.Exists(path))
                        {
                            try
                            {
                                CreateBackup(backupDirDialog.SelectedPath);
                                Settings.Default.BackupLeftoversDirectory = backupDirDialog.SelectedPath;
                                break;
                            }
                            catch (OperationCanceledException)
                            {
                            }
                        }

                        if (backupDirDialog.ShowDialog() == DialogResult.OK)
                        {
                            Settings.Default.BackupLeftoversDirectory = backupDirDialog.SelectedPath;
                        }
                        else
                        {
                            Settings.Default.BackupLeftovers = YesNoAsk.Ask;
                            return;
                        }
                    }
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }