private void GetStartupState()
{
Uri optFileName = new Uri(AppDomain.CurrentDomain.BaseDirectory + "designerstate.xml");
_RecentFiles = new SortedList<DateTime, string>();
_CurrentFiles = new List<Uri>();
_HelpUrl = DefaultHelpUrl; // set as default
_SupportUrl = DefaultSupportUrl;
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.PreserveWhitespace = false;
xDoc.Load(optFileName.AbsoluteUri);
XmlNode xNode;
xNode = xDoc.SelectSingleNode("//designerstate");
string[] args = Environment.GetCommandLineArgs();
for (int i = 1; i < args.Length; i++)
{
string larg = args[i].ToLower();
if (larg == "/m" || larg == "-m")
continue;
if (File.Exists(args[i])) // only add it if it exists
{
_CurrentFiles.Add(new Uri(args[i]));
}
}
// Loop thru all the child nodes
foreach (XmlNode xNodeLoop in xNode.ChildNodes)
{
switch (xNodeLoop.Name)
{
case "RecentFiles":
DateTime now = DateTime.Now;
now = now.Subtract(new TimeSpan(0, 1, 0, 0, 0)); // subtract an hour
foreach (XmlNode xN in xNodeLoop.ChildNodes)
{
Uri file = new Uri(xN.InnerText.Trim());
if (File.Exists(file.LocalPath)) // only add it if it exists
{
_RecentFiles.Add(now, file.LocalPath);
now = now.AddSeconds(1);
}
}
break;
case "RecentFilesMax":
try
{
this._RecentFilesMax = Convert.ToInt32(xNodeLoop.InnerText);
}
catch
{
this._RecentFilesMax = 5;
}
break;
case "CurrentFiles":
if (_CurrentFiles.Count > 0) // don't open other current files if opened with argument
break;
foreach (XmlNode xN in xNodeLoop.ChildNodes)
{
Uri file = new Uri(xN.InnerText.Trim());
if (File.Exists(file.LocalPath)) // only add it if it exists
{
_CurrentFiles.Add(file);
}
}
break;
case "Toolbar":
_Toolbar = new List<string>();
foreach (XmlNode xN in xNodeLoop.ChildNodes)
{
string item = xN.InnerText.Trim();
_Toolbar.Add(item);
}
break;
case "Help":
if (xNodeLoop.InnerText.Length > 0) //empty means to use the default
_HelpUrl = xNodeLoop.InnerText;
break;
case "Support":
if (xNodeLoop.InnerText.Length > 0) //empty means to use the default
_SupportUrl = xNodeLoop.InnerText;
break;
case "EditLines":
_ShowEditLines = (xNodeLoop.InnerText.ToLower() == "true");
break;
case "ShowPreviewWaitDialog":
_ShowPreviewWaitDialog = (xNodeLoop.InnerText.ToLower() == "true");
break;
case "OutlineReportItems":
this.ShowReportItemOutline = (xNodeLoop.InnerText.ToLower() == "true");
break;
case "ShowTabbedInterface":
this._ShowTabbedInterface = (xNodeLoop.InnerText.ToLower() == "true");
break;
case "PropertiesLocation":
this._PropertiesLocation = GetPropertiesDockStyle(xNodeLoop.InnerText);
break;
case "PropertiesAutoHide":
this._PropertiesAutoHide = (xNodeLoop.InnerText.ToLower() == "true");
break;
case "MapSubtypes":
RdlDesigner.MapSubtypes = xNodeLoop.InnerText.Split(new char[] { ',' });
break;
case "CustomColors":
break;
default:
break;
}
}
}
catch (Exception ex)
{ // Didn't sucessfully get the startup state but don't really care
Console.WriteLine(string.Format("Exception in GetStartupState ignored.\n{0}\n{1}", ex.Message, ex.StackTrace));
}
if (_Toolbar == null) // Use this as the default toolbar
_Toolbar = this.ToolbarDefault;
return;
}