private void OnTaskFinished()
        {
            if (_walkAwayBox != null && _walkAwayBox.Visible)
            {
                _walkAwayBox.Close();
            }

            if (!_currentTargetStatus.Aborted && _currentTargetStatus.Configuration.PreferQuiet)
            {
                var failedSilent = _currentTargetStatus.AllUninstallersList
                                   .Where(x => x.CurrentStatus == UninstallStatus.Failed && x.IsSilentPossible).ToList();
                if (failedSilent.Count > 0 && MessageBoxes.AskToRetryFailedQuietAsLoud(this, failedSilent.Select(x => x.UninstallerEntry.DisplayName)))
                {
                    foreach (var uninstallEntry in failedSilent)
                    {
                        uninstallEntry.Reset();
                        uninstallEntry.IsSilentPossible = false;
                    }
                    objectListView1.UpdateObjects(failedSilent);
                    objectListView1.BuildGroups();
                    _currentTargetStatus.Start();
                    return;
                }
            }

            label1.Text         = Localisable.UninstallProgressWindow_TaskDone;
            progressBar1.Value  = progressBar1.Maximum;
            buttonClose.Text    = Buttons.ButtonClose;
            buttonClose.Enabled = true;
        }
 private void CustomMessageBox(string title, string message)
 {
     CustomMessageBox mb = new CustomMessageBox();
     mb.Title = title;
     mb.Message = message;
     mb.ShowDialog();
     mb.Close();
 }
        public void FixGridSquareNames()
        {
            if (!settings.GridSquareNamesFixed.Value)
            {
                var gridSquares = dataRepository.GetAllGridSquares();

                bool hasUnfixedGridSqures = false;

                // Do we have any unfixed grid squares?
                if (gridSquares != null && gridSquares.Count > 0)
                {
                    foreach (GridSquare gridSquare in gridSquares)
                    {
                        if (gridSquare.Fixed == 0)
                        {
                            hasUnfixedGridSqures = true;
                            break;
                        }
                    }
                }

                // If there are no grid squres to fix, we don't need to do anything
                if (!hasUnfixedGridSqures)
                {
                    settings.GridSquareNamesFixed = true;
                    settingsService.SaveSettings(settings);
                }
                else
                {
                    var pleaseWaitBox = new CustomMessageBox("Please Wait.\nThis may take a while if you have lots of existing AeroScenery downloads.",
                                                             "AeroScenery",
                                                             MessageBoxIcon.Information);

                    pleaseWaitBox.Show();


                    var sb = new StringBuilder();
                    sb.AppendLine("*** PLEASE READ ***");
                    sb.AppendLine("Previous versions of AeroScenery got the hex value of Aerofly tiles wrong.");
                    sb.AppendLine("");
                    sb.AppendLine("Entries in the AeroScenery database will be renamed.");
                    sb.AppendLine("");
                    sb.AppendLine(string.Format("Relevant directories will be renamed under the folder {0}", settings.WorkingDirectory));
                    sb.AppendLine("Nothing will be changed in your Aerofly install or Aerofly user folders.");
                    sb.AppendLine("");
                    sb.AppendLine("Please make sure all files and Explorer windows are closed relating to the directory");
                    sb.AppendLine(string.Format("{0}", settings.WorkingDirectory));

                    var messageBox = new CustomMessageBox(sb.ToString(),
                                                          "AeroScenery",
                                                          MessageBoxIcon.Warning);

                    messageBox.SetButtons(
                        new string[] { "OK", "Cancel" },
                        new DialogResult[] { DialogResult.OK, DialogResult.Cancel });


                    var result = messageBox.ShowDialog();

                    switch (result)
                    {
                    case DialogResult.OK:

                        failedCount = 0;

                        this.DoFirstDirectoryRename(gridSquares);

                        if (failedCount == 0)
                        {
                            var sb2 = new StringBuilder();
                            sb2.AppendLine(string.Format("All directories with incorrect names under {0} have been prefixed with an underscore.", settings.WorkingDirectory));
                            sb2.AppendLine("Click OK to continue with the rename process.");

                            var messageBox2 = new CustomMessageBox(sb2.ToString(),
                                                                   "AeroScenery",
                                                                   MessageBoxIcon.Information);

                            var result2 = messageBox2.ShowDialog();

                            if (result2 == DialogResult.OK)
                            {
                                Thread.Sleep(1000);

                                this.DoSecondDirectoryRename(gridSquares);

                                if (failedCount == 0)
                                {
                                    settings.GridSquareNamesFixed = true;
                                    settingsService.SaveSettings(settings);
                                }
                            }
                        }


                        pleaseWaitBox.Close();

                        break;

                    case DialogResult.Cancel:

                        Environment.Exit(0);

                        break;
                    }
                }
            }
        }