Browse Source

Add version info to layout files to avoid exception when AvalonDock version has changed.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5212 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
db5f09dfd4
  1. 2
      data/layouts/Debug.xml
  2. 2
      data/layouts/Default.xml
  3. 2
      data/layouts/Plain.xml
  4. 6
      src/Libraries/AvalonDock/DockingManager.cs
  5. 23
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs

2
data/layouts/Debug.xml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<DockingManager>
<DockingManager version="1.2.1">
<ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1076,904.08" Orientation="Vertical">
<ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1257.04,717.08" Orientation="Horizontal">
<DockablePane ResizeWidth="200" ResizeHeight="*" EffectiveSize="200,717.08" Anchor="Left">

2
data/layouts/Default.xml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<DockingManager>
<DockingManager version="1.2.1">
<ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="0,0" Orientation="Horizontal">
<DockablePane ResizeWidth="200" ResizeHeight="*" EffectiveSize="200,904.08" Anchor="Left">
<DockableContent Name="ICSharpCode_SharpDevelop_Project_ProjectBrowserPad" AutoHide="false" />

2
data/layouts/Plain.xml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<DockingManager>
<DockingManager version="1.2.1">
<DocumentPanePlaceHolder />
<Hidden />
<Windows />

6
src/Libraries/AvalonDock/DockingManager.cs

@ -2714,6 +2714,8 @@ namespace AvalonDock @@ -2714,6 +2714,8 @@ namespace AvalonDock
SaveLayout(stream);
}
const string layoutFileVersion = "1.2.1";
/// <summary>
/// Send layout configuration to a <see cref="XmlTextWriter"/> object
/// </summary>
@ -2725,6 +2727,7 @@ namespace AvalonDock @@ -2725,6 +2727,7 @@ namespace AvalonDock
throw new InvalidOperationException("Unable to serialize docking layout while DockingManager control is unloaded");
sw.WriteStartElement("DockingManager");
sw.WriteAttributeString("version", layoutFileVersion);
if (Content is ResizingPanel)
SaveLayout(sw, Content as ResizingPanel);
@ -3032,6 +3035,9 @@ namespace AvalonDock @@ -3032,6 +3035,9 @@ namespace AvalonDock
Debug.Assert(false, "Layout file hasn't a valid structure!");
throw new InvalidOperationException("Layout file had not a valid structure!");
}
if (doc.DocumentElement.GetAttribute("version") != layoutFileVersion)
throw new FileFormatException("Unsupported layout file version");
if (doc.DocumentElement.ChildNodes.Count != 3 ||
(doc.DocumentElement.ChildNodes[0].Name != "ResizingPanel" && doc.DocumentElement.ChildNodes[0].Name != "DocumentPanePlaceHolder") ||

23
src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs

@ -204,12 +204,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -204,12 +204,7 @@ namespace ICSharpCode.SharpDevelop.Gui
return;
Busy = true;
try {
bool isPlainLayout = LayoutConfiguration.CurrentLayoutName == "Plain";
if (File.Exists(LayoutConfiguration.CurrentLayoutFileName)) {
LoadLayout(LayoutConfiguration.CurrentLayoutFileName, isPlainLayout);
} else if (File.Exists(LayoutConfiguration.CurrentLayoutTemplateFileName)) {
LoadLayout(LayoutConfiguration.CurrentLayoutTemplateFileName, isPlainLayout);
}
TryLoadConfiguration();
} catch (Exception ex) {
MessageService.ShowException(ex);
// ignore errors loading configuration
@ -221,6 +216,22 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -221,6 +216,22 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
void TryLoadConfiguration()
{
bool isPlainLayout = LayoutConfiguration.CurrentLayoutName == "Plain";
if (File.Exists(LayoutConfiguration.CurrentLayoutFileName)) {
try {
LoadLayout(LayoutConfiguration.CurrentLayoutFileName, isPlainLayout);
return;
} catch (FileFormatException) {
// error when version of AvalonDock has changed: ignore and load template instead
}
}
if (File.Exists(LayoutConfiguration.CurrentLayoutTemplateFileName)) {
LoadLayout(LayoutConfiguration.CurrentLayoutTemplateFileName, isPlainLayout);
}
}
void LoadLayout(string fileName, bool hideAllLostPads)
{
LoggingService.Info("Loading layout file: " + fileName + ", hideAllLostPads=" + hideAllLostPads);

Loading…
Cancel
Save