/**
         * Modifies the UT2settings.cfg file.
         */
        protected bool ModifyUT2Settings(System.Timers.Timer timer)
        {
            string file = FilesHandler.GetApplicationDataPath() + @"\Flight One Software\Ultimate Traffic 2\UT2settings.cfg";

            if (!File.Exists(file))
            {
                return(false);
            }

            List <string> fileContent    = Helper.GetTextFileContent(file);
            List <string> newFileContent = new List <string>();

            string newLine = "FSX Location=" + migrateTarget.GetSimPath();

            foreach (string line in fileContent)
            {
                if (!line.Contains("FSX Location"))
                {
                    newFileContent.Add(line);
                    continue;
                }

                if (line.Equals(newLine))
                {
                    timer.Stop();

                    try
                    {
                        timers.Remove(timer);
                    }
                    catch (Exception)
                    {
                    }

                    return(true);
                }
            }

            newFileContent.Add(newLine);

            Helper.SetTextFileContent(file, newFileContent);

            return(true);
        }
示例#2
0
        /**
         * Sets the path of the source simulator as the target.
         */
        public static bool SetSourceAsTarget()
        {
            SimulatorOption sourceOption = MainFormHandler.GetSelectedSourceSimulator();
            SimulatorOption targetOption = MainFormHandler.GetSelectedTargetSimulator();

            if (sourceOption == null || targetOption == null)
            {
                return(false);
            }

            string targetPath    = targetOption.GetSimPath();
            int    registryIndex = 0;

            foreach (string registryPath in sourceOption.GetRegistryPaths())
            {
                string sourcePath = RegistryInterface.GetRegistryValue(registryPath);
                RegistryInterface.SetRegistryValue(registryPath, targetPath, true);

                string log = "";

                if (!sourcePath.Equals("") && sourcePath != null)
                {
                    log = "1," + sourceOption.GetValue() + "," + registryIndex + "," + sourcePath;
                }
                else
                {
                    log = "1," + sourceOption.GetValue() + "," + registryIndex + ",0";
                }

                HistoryHandler.AppendHistory(log);

                registryIndex++;
            }

            return(true);
        }