diff --git a/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs b/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs index 6067166d99..c30a03a5f1 100644 --- a/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs +++ b/src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs @@ -42,8 +42,8 @@ namespace ICSharpCode.SharpDevelop.Commands LoggingService.Debug("ChooseLayoutCommand.Run()"); var comboBox = (System.Windows.Controls.ComboBox)base.ComboBox; - string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); - string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); + string dataPath = LayoutConfiguration.DataLayoutPath; + string configPath = LayoutConfiguration.ConfigLayoutPath; if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } @@ -141,8 +141,8 @@ namespace ICSharpCode.SharpDevelop.Commands if (MessageService.AskQuestion("${res:ICSharpCode.SharpDevelop.Commands.ChooseLayoutCommand.ResetToDefaultsQuestion}")) { foreach (LayoutConfiguration config in LayoutConfiguration.Layouts) { - string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); - string dataPath = Path.Combine(PropertyService.DataDirectory, "resources" + Path.DirectorySeparatorChar + "layouts"); + string configPath = LayoutConfiguration.ConfigLayoutPath; + string dataPath = LayoutConfiguration.DataLayoutPath; if (File.Exists(Path.Combine(dataPath, config.FileName)) && File.Exists(Path.Combine(configPath, config.FileName))) { try { File.Delete(Path.Combine(configPath, config.FileName)); diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs index fcd1a2ff22..b4f5585422 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs @@ -16,10 +16,27 @@ namespace ICSharpCode.SharpDevelop.Gui { public class LayoutConfiguration { - const string DataLayoutSubPath = "layouts"; const string configFile = "LayoutConfig.xml"; public static readonly List Layouts = new List(); + /// + /// Gets the path the layouts folder in SharpDevelop/data (containing the layout templates). + /// + public static string DataLayoutPath { + get { + return Path.Combine(PropertyService.DataDirectory, "layouts"); + } + } + + /// + /// Gets the path to the layouts folder in the %appdata% (containing the user's layouts). + /// + public static string ConfigLayoutPath { + get { + return Path.Combine(PropertyService.ConfigDirectory, "layouts"); + } + } + const string DefaultLayoutName = "Default"; public static string[] DefaultLayouts = new string[] { @@ -97,8 +114,8 @@ namespace ICSharpCode.SharpDevelop.Gui LayoutConfiguration l = new LayoutConfiguration(); l.name = name; l.fileName = Path.GetRandomFileName() + ".xml"; - File.Copy(Path.Combine(Path.Combine(PropertyService.DataDirectory, DataLayoutSubPath), "Default.xml"), - Path.Combine(Path.Combine(PropertyService.ConfigDirectory, "layouts"), l.fileName)); + File.Copy(Path.Combine(DataLayoutPath, "Default.xml"), + Path.Combine(ConfigLayoutPath, l.fileName)); l.custom = true; Layouts.Add(l); return l; @@ -135,10 +152,9 @@ namespace ICSharpCode.SharpDevelop.Gui public static string CurrentLayoutFileName { get { - string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); LayoutConfiguration current = CurrentLayout; if (current != null) { - return Path.Combine(configPath, current.FileName); + return Path.Combine(ConfigLayoutPath, current.FileName); } return null; } @@ -146,10 +162,9 @@ namespace ICSharpCode.SharpDevelop.Gui public static string CurrentLayoutTemplateFileName { get { - string dataPath = Path.Combine(PropertyService.DataDirectory, DataLayoutSubPath); LayoutConfiguration current = CurrentLayout; if (current != null) { - return Path.Combine(dataPath, current.FileName); + return Path.Combine(DataLayoutPath, current.FileName); } return null; } @@ -179,11 +194,11 @@ namespace ICSharpCode.SharpDevelop.Gui internal static void LoadLayoutConfiguration() { Layouts.Clear(); - string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); + string configPath = ConfigLayoutPath; if (File.Exists(Path.Combine(configPath, configFile))) { LoadLayoutConfiguration(Path.Combine(configPath, configFile), true); } - string dataPath = Path.Combine(PropertyService.DataDirectory, DataLayoutSubPath); + string dataPath = DataLayoutPath; if (File.Exists(Path.Combine(dataPath, configFile))) { LoadLayoutConfiguration(Path.Combine(dataPath, configFile), false); } @@ -201,7 +216,7 @@ namespace ICSharpCode.SharpDevelop.Gui public static void SaveCustomLayoutConfiguration() { - string configPath = Path.Combine(PropertyService.ConfigDirectory, "layouts"); + string configPath = ConfigLayoutPath; using (XmlTextWriter w = new XmlTextWriter(Path.Combine(configPath, configFile), System.Text.Encoding.UTF8)) { w.Formatting = Formatting.Indented; w.WriteStartElement("LayoutConfig");