Exemplo n.º 1
0
    /** Reads all settings from XML file */
    public static void ReadSettings()
    {
        bool hasSettingsFile = StateStorage.HasData("Settings");

        General     = new GeneralSettings();
        Advanced    = new AdvancedSettings();
        Information = new InformationSettings();

        try {
            if (hasSettingsFile)
            {
                XElement rootNode = StateStorage.LoadXML("Settings");
                if (rootNode == null)
                {
                    Trace.LogWarning("No settings in file, resetting to default");
                    ResetSettings();
                }
                else
                {
                    Trace.Log("Reading settings");
                    General.Load(rootNode.Element("General"));
                    Advanced.Load(rootNode.Element("Advanced"));
                }
            }
            else
            {
                Trace.Log("No settings file present, setting to default");
                ResetSettings();
            }
        } catch (Exception e) {
            Trace.LogWarning("Error while reading settings file:" + e.Message);
            ResetSettings();
        }

        IsLoaded = true;
    }