in src/OptionsPage/OptionsControl.xaml.cs [20:88]
public OptionsControl(IEditorOptions globalOptions, IEnumerable<LabeledOptionDefinitionGroup> optionGroups)
{
InitializeComponent();
_globalOptions = globalOptions;
foreach (var optionGroup in optionGroups)
{
GroupBox groupBox = null;
StackPanel itemList = null;
// Create a group if the group heading is not null or empty.
if (!string.IsNullOrEmpty(optionGroup.GroupHeading))
{
groupBox = new GroupBox();
groupBox.Header = optionGroup.GroupHeading;
itemList = new StackPanel();
itemList.Orientation = Orientation.Vertical;
groupBox.Content = itemList;
groupBox.Padding = new Thickness(4.0, 6.0, 4.0, 2.0);
groupBox.Margin = new Thickness(0.0, 4.0, 0.0, 0.0);
groupBox.Foreground = SystemColors.WindowTextBrush;
}
bool atLeastOneOptionIsDefined = false;
foreach (var labeledOption in optionGroup.LabeledOptionDefinitions)
{
if (_globalOptions.IsOptionDefined(labeledOption.Name, localScopeOnly: true))
{
// Add a checkbox to the group if it exists; if the group doesn't exist, then
// add the checkbox to the list of options.
CheckBox box = new CheckBox();
_allOptions.Add(box);
box.IsEnabled = true;
box.IsChecked = _globalOptions.GetOptionValue<bool>(labeledOption.Name);
box.Tag = labeledOption;
box.Content = labeledOption.Label;
box.Margin = new Thickness(0.0, 1.0, 0.0, 1.0);
// We found at least one option that can is defined in global options.
// Now we can add the group to the options page (if there is a group).
if (!atLeastOneOptionIsDefined)
{
if (groupBox != null)
{
this.Options.Items.Add(groupBox);
}
atLeastOneOptionIsDefined = true;
}
if (itemList != null)
{
itemList.Children.Add(box);
}
else
{
this.Options.Items.Add(box);
}
}
}
}
}