Beispiel #1
0
        private static TextView CreateStringTextBox(UiItem configItem)
        {
            var textView = new TextView();

            textView.Buffer.Text     = configItem.GetValue <string> ();
            textView.Buffer.Changed += (s, a) => configItem.Value = textView.Buffer.Text;
            return(textView);
        }
Beispiel #2
0
        private static CheckButton CreateCheckButton(UiItem configItem)
        {
            var checkButton = new CheckButton();

            checkButton.Active        = configItem.GetValue <Boolean> ();
            checkButton.StateChanged += (s, a) => configItem.Value = checkButton.Active;
            return(checkButton);
        }
        private static TextBox CreateStringTextBox(UiItem configItem)
        {
            var textBox = new TextBox {
                Text = configItem.GetValue <string> ()
            };

            textBox.TextChanged += (s, e) => configItem.Value = textBox.Text;
            return(textBox);
        }
        private static CheckBox CreateCheckBox(UiItem configItem)
        {
            var checkBox = new CheckBox {
                Checked = configItem.GetValue <Boolean> ()
            };

            checkBox.CheckedChanged += (s, e) => configItem.Value = checkBox.Checked;
            return(checkBox);
        }
Beispiel #5
0
        private static TextView CreateIntegerTextBox(UiItem configItem)
        {
            var textView = new TextView();

            textView.Buffer.Text     = configItem.GetValue <int> ().ToString();
            textView.Buffer.Changed += (s, a) => {
                int value;
                if (int.TryParse(textView.Buffer.Text, out value))
                {
                    configItem.Value = value;
                }
            };
            return(textView);
        }
        private static TextBox CreateIntegerTextBox(UiItem configItem)
        {
            var textBox = new TextBox {
                Text = configItem.GetValue <int> ().ToString()
            };

            textBox.TextChanged += (s, e) => {
                int value;
                if (int.TryParse(textBox.Text, out value))
                {
                    configItem.Value = value;
                }
            };
            return(textBox);
        }
Beispiel #7
0
        private static IEnumerable <Widget> CreateItemWidgets(UiItem configItem)
        {
            yield return(CreateLabel(configItem.Name));

            if (configItem.Type == typeof(string))
            {
                yield return(CreateStringTextBox(configItem));
            }
            else if (configItem.Type == typeof(int))
            {
                yield return(CreateIntegerTextBox(configItem));
            }
            else if (configItem.Type == typeof(Boolean))
            {
                yield return(CreateCheckButton(configItem));
            }
            else
            {
                throw new ArgumentException($"Unsupported config item type: {configItem.Type}");
            }
        }