Example #1
0
        public CallerSetting()
        {
            _xDoc.RemoveAll();
            if (!Sldr.IsInitialized)
            {
                Sldr.Initialize(true);
            }
            WritingSystem = new WritingSystemDefinition();
            Caller        = DataCreator.Creator;
            switch (Caller)
            {
            case DataCreator.CreatorProgram.Paratext8:
                _dataFolder = RegistryHelperLite.FallbackStringValue("Paratext/8", "Settings_Directory");
                break;

            case DataCreator.CreatorProgram.Paratext7:
                _dataFolder = RegistryHelperLite.FallbackStringValue("ScrChecks/1.0/Settings_Directory");
                break;

            case DataCreator.CreatorProgram.FieldWorks8:
                _dataFolder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/8", "ProjectsDir");
                SetupLdmlFolder();
                break;

            case DataCreator.CreatorProgram.FieldWorks9:
                _dataFolder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/9", "ProjectsDir");
                SetupLdmlFolder();
                break;
            }
            if (Caller != DataCreator.CreatorProgram.Unknown)
            {
                return;
            }
            FindDataFolder();
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the directory for the ConTeXt software for the XeTeX back end.
        /// </summary>
        ///
        /// <returns>
        /// name or the directory or string.Empty if the directory name isn't in the registry.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public static string GetCtxDir()
        {
            object regObj;

            if (RegistryHelperLite.RegEntryExists(RegistryHelperLite.CompanyKeyLocalMachine,
                                                  "PwCtx", "ConTeXtDir", out regObj))
            {
                return((string)regObj);
            }
            return("");
        }
Example #3
0
        private static bool HasPathwayExportBatchRegistryValueForCurrentUserRegistry()
        {
            bool isAvailable = false;

            try
            {
                object regObj;
                if (RegistryHelperLite.RegEntryExists(RegistryHelperLite.CompanyKeyCurrentUser,
                                                      "Pathway", "PathwayExportBatch", out regObj))
                {
                    isAvailable = true;
                }
            }
            catch
            {
            }
            return(isAvailable);
        }
Example #4
0
        public static string GetSettingFilePathForParatext(string database)
        {
            // (Note that PathwayB _might_ have a project file we can poke at - no guarantee)
            object paraTextprojectPath;
            string ssfFile = database + ".ssf";

            if (Common.UnixVersionCheck())
            {
                string userName     = Environment.UserName;
                string registryPath = "/home/" + userName +
                                      "/.config/paratext/registry/LocalMachine/software/scrchecks/1.0/settings_directory/";
                while (Directory.Exists(registryPath))
                {
                    if (File.Exists(Common.PathCombine(registryPath, "values.xml")))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(Common.PathCombine(registryPath, "values.xml"));
                        paraTextprojectPath = doc.InnerText;
                        Environment.SetEnvironmentVariable("ParatextProjPath", paraTextprojectPath.ToString());
                        return(Common.PathCombine(paraTextprojectPath.ToString(), ssfFile));
                    }
                    //string ParatextProjectPath = Environment.GetEnvironmentVariable("ParatextProjPath");
                }
            }
            else
            {
                if (RegistryHelperLite.RegEntryExists(RegistryHelperLite.ParatextKey,
                                                      "Settings_Directory", "", out paraTextprojectPath))
                {
                    string settingFilePath = Common.PathCombine((string)paraTextprojectPath, ssfFile);
                    if (File.Exists(settingFilePath))
                    {
                        return(settingFilePath);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
            }
            // not found on logical drives.
            Debug.WriteLine(ssfFile + " does not exist.");
            return(string.Empty);
        }
Example #5
0
        private static bool GetPathwayInstallerDirectoryForLocalMachineRegistry(out string pathwayDir)
        {
            bool isAvailable = false;

            pathwayDir = null;
            try
            {
                object regObj;
                if (RegistryHelperLite.RegEntryExists(RegistryHelperLite.CompanyKeyLocalMachine,
                                                      "Pathway", "PathwayDir", out regObj))
                {
                    Common.SupportFolder = "";
                    pathwayDir           = (string)regObj;
                    isAvailable          = true;
                }
            }
            catch
            {
            }
            return(isAvailable);
        }
Example #6
0
        public void FindDataFolder()
        {
            if (string.IsNullOrEmpty(DatabaseName))
            {
                return;
            }
            if (!string.IsNullOrEmpty(_dataFolder))
            {
                return;
            }
            var folder = RegistryHelperLite.FallbackStringValue("Paratext/8", "Settings_Directory");

            if (!string.IsNullOrEmpty(folder))
            {
                if (TestFolder(folder, DataCreator.CreatorProgram.Paratext8))
                {
                    return;
                }
            }
            folder = RegistryHelperLite.FallbackStringValue("ScrChecks/1.0/Settings_Directory");
            if (!string.IsNullOrEmpty(folder))
            {
                if (TestFolder(folder, DataCreator.CreatorProgram.Paratext7))
                {
                    return;
                }
            }
            folder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/8", "ProjectsDir");
            if (!string.IsNullOrEmpty(folder))
            {
                TestFolder(folder, DataCreator.CreatorProgram.FieldWorks8);
            }
            folder = RegistryHelperLite.FallbackStringValue("SIL/FieldWorks/9", "ProjectsDir");
            if (!string.IsNullOrEmpty(folder))
            {
                TestFolder(folder, DataCreator.CreatorProgram.FieldWorks9);
            }
        }
Example #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the directory for the Pathway application.
        /// </summary>
        /// <returns>
        /// name or the directory or string.Empty if the directory name isn't in the registry.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public static string GetPathwayDir()
        {
            string pathwayDir = string.Empty;
            object regObj;

            try
            {
                if (RegistryHelperLite.RegEntryExists(RegistryHelperLite.CompanyKeyCurrentUser,
                                                      "Pathway", "PathwayDir", out regObj))
                {
                    Common.SupportFolder = "";
                    return((string)regObj);
                }
                if (Path.PathSeparator == '/' || Path.PathSeparator == ':')                 //Test for Linux (see: http://www.mono-project.com/FAQ:_Technical)
                {
                    const string myPathwayDir = "/usr/lib/pathway";
                    RegistryAccess.SetStringRegistryValue("PathwayDir", myPathwayDir);
                    Common.SupportFolder = "";
                    return(myPathwayDir);
                }
                if (GetPathwayInstallerDirectoryForCurrentUserRegistry(out pathwayDir))
                {
                    return(pathwayDir);
                }

                if (GetPathwayInstallerDirectoryForLocalMachineRegistry(out pathwayDir))
                {
                    return(pathwayDir);
                }

                string pathwayInstalledLocation = "C:\\Program Files (x86)\\SIL\\Pathway7\\";
                if (Directory.Exists(pathwayInstalledLocation))
                {
                    Common.SupportFolder = "";
                    return(pathwayInstalledLocation);
                }

                pathwayInstalledLocation = "C:\\Program Files\\SIL\\Pathway7\\";
                if (Directory.Exists(pathwayInstalledLocation))
                {
                    Common.SupportFolder = "";
                    return(pathwayInstalledLocation);
                }

                var fwKey = RegistryHelperLite.CompanyKeyLocalMachine.OpenSubKey("FieldWorks");
                if (fwKey != null)
                {
                    if (!RegistryHelperLite.RegEntryExists(fwKey, "8.0", "RootCodeDir", out regObj))
                    {
                        if (!RegistryHelperLite.RegEntryExists(fwKey, "7.0", "RootCodeDir", out regObj))
                        {
                            if (!RegistryHelperLite.RegEntryExists(fwKey, "", "RootCodeDir", out regObj))
                            {
                                regObj = string.Empty;
                            }
                        }
                    }
                    pathwayDir = (string)regObj;
                    // The next line helps those using the developer version of FieldWorks
                    pathwayDir = pathwayDir.Replace("DistFiles", @"Output\Debug").Replace("distfiles", @"Output\Debug");
                }
                if (!File.Exists(Common.PathCombine(pathwayDir, "PsExport.dll")))
                {
                    pathwayDir = string.Empty;
                }
                if (pathwayDir == string.Empty)
                {
                    pathwayDir = Path.GetDirectoryName(Application.ExecutablePath);
                }
                // If after all this fall back code, we can't find PsExport in the resulting folder, we're in trouble
                //if (!File.Exists(Common.PathCombine(pathwayDir, "PsExport.dll")) && !Common.Testing)
                //    Debug.Fail("Unable to find Pathway directory in registry.");
                // If the Support folder exists, it should be used.
                Common.SupportFolder = Directory.Exists(Common.PathCombine(Path.GetDirectoryName(pathwayDir), "PathwaySupport")) ? "PathwaySupport" : "";
            }
            catch { }
            return(pathwayDir);
        }