Example #1
0
        public InternalOptionsControl(string featureOptionName, IServiceProvider serviceProvider)
            : base(serviceProvider)
        {
            var panel = new StackPanel();

            foreach (var option in OptionService.GetRegisteredOptions().Where(o => o.Feature == featureOptionName).OrderBy(o => o.Name))
            {
                if (!option.IsPerLanguage)
                {
                    var checkBox = new CheckBox()
                    {
                        Content = option.Name
                    };
                    BindToOption(checkBox, (Option <bool>)option);
                    panel.Children.Add(checkBox);
                }
                else
                {
                    AddPerLanguageOption(panel, option, LanguageNames.CSharp);
                    AddPerLanguageOption(panel, option, LanguageNames.VisualBasic);
                }
            }

            var viewer = new ScrollViewer();

            viewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            viewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;

            var checkAllButton = new Button()
            {
                Content = "Check All"
            };

            checkAllButton.Click += (o, a) => panel.Children.OfType <CheckBox>().Do(c => c.IsChecked = true);

            var uncheckAllButton = new Button()
            {
                Content = "Uncheck All"
            };

            uncheckAllButton.Click += (o, a) => panel.Children.OfType <CheckBox>().Do(c => c.IsChecked = false);

            var selectionPanel = new StackPanel();

            selectionPanel.Children.Add(checkAllButton);
            selectionPanel.Children.Add(uncheckAllButton);

            panel.Children.Add(selectionPanel);

            viewer.Content = panel;

            this.Content = viewer;
        }
Example #2
0
 protected virtual void AddOptions(Panel panel)
 {
     foreach (var option in OptionService.GetRegisteredOptions().Where(o => o.Feature == _featureOptionName).OrderBy(o => o.Name))
     {
         if (!option.IsPerLanguage)
         {
             AddOption(panel, option);
         }
         else
         {
             AddPerLanguageOption(panel, option, LanguageNames.CSharp);
             AddPerLanguageOption(panel, option, LanguageNames.VisualBasic);
         }
     }
 }