ExtTools code clean up

Relates to #291 & #236
This commit is contained in:
Sean Kaim
2016-12-02 12:11:46 -05:00
parent 6eff685b18
commit 9d2bbda2b9

View File

@@ -20,47 +20,59 @@ namespace mRemoteNG.Config.Settings
public void LoadExternalAppsFromXML()
{
var oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProductName + "\\" + SettingsFileInfo.ExtAppsFilesName;
var newPath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.ExtAppsFilesName;
#if !PORTABLE
var oldPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), GeneralAppInfo.ProductName, SettingsFileInfo.ExtAppsFilesName);
#endif
var newPath = Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.ExtAppsFilesName);
var xDom = new XmlDocument();
if (File.Exists(newPath))
{
// TODO: Log message here
xDom.Load(newPath);
}
#if !PORTABLE
}
else if (File.Exists(oldPath))
{
xDom.Load(oldPath);
// TODO: Log message here
xDom.Load(oldPath);
}
#endif
}
else
{
// TODO: Log message here
return;
}
if (xDom.DocumentElement != null)
foreach (XmlElement xEl in xDom.DocumentElement.ChildNodes)
if (xDom.DocumentElement == null)
{
// TODO: Log message here
return;
}
foreach (XmlElement xEl in xDom.DocumentElement.ChildNodes)
{
var extA = new ExternalTool
{
var extA = new ExternalTool
{
DisplayName = xEl.Attributes["DisplayName"].Value,
FileName = xEl.Attributes["FileName"].Value,
Arguments = xEl.Attributes["Arguments"].Value
};
DisplayName = xEl.Attributes["DisplayName"].Value,
FileName = xEl.Attributes["FileName"].Value,
Arguments = xEl.Attributes["Arguments"].Value
};
if (xEl.HasAttribute("WaitForExit"))
{
extA.WaitForExit = bool.Parse(xEl.Attributes["WaitForExit"].Value);
}
if (xEl.HasAttribute("TryToIntegrate"))
{
extA.TryIntegrate = bool.Parse(xEl.Attributes["TryToIntegrate"].Value);
}
Runtime.ExternalTools.Add(extA);
if (xEl.HasAttribute("WaitForExit"))
{
extA.WaitForExit = bool.Parse(xEl.Attributes["WaitForExit"].Value);
}
if (xEl.HasAttribute("TryToIntegrate"))
{
extA.TryIntegrate = bool.Parse(xEl.Attributes["TryToIntegrate"].Value);
}
// TODO: Log message here
Runtime.ExternalTools.Add(extA);
}
_MainForm.SwitchToolBarText(Convert.ToBoolean(mRemoteNG.Settings.Default.ExtAppsTBShowText));
frmMain.Default.AddExternalToolsToToolBar();