|
|
|
@ -16,10 +16,27 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -16,10 +16,27 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
{ |
|
|
|
|
public class LayoutConfiguration |
|
|
|
|
{ |
|
|
|
|
const string DataLayoutSubPath = "layouts"; |
|
|
|
|
const string configFile = "LayoutConfig.xml"; |
|
|
|
|
public static readonly List<LayoutConfiguration> Layouts = new List<LayoutConfiguration>(); |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the path the layouts folder in SharpDevelop/data (containing the layout templates).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string DataLayoutPath { |
|
|
|
|
get { |
|
|
|
|
return Path.Combine(PropertyService.DataDirectory, "layouts"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the path to the layouts folder in the %appdata% (containing the user's layouts).
|
|
|
|
|
/// </summary>
|
|
|
|
|
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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"); |
|
|
|
|