Browse Source

Fixed 'Reset to defaults' in layout combo box.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4135 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts^2
Daniel Grunwald 16 years ago
parent
commit
45b73e93e2
  1. 8
      src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs
  2. 35
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs

8
src/Main/Base/Project/Src/Commands/ChooseLayoutCommand.cs

@ -42,8 +42,8 @@ namespace ICSharpCode.SharpDevelop.Commands @@ -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 @@ -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));

35
src/Main/Base/Project/Src/Gui/Workbench/Layouts/LayoutConfiguration.cs

@ -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");

Loading…
Cancel
Save