Exemple #1
0
        public DialogResult ConfirmSceneryInstallation(AFS2GridSquare afs2GridSquare)
        {
            var gridSquareDirectory = AeroSceneryManager.Instance.Settings.WorkingDirectory + afs2GridSquare.Name;

            DialogResult result = DialogResult.No;

            // Does this grid square exist
            if (Directory.Exists(gridSquareDirectory))
            {
                // Do we have an Aerofly folder to install into?
                string afsSceneryInstallDirectory = DirectoryHelper.FindAFSSceneryInstallDirectory(AeroSceneryManager.Instance.Settings);

                if (afsSceneryInstallDirectory != null)
                {
                    // Confirm that the user does want to install scenery
                    StringBuilder sb = new StringBuilder();

                    sb.AppendLine("Are you sure you want to install all scenery for this grid square?");
                    sb.AppendLine("Any existing files in the same destination folder will be overwritten.");
                    sb.AppendLine("");
                    sb.AppendLine(String.Format("Destination: {0}", afsSceneryInstallDirectory));

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

                    messageBox.SetButtons(
                        new string[] { "Yes", "No" },
                        new DialogResult[] { DialogResult.Yes, DialogResult.No });

                    result = messageBox.ShowDialog();
                }
                else
                {
                    // Can't find anywhere to install
                    StringBuilder sb = new StringBuilder();

                    sb.AppendLine("Could not find a location to install to.");
                    sb.AppendLine("Either Aerofly FS2 is not installed or your 'My Documents\\Aerofly FS 2' folder has been removed.");

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

                    result = messageBox.ShowDialog();
                }
            }
            else
            {
            }

            return(result);
        }
Exemple #2
0
        public DialogResult?CheckForDuplicateTTCFiles(AFS2GridSquare afs2GridSquare, out List <string> ttcFiles)
        {
            // A null dialog result means that there are no duplicates
            DialogResult?result = null;

            var gridSquareDirectory = AeroSceneryManager.Instance.Settings.WorkingDirectory + afs2GridSquare.Name;

            ttcFiles = this.EnumerateFilesRecursive(gridSquareDirectory, "*.ttc").ToList();

            List <string> ttcFileNames = new List <string>();

            foreach (var ttcFile in ttcFiles)
            {
                var tccFileName = Path.GetFileName(ttcFile);
                ttcFileNames.Add(tccFileName);
            }

            // Check for duplicate ttc files
            if (ttcFileNames.Count != ttcFileNames.Distinct().Count())
            {
                StringBuilder sbDuplicates = new StringBuilder();

                sbDuplicates.AppendLine(String.Format("Duplicate ttc files were found in the folder for grid square ({0})", afs2GridSquare.Name));
                sbDuplicates.AppendLine("This may be because you have downloaded this grid square with multiple map image providers.");
                sbDuplicates.AppendLine("If you continue with the install you may get a mismatched set of ttc files.");

                var duplicatesMessageBox = new CustomMessageBox(sbDuplicates.ToString(),
                                                                "AeroScenery",
                                                                MessageBoxIcon.Warning);

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

                result = duplicatesMessageBox.ShowDialog();
            }

            return(result);
        }
        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;
                    }
                }
            }
        }