Ejemplo n.º 1
0
        private FrameworkElement GetFrameworkElement(ConnectionSetting setting)
        {
            FrameworkElement element;
            Binding          binding = new Binding("Value")
            {
                NotifyOnSourceUpdated = true
            };

            // Check if the setting has possibilities
            if (setting.Possibilities == null)
            {
                switch (setting.Value)
                {
                case bool _:
                    element = this.GenerateValueCheckBoxElement(setting.Value, binding);
                    break;

                default:
                    element = this.GenerateValueTextBoxElement(setting.Value, binding);
                    break;
                }
            }
            else
            {
                element = this.GenerateValueComboBoxElement(setting.Value, binding, setting.Possibilities, setting.EnforcePossibilities);
            }
            element.Margin = new Thickness(3);
            Grid.SetRow(element, 0);
            Grid.SetColumn(element, 1);
            if (setting.PossibilitiesRefresher == null)
            {
                Grid.SetColumnSpan(element, 2);
            }
            else
            {
                this.RefreshButton.Visibility = Visibility.Visible;
                this.RefreshButton.Click     += delegate { setting.PossibilitiesRefresher(); };
                Grid.SetColumnSpan(element, 1);
            }
            return(element);
        }