private SettingsViewModel CreateSettingsTree() { SettingsSectionView[] list = { new SettingsSectionView { Label = guiStrings.TextViewer, Panel = CreateSectionPanel(ViewerSettings) }, new SettingsSectionView { Label = guiStrings.TextFormats, Children = EnumerateFormatsSettings(), }, }; SettingsSectionView selected_section = null; if (LastSelectedSection != null) { selected_section = EnumerateSections(list).FirstOrDefault(s => s.Label == LastSelectedSection); } if (null == selected_section) { selected_section = list[0]; } selected_section.IsSelected = true; return(new SettingsViewModel { Root = list }); }
IEnumerable <SettingsSectionView> EnumerateFormatsSettings() { var list = new List <SettingsSectionView>(); var formats = FormatCatalog.Instance.Formats.Where(f => f.Settings != null && f.Settings.Any()); foreach (var format in formats.OrderBy(f => f.Tag)) { var pane = new WrapPanel(); foreach (var setting in format.Settings) { var widget = CreateSettingWidget(setting, setting.Value as dynamic); if (widget != null) { pane.Children.Add(widget); } } if (pane.Children.Count > 0) { var section = new SettingsSectionView { Label = format.Tag, SectionTitle = guiStrings.TextFormats + " :: " + format.Tag, Panel = pane }; list.Add(section); } } return(list); }
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); }
private SettingsViewModel CreateSettingsTree() { SettingsSectionView[] list = { new SettingsSectionView { Label = "Formats", Children = EnumerateFormatsSettings(), Panel = (UIElement)this.Resources["FormatsPanel"] }, }; SettingsSectionView selected_section = null; if (LastSelectedSection != null) { selected_section = EnumerateSections(list).FirstOrDefault(s => s.Label == LastSelectedSection); } if (null == selected_section) { selected_section = list[0]; } selected_section.IsSelected = true; return(new SettingsViewModel { Root = list }); }