public AddNewTextSourceDialog(JsonTextInput input) : this()
        {
            _input = input;

            NameTextBox.Text = _input.Name;
            JsonTextBox.Text = _input.Json;
        }
        public AddNewTextSourceDialog(JsonTextInput input)
            : this()
        {
            _input = input;

            NameTextBox.Text = _input.Name;
            JsonTextBox.Text = _input.Json;
        }
        public AddNewTextSourceDialog()
        {
            _input = new JsonTextInput();

            InitializeComponent();

            // sigh, too bad reactiveui doesn't support .net 4
            Action doValidation = () =>
            {
                var name = NameTextBox.Text;
                var json = JsonTextBox.Text;

                bool validJson = false;
                try
                {
                    var obj = JContainer.Parse(json);
                    validJson = true;
                } catch { }

                var nameOk = String.IsNullOrEmpty(name) || char.IsLetter(name.ToCharArray()[0]);
                var jsonOk = validJson || String.IsNullOrEmpty(json);

                OkButton.IsEnabled = (nameOk && jsonOk && !String.IsNullOrEmpty(json) && !string.IsNullOrWhiteSpace(name));

                NameTextBox.Background = nameOk ? _goodBrush : _badBrush;
                JsonTextBox.Background = jsonOk ? _goodBrush : _badBrush;
            };

            NameTextBox.TextChanged += (sender, args) => doValidation();
            JsonTextBox.TextChanged += (sender, args) => doValidation();

            CancelButton.Click += (sender, args) => DialogResult = false;
            OkButton.Click     += (sender, args) =>
            {
                _input.Name = NameTextBox.Text;
                _input.Json = JsonTextBox.Text;

                Input        = _input;
                DialogResult = true;
            };

            doValidation();

            NameTextBox.Focus();
        }
        public AddNewTextSourceDialog()
        {
            _input = new JsonTextInput();

            InitializeComponent();

            // sigh, too bad reactiveui doesn't support .net 4
            Action doValidation = () =>
            {
                var name = NameTextBox.Text;
                var json = JsonTextBox.Text;

                bool validJson = false;
                try
                {
                    var obj = JContainer.Parse(json);
                    validJson = true;
                } catch { }

                var nameOk = String.IsNullOrEmpty(name) || char.IsLetter(name.ToCharArray()[0]);
                var jsonOk = validJson || String.IsNullOrEmpty(json);

                OkButton.IsEnabled = (nameOk && jsonOk && !String.IsNullOrEmpty(json) && !string.IsNullOrWhiteSpace(name));

                NameTextBox.Background = nameOk ? _goodBrush : _badBrush;
                JsonTextBox.Background = jsonOk ? _goodBrush : _badBrush;
            };

            NameTextBox.TextChanged += (sender, args) => doValidation();
            JsonTextBox.TextChanged += (sender, args) => doValidation();

            CancelButton.Click += (sender, args) => DialogResult = false;
            OkButton.Click += (sender, args) =>
            {
                _input.Name = NameTextBox.Text;
                _input.Json = JsonTextBox.Text;

                Input = _input;
                DialogResult = true;
            };

            doValidation();

            NameTextBox.Focus();
        }
 public JsonTextGeneratedClass(JsonTextInput input)
 {
     Input = input;
 }
 public JsonTextGeneratedClass(JsonTextInput input)
 {
     Input = input;
 }