Beispiel #1
0
        //public static LibSys.ThreadPool threadPool = null;

        #region Constructor and Executables

        public Project()
        {
            FileInfo myExe = new FileInfo(Project.GetLongPathName(Application.ExecutablePath));

            startupPath           = myExe.Directory.FullName;
            driveProgramInstalled = startupPath.Substring(0, 3);

            string appFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            miscFolderPath = Path.Combine(appFolderPath, PROGRAM_NAME_HUMAN + @"\Misc");
        }
Beispiel #2
0
        public static void ReadOptions()
        {
            string optionsFilePath = GetMiscPath(OPTIONS_FILE_NAME);

#if DEBUG
            LibSys.StatusBar.Trace("IP: Project:ReadOptions() path=" + optionsFilePath);
#endif
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(optionsFilePath);

                // we want to traverse XmlDocument fast, as tile load operations can be numerous
                // and come in pack. So we avoid using XPath and rely mostly on "foreach child":
                foreach (XmlNode nnode in xmlDoc.ChildNodes)
                {
                    if (nnode.Name.Equals("options"))
                    {
                        foreach (XmlNode node in nnode)
                        {
                            string nodeName = node.Name;
                            try
                            {
                                if (nodeName.Equals("mainFormWidth"))
                                {
                                    mainFormWidth = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("mainFormHeight"))
                                {
                                    mainFormHeight = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("mainFormX"))
                                {
                                    mainFormX = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("mainFormY"))
                                {
                                    mainFormY = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("mainFormMaximized"))
                                {
                                    mainFormMaximized = "true".Equals(node.InnerText.ToLower());
                                }
#if DEBUG
                                else if (nodeName.Equals("enableTrace"))
                                {
                                    enableTrace = node.InnerText.ToLower().Equals("true");
                                }
#endif
                                else if (nodeName.Equals("serverMessageLast"))
                                {
                                    serverMessageLast = node.InnerText;
                                }
                                else if (nodeName.Equals("inputSelectedIndex"))
                                {
                                    inputSelectedIndex = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("outputSelectedIndex"))
                                {
                                    outputSelectedIndex = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("inputFile"))
                                {
                                    inputFile = node.InnerText;
                                }
                                else if (nodeName.Equals("outputFile"))
                                {
                                    outputFile = node.InnerText;
                                }
                                else if (nodeName.Equals("inputFormatIndex"))
                                {
                                    inputFormatIndex = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("outputFormatIndex"))
                                {
                                    outputFormatIndex = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("gpsMakeIndex"))
                                {
                                    gpsMakeIndex = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("gpsPort"))
                                {
                                    gpsPort = node.InnerText;
                                }
                                else if (nodeName.Equals("gpsBaudRate"))
                                {
                                    gpsBaudRate = node.InnerText;
                                }
                                else if (nodeName.Equals("gpsNoack"))
                                {
                                    gpsNoack = node.InnerText.ToLower().Equals("true");
                                }
                                else if (nodeName.Equals("GpsBabelExecutable"))
                                {
                                    GpsBabelExecutable = node.InnerText;
                                }
                                else if (nodeName.Equals("QuakeMapExecutable"))
                                {
                                    QuakeMapExecutable = node.InnerText;
                                }
                                else if (nodeName.Equals("QuakeMapStartupDelay"))
                                {
                                    QuakeMapStartupDelay = Convert.ToInt32(node.InnerText);
                                }
                                else if (nodeName.Equals("recentFiles"))
                                {
                                    foreach (XmlNode nnnode in node.ChildNodes)
                                    {
                                        string filename = nnnode.Attributes.GetNamedItem("path").InnerText.Trim();
                                        filename = Project.GetLongPathName(filename);
                                        FileInfo fi = new FileInfo(filename);
                                        if (fi.Exists)
                                        {
                                            Project.recentFiles.Add(filename);
                                        }
                                        else
                                        {
                                            DirectoryInfo di = new DirectoryInfo(filename);
                                            if (di.Exists)
                                            {
                                                Project.recentFiles.Add(filename);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ee)
                            {
                                // bad node - not a big deal...
                                LibSys.StatusBar.Error("Project:ReadOptions() node=" + nodeName + " " + ee.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LibSys.StatusBar.Error("Project:ReadOptions() " + e.Message);
            }
        }