Browse Source

Fixed some issues with formatting options becoming "dirty" unnecessarily.

pull/487/head
Andreas Weizel 11 years ago
parent
commit
86150a45d6
  1. 22
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs
  2. 10
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs

22
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs

@ -127,7 +127,7 @@ namespace CSharpBinding.FormattingStrategy @@ -127,7 +127,7 @@ namespace CSharpBinding.FormattingStrategy
if ((e.PropertyName == "Parent") || (e.PropertyName == null)) {
// All properties might have changed -> update everything
cachedOptions = CreateCachedOptions();
OnPropertyChanged(e.PropertyName);
// OnPropertyChanged(e.PropertyName);
} else {
// Some other property has changed, check if we have our own value for it
if (!activeOptions.Contains(e.PropertyName)) {
@ -136,7 +136,7 @@ namespace CSharpBinding.FormattingStrategy @@ -136,7 +136,7 @@ namespace CSharpBinding.FormattingStrategy
if (propertyInfo != null) {
var val = GetEffectiveOption(e.PropertyName);
propertyInfo.SetValue(cachedOptions, val);
OnPropertyChanged(e.PropertyName);
// OnPropertyChanged(e.PropertyName);
}
}
}
@ -265,14 +265,16 @@ namespace CSharpBinding.FormattingStrategy @@ -265,14 +265,16 @@ namespace CSharpBinding.FormattingStrategy
if (parentProperties == null)
throw new ArgumentNullException("parentProperties");
Properties formatProperties = parentProperties.NestedProperties("CSharpFormatting");
if (formatProperties != null) {
foreach (var key in formatProperties.Keys) {
try {
object val = formatProperties.Get(key, (object) null);
SetOption(key, val);
} catch (Exception) {
// Silently ignore loading error, then this property will be "as parent" automatically
if (parentProperties.Contains("CSharpFormatting")) {
Properties formatProperties = parentProperties.NestedProperties("CSharpFormatting");
if (formatProperties != null) {
foreach (var key in formatProperties.Keys) {
try {
object val = formatProperties.Get(key, (object)null);
SetOption(key, val);
} catch (Exception) {
// Silently ignore loading error, then this property will be "as parent" automatically
}
}
}
}

10
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs

@ -64,6 +64,7 @@ namespace CSharpBinding.OptionPanels @@ -64,6 +64,7 @@ namespace CSharpBinding.OptionPanels
internal partial class CSharpFormattingOptionPanel : OptionPanel
{
readonly CSharpFormattingOptionsPersistence persistenceHelper;
bool isDirty;
public CSharpFormattingOptionPanel(CSharpFormattingOptionsPersistence persistenceHelper, bool allowPresets)
{
@ -71,6 +72,7 @@ namespace CSharpBinding.OptionPanels @@ -71,6 +72,7 @@ namespace CSharpBinding.OptionPanels
throw new ArgumentNullException("persistenceHelper");
this.persistenceHelper = persistenceHelper;
this.isDirty = false;
InitializeComponent();
formattingEditor.AllowPresets = allowPresets;
@ -80,11 +82,17 @@ namespace CSharpBinding.OptionPanels @@ -80,11 +82,17 @@ namespace CSharpBinding.OptionPanels
{
base.LoadOptions();
formattingEditor.OptionsContainer = persistenceHelper.StartEditing();
formattingEditor.OptionsContainer.PropertyChanged += (sender, e) => isDirty = true;
}
public override bool SaveOptions()
{
return persistenceHelper.Save() && base.SaveOptions();
if (isDirty) {
return persistenceHelper.Save() && base.SaveOptions();
} else {
// Nothing has been changed here, return without action
return true;
}
}
}
}
Loading…
Cancel
Save