public void Load()
{
try
{
XElement library = SIL.IO.RobustIO.LoadXElement(SettingsFilePath);
Language1Iso639Code = GetValue(library, "Language1Iso639Code", /* old name */GetValue(library, "Language1Iso639Code", ""));
Language2Iso639Code = GetValue(library, "Language2Iso639Code", /* old name */GetValue(library, "National1Iso639Code", "en"));
Language3Iso639Code = GetValue(library, "Language3Iso639Code", /* old name */GetValue(library, "National2Iso639Code", ""));
XMatterPackName = GetValue(library, "XMatterPack", "Factory");
var style = GetValue(library, "PageNumberStyle", "Decimal");
PageNumberStyle = PageNumberStyleKeys.Contains(style) ? style : "Decimal";
BrandingProjectName = GetValue(library, "BrandingProjectName", "Default");
Language1Name = GetValue(library, "Language1Name", /* old name */GetValue(library, "LanguageName", ""));
DefaultLanguage1FontName = GetValue(library, "DefaultLanguage1FontName", GetDefaultFontName());
DefaultLanguage2FontName = GetValue(library, "DefaultLanguage2FontName", GetDefaultFontName());
DefaultLanguage3FontName = GetValue(library, "DefaultLanguage3FontName", GetDefaultFontName());
OneTimeCheckVersionNumber = GetIntegerValue(library, "OneTimeCheckVersionNumber", 0);
IsLanguage1Rtl = GetBoolValue(library, "IsLanguage1Rtl", false);
IsLanguage2Rtl = GetBoolValue(library, "IsLanguage2Rtl", false);
IsLanguage3Rtl = GetBoolValue(library, "IsLanguage3Rtl", false);
Language1LineHeight = GetDecimalValue(library, "Language1LineHeight", 0);
Language2LineHeight = GetDecimalValue(library, "Language2LineHeight", 0);
Language3LineHeight = GetDecimalValue(library, "Language3LineHeight", 0);
Country = GetValue(library, "Country", "");
Province = GetValue(library, "Province", "");
District = GetValue(library, "District", "");
AllowNewBooks = GetBoolValue(library, "AllowNewBooks", true);
IsSourceCollection = GetBoolValue(library, "IsSourceCollection", GetBoolValue(library, "IsShellLibrary" /*the old name*/, GetBoolValue(library, "IsShellMakingProject" /*an even older name*/, false)));
}
catch (Exception e)
{
string settingsContents = "";
try
{
settingsContents = RobustFile.ReadAllText(SettingsFilePath);
}
catch (Exception error)
{
settingsContents = error.Message;
}
Logger.WriteEvent("Contents of "+SettingsFilePath+": /r/n"+ settingsContents);
SIL.Reporting.ErrorReport.NotifyUserOfProblem(e, "There was an error reading the file {0}. Please report this error to the developers. To get access to your books, you should make a new collection, then copy your book folders from this broken collection into the new one, then run Bloom again.",SettingsFilePath);
throw;
}
try
{
string oldcustomCollectionStylesPath = FolderPath.CombineForPath("collection.css");
if(RobustFile.Exists(oldcustomCollectionStylesPath))
{
string newcustomCollectionStylesPath = FolderPath.CombineForPath("customCollectionStyles.css");
RobustFile.Move(oldcustomCollectionStylesPath, newcustomCollectionStylesPath);
}
}
catch (Exception)
{
//ah well, we tried, no big deal, only a couple of beta testers used this old name
}
// Check if we need to do a one time check (perhaps migrate to a new Settings value)
if (OneTimeCheckVersionNumber < kCurrentOneTimeCheckVersionNumber)
{
DoOneTimeCheck();
}
}