From 9d2bbda2b97ce4fcf7ad234c21c563d4b3cbffc4 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 2 Dec 2016 12:11:46 -0500 Subject: [PATCH] ExtTools code clean up Relates to #291 & #236 --- .../Config/Settings/ExternalAppsLoader.cs | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/mRemoteV1/Config/Settings/ExternalAppsLoader.cs b/mRemoteV1/Config/Settings/ExternalAppsLoader.cs index 41fdf420a..deded853c 100644 --- a/mRemoteV1/Config/Settings/ExternalAppsLoader.cs +++ b/mRemoteV1/Config/Settings/ExternalAppsLoader.cs @@ -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();