in src/Application/FormMain.cs [1405:1512]
public virtual void LoadConfig()
{
string path;
try
{
this._loading = true;
if (this._args != null && this._args.Length > 0)
{
// When user passes arguments we skip the config file
// This is for unit testing where we need consistent config!
path = this._args[0];
this._settings.FileName = this.ConfigFile;
}
else
{
// allow user to have a local settings file (xcopy deployable).
path = this.LocalConfigFile;
if (!File.Exists(path))
{
path = this.ConfigFile;
}
if (File.Exists(path))
{
Debug.WriteLine(path);
_settings.Load(path);
// convert old format to the new one
object oldFont = this._settings["Font"];
if (oldFont is string s && s != "deleted")
{
// migrate old setting to the new setting
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Font));
try
{
Font f = (Font)tc.ConvertFromString(s);
this._settings["FontFamily"] = f.FontFamily.Name;
this._settings["FontSize"] = (double)f.SizeInPoints;
switch (f.Style)
{
case FontStyle.Regular:
this._settings["FontStyle"] = "Normal";
this._settings["FontWeight"] = "Normal";
break;
case FontStyle.Bold:
this._settings["FontStyle"] = "Normal";
this._settings["FontWeight"] = "Bold";
break;
case FontStyle.Italic:
this._settings["FontStyle"] = "Italic";
this._settings["FontWeight"] = "Normal";
break;
case FontStyle.Underline:
break;
case FontStyle.Strikeout:
break;
default:
break;
}
this.Font = this.xmlTreeView1.Font = f;
this._settings.Remove("Font");
}
catch { }
}
else
{
// convert serialized settings to a winforms Font object.
this._settings.Remove("Font");
this.Font = this.xmlTreeView1.Font = this.GetFont();
}
var lightColors = _settings.AddDefaultColors("LightColors", ColorTheme.Light);
if (lightColors.EditorBackground == Color.LightSteelBlue)
{
// migrate to new default that looks better.
lightColors.EditorBackground = Color.FromArgb(255, 250, 205); // lemon chiffon.
}
_settings.AddDefaultColors("DarkColors", ColorTheme.Dark);
string newLines = (string)this._settings["NewLineChars"];
Uri location = (Uri)this._settings["FileName"];
// Load up the last file we were editing before - if it is local and still exists.
if (location != null && location.OriginalString != "/" && location.IsFile && File.Exists(location.LocalPath))
{
path = location.LocalPath;
}
string updates = (string)this._settings["UpdateLocation"];
if (string.IsNullOrEmpty(updates) ||
updates.Contains("download.microsoft.com") ||
updates.Contains("lovettsoftware.com"))
{
this._settings["UpdateLocation"] = XmlNotepad.Settings.DefaultUpdateLocation;
}
}
}
}
finally
{
this._loading = false;
}
CheckAnalytics();
InitializeXsltViewer();
InitializeHelpViewer();
}