IEnumerable <SettingsSectionView> EnumerateFormatsSettings() { var list = new List <SettingsSectionView>(); foreach (var format in FormatCatalog.Instance.Formats.Where(f => f.Settings != null && f.Settings.Any())) { var pane = new WrapPanel(); foreach (var setting in format.Settings) { if (setting.Value is bool) { var view = new ResourceSettingView <bool> (setting); view.ValueChanged += (s, e) => ViewModel.HasChanges = true; this.OnApplyChanges += (s, e) => view.Apply(); var check_box = new CheckBox { Template = (ControlTemplate)this.Resources["BoundCheckBox"], DataContext = view, }; pane.Children.Add(check_box); } } if (pane.Children.Count > 0) { var section = new SettingsSectionView { Label = format.Tag, SectionTitle = guiStrings.TextFormats + " :: " + format.Tag, Panel = pane }; list.Add(section); } } return(list); }
ISettingView CreateSettingView <TValue> (IResourceSetting setting) { var view = new ResourceSettingView <TValue> (setting); view.ValueChanged += (s, e) => ViewModel.HasChanges = true; this.OnApplyChanges += (s, e) => view.Apply(); return(view); }