Browse Source

Fixed saving CodeEditorOptions.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
c9860fb9bc
  1. 3
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  2. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
  3. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs
  4. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryPad.cs
  5. 16
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
  6. 19
      src/Main/Core/Project/Src/Services/PropertyService/Properties.cs

3
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -61,6 +61,9 @@ @@ -61,6 +61,9 @@
<Reference Include="System.Printing">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Runtime.Serialization">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xaml" />

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs

@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Windows.Data;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@ -14,8 +14,17 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -14,8 +14,17 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
[Serializable]
public class CodeEditorOptions : TextEditorOptions, ITextEditorOptions
{
static readonly Lazy<CodeEditorOptions> instance = new Lazy<CodeEditorOptions>(
() => PropertyService.Get("CodeEditorOptions", new CodeEditorOptions()));
public static CodeEditorOptions Instance {
get { return PropertyService.Get("CodeEditorOptions", new CodeEditorOptions()); }
get { return instance.Value; }
}
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
PropertyService.Set("CodeEditorOptions", this);
}
// always support scrolling below the end of the document - it's better when folding is enabled

4
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs

@ -150,7 +150,7 @@ namespace ICSharpCode.XmlEditor @@ -150,7 +150,7 @@ namespace ICSharpCode.XmlEditor
void LoadNamespaces(Properties properties)
{
string[] namespaces = properties.GetList<string>(NamespacesProperty);
var namespaces = properties.GetList<string>(NamespacesProperty);
foreach (string ns in namespaces) {
XmlNamespace xmlNamespace = XmlNamespace.FromString(ns);
AddNamespace(xmlNamespace.Prefix, xmlNamespace.Name);
@ -171,7 +171,7 @@ namespace ICSharpCode.XmlEditor @@ -171,7 +171,7 @@ namespace ICSharpCode.XmlEditor
void LoadXPathQueryHistory(Properties properties)
{
XPathComboBox.Text = properties.Get(XPathComboBoxTextProperty, string.Empty);
string[] xpaths = properties.GetList<string>(XPathComboBoxItemsProperty);
var xpaths = properties.GetList<string>(XPathComboBoxItemsProperty);
foreach (string xpath in xpaths) {
xpathComboBox.Items.Add(xpath);
}

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryPad.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.XmlEditor @@ -42,7 +42,7 @@ namespace ICSharpCode.XmlEditor
disposed = true;
WorkbenchSingleton.Workbench.ActiveViewContentChanged -= ActiveViewContentChanged;
Properties properties = xpathQueryControl.CreateMemento();
PropertyService.PropertiesContainer.SetNestedProperties(XPathQueryControlProperties, properties);
PropertyService.SetNestedProperties(XPathQueryControlProperties, properties);
xpathQueryControl.Dispose();
}
}

16
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -194,7 +194,7 @@ namespace ICSharpCode.AvalonEdit @@ -194,7 +194,7 @@ namespace ICSharpCode.AvalonEdit
// The fields should be accessed only by their property - the fields might not be used
// if someone overrides the property.
int _indentationSize = 4;
int indentationSize = 4;
/// <summary>
/// Gets/Sets the width of one indentation unit.
@ -202,7 +202,7 @@ namespace ICSharpCode.AvalonEdit @@ -202,7 +202,7 @@ namespace ICSharpCode.AvalonEdit
/// <remarks>The default value is 4.</remarks>
[DefaultValue(4)]
public virtual int IndentationSize {
get { return _indentationSize; }
get { return indentationSize; }
set {
if (value < 1)
throw new ArgumentOutOfRangeException("value", value, "value must be positive");
@ -210,15 +210,15 @@ namespace ICSharpCode.AvalonEdit @@ -210,15 +210,15 @@ namespace ICSharpCode.AvalonEdit
// (it only crashed in the hundred thousands for me; but might crash earlier with larger fonts)
if (value > 1000)
throw new ArgumentOutOfRangeException("value", value, "indentation size is too large");
if (_indentationSize != value) {
_indentationSize = value;
if (indentationSize != value) {
indentationSize = value;
OnPropertyChanged("IndentationSize");
OnPropertyChanged("IndentationString");
}
}
}
bool _convertTabsToSpaces;
bool convertTabsToSpaces;
/// <summary>
/// Gets/Sets whether to use spaces for indentation instead of tabs.
@ -226,10 +226,10 @@ namespace ICSharpCode.AvalonEdit @@ -226,10 +226,10 @@ namespace ICSharpCode.AvalonEdit
/// <remarks>The default value is <c>false</c>.</remarks>
[DefaultValue(false)]
public virtual bool ConvertTabsToSpaces {
get { return _convertTabsToSpaces; }
get { return convertTabsToSpaces; }
set {
if (_convertTabsToSpaces != value) {
_convertTabsToSpaces = value;
if (convertTabsToSpaces != value) {
convertTabsToSpaces = value;
OnPropertyChanged("ConvertTabsToSpaces");
OnPropertyChanged("IndentationString");
}

19
src/Main/Core/Project/Src/Services/PropertyService/Properties.cs

@ -168,7 +168,12 @@ namespace ICSharpCode.Core @@ -168,7 +168,12 @@ namespace ICSharpCode.Core
lock (syncRoot) {
object val;
if (dict.TryGetValue(key, out val)) {
return (T)Deserialize(val, typeof(T));
try {
return (T)Deserialize(val, typeof(T));
} catch (SerializationException ex) {
LoggingService.Warn(ex);
return defaultValue;
}
} else {
return defaultValue;
}
@ -221,11 +226,15 @@ namespace ICSharpCode.Core @@ -221,11 +226,15 @@ namespace ICSharpCode.Core
if (dict.TryGetValue(key, out val)) {
object[] serializedArray = val as object[];
if (serializedArray != null) {
T[] array = new T[serializedArray.Length];
for (int i = 0; i < array.Length; i++) {
array[i] = (T)Deserialize(serializedArray[i], typeof(T));
try {
T[] array = new T[serializedArray.Length];
for (int i = 0; i < array.Length; i++) {
array[i] = (T)Deserialize(serializedArray[i], typeof(T));
}
return array;
} catch (SerializationException ex) {
LoggingService.Warn(ex);
}
return array;
} else {
LoggingService.Warn("Properties.GetList(" + key + ") - this entry is not a list");
}

Loading…
Cancel
Save