Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit ad4040a

Browse files
committed
Finished formatting editor tree items, fixed some bugs, editor now really changes (but not saves) the option container.
1 parent 41763fb commit ad4040a

3 files changed

Lines changed: 116 additions & 85 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ public void SetOption(string option, object value)
194194
activeOptions.Remove(option);
195195
// Update formatting options object from parents
196196
PropertyInfo propertyInfo = typeof(CSharpFormattingOptions).GetProperty(option);
197-
if ((propertyInfo != null) && (propertyInfo.PropertyType == value.GetType())) {
198-
propertyInfo.SetValue(cachedOptions, GetOption(option));
197+
if (propertyInfo != null) {
198+
propertyInfo.SetValue(cachedOptions, GetEffectiveOption(option));
199199
}
200200
}
201201
}

src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/FormattingOptionBinding.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void OnOptionPropertyChanged(DependencyObject o, DependencyPropertyChange
6969
ComboBox comboBox = o as ComboBox;
7070
if ((option != null) && (comboBox != null)) {
7171
// Add "default" entry in ComboBox
72-
// TODO Add located resource!
72+
// TODO Add located resource, maybe context-bound, like "(solution)" or "(global)"!
7373
comboBox.Items.Add(new ComboBoxItem { Content = "(default)", Tag = null });
7474
comboBox.SelectedIndex = 0;
7575

@@ -78,7 +78,25 @@ static void OnOptionPropertyChanged(DependencyObject o, DependencyPropertyChange
7878
Type optionType = container.GetOptionType(option);
7979
FillComboValues(comboBox, optionType);
8080
object currentValue = container.GetOption(option);
81-
comboBox.SelectedItem = comboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(item => currentValue.Equals(item.Tag));
81+
comboBox.SelectedItem = comboBox.Items.OfType<ComboBoxItem>().FirstOrDefault(item => object.Equals(currentValue, item.Tag));
82+
}
83+
84+
comboBox.SelectionChanged += ComboBox_SelectionChanged;
85+
}
86+
}
87+
88+
static void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
89+
{
90+
ComboBox comboBox = sender as ComboBox;
91+
if (comboBox != null) {
92+
string option = GetOption(comboBox);
93+
CSharpFormattingOptionsContainer container = GetContainer(comboBox);
94+
if ((container != null) && (option != null)) {
95+
ComboBoxItem selectedItem = comboBox.SelectedItem as ComboBoxItem;
96+
if (selectedItem != null) {
97+
// Set option to appropriate value
98+
container.SetOption(option, selectedItem.Tag);
99+
}
82100
}
83101
}
84102
}

0 commit comments

Comments
 (0)