Exemplo n.º 1
0
        /// <summary>
        /// Load settings from XML file
        /// </summary>
        /// <param name="path">Xml file path</param>
        public static void LoadXml(string path)
        {
            string XMLtext = Files.Read(path);

            try
            {
                bool save = false;
                // ----- Parse XML to Structure -----
                var      xml = XDocument.Parse(XMLtext);
                XElement settings;
                XElement mainGroup;

                settings = xml.Element("settings");

                // ----- Connection section -----
                mainGroup = settings.Element("connection");
                if (mainGroup != null)
                {
                    if (Connection.Load(mainGroup))
                    {
                        mainGroup = Connection.GetXmlElement();
                        save      = true;
                    }
                }

                // ----- Messages section -----
                mainGroup = settings.Element("messages");
                if (mainGroup != null)
                {
                    Messages.Load(mainGroup);
                }

                // ----- GUI section -----
                mainGroup = settings.Element("GUI");
                if (mainGroup != null)
                {
                    GUI.Load(mainGroup);
                }

                // ----- GUI section -----
                mainGroup = settings.Element("app");
                if (mainGroup != null)
                {
                    App.Load(mainGroup);
                }


                if (save)
                {
                    xml.Save(path);
                }
            }
            catch (Exception)
            {
            }
        }