Exemplo n.º 1
0
        public Control CreateInput(IStyler <Control> styler, string[] text, QuestionElementManager <T> questionElementManager)
        {
            FlowLayoutPanel holder = new FlowLayoutPanel {
                FlowDirection = FlowDirection.TopDown
            };
            CheckBox checkBox = new CheckBox {
                Text = text[0]
            };

            checkBox.Checked         = GetChecked(questionElementManager);
            checkBox.CheckedChanged += (object sender, EventArgs eventArgs) => questionElementManager.SetAnswer(checkBox.Checked.ToString());
            questionElementManager.OnAnswerValueUpdate += (ElementManagerLeaf elementManagerLeaf, bool calculated) =>
            {
                if (calculated)
                {
                    bool check = false;
                    bool.TryParse(elementManagerLeaf.AnswerToString(), out check);
                    checkBox.Checked = check;
                }
            };

            holder.Controls.Add(styler.StyleElement(checkBox));

            questionElementManager.OnActiveChange += (string identifier, bool isActive) => holder.Visible = isActive;
            holder.Visible = questionElementManager.Active;

            return(styler.StyleElement(holder));
        }
Exemplo n.º 2
0
        public Control CreateInput(IStyler <Control> styler, string[] text, QuestionElementManager <T> questionElementManager)
        {
            string title = text[0];

            string[] answerOptions = AllButFirst(text);

            FlowLayoutPanel holder = new FlowLayoutPanel {
                FlowDirection = FlowDirection.TopDown
            };
            Label titleLabel = new Label {
                Text = title
            };
            Control styledTitleLabel = styler.StyleElement(titleLabel);

            holder.Controls.Add(styledTitleLabel);

            Control radioButtons = CreateRadioButtons(styler, answerOptions, questionElementManager);

            radioButtons = styler.StyleElement(radioButtons);
            holder.Controls.Add(radioButtons);

            return(styler.StyleElement(holder));
        }
Exemplo n.º 3
0
        public Control CreateInput(IStyler <Control> styler, string[] text, QuestionElementManager <T> questionElementManager)
        {
            // Create holder
            FlowLayoutPanel holder = new FlowLayoutPanel {
                FlowDirection = FlowDirection.TopDown
            };

            holder.Controls.Add(styler.StyleElement(new Label {
                Text = text[0]
            }));

            // Create and style textbox
            Control textbox = CreateTextBox(questionElementManager);

            textbox.Text = questionElementManager.AnswerToString();
            textbox      = styler.StyleElement(textbox);
            holder.Controls.Add(textbox);

            // Add events on holder
            questionElementManager.OnActiveChange += (string identifier, bool isActive) => holder.Visible = isActive;
            holder.Visible = questionElementManager.Active;

            return(styler.StyleElement(holder));
        }
Exemplo n.º 4
0
        public Control CreateInput(IStyler <Control> styler, string[] text, QuestionElementManager <T> questionElementManager)
        {
            Button colorPickerButton = new Button {
                Text = text[0]
            };

            UpdateColor(questionElementManager.AnswerToString());

            colorPickerButton.Click += (object sender, EventArgs evenArgs) => ColorPickerButton_Click(questionElementManager);
            questionElementManager.OnAnswerValueUpdate += AnwerUpdate;
            questionElementManager.OnActiveChange      += (string identifier, bool isActive) => colorPickerButton.Visible = isActive;
            colorPickerButton.Visible = questionElementManager.Active;

            return(styler.StyleElement(colorPickerButton));
        }
Exemplo n.º 5
0
        private Control CreateRadioButtons(IStyler <Control> styler, string[] text, QuestionElementManager <T> questionElementManager)
        {
            FlowLayoutPanel holder = new FlowLayoutPanel {
                FlowDirection = FlowDirection.TopDown
            };

            foreach (string option in text)
            {
                RadioButton radioButton = new RadioButton {
                    Text = option
                };
                radioButton.Checked         = questionElementManager.AnswerToString() == option;
                radioButton.CheckedChanged += (object sender, EventArgs eventArgs) => questionElementManager.SetAnswer(radioButton.Text);
                questionElementManager.OnAnswerValueUpdate += (ElementManagerLeaf elementManagerLeaf, bool calculated) => { if (calculated)
                                                                                                                            {
                                                                                                                                radioButton.Checked = elementManagerLeaf.AnswerToString() == option;
                                                                                                                            }
                };
                holder.Controls.Add(styler.StyleElement(radioButton));
            }
            return(holder);
        }
Exemplo n.º 6
0
        public Control CreateInput(IStyler <Control> styler, string[] text, QuestionElementManager <T> questionElementManager)
        {
            NumericUpDown spinner  = new NumericUpDown();
            Label         question = new Label {
                Text = text[0]
            };
            FlowLayoutPanel holder = new FlowLayoutPanel {
                FlowDirection = FlowDirection.TopDown
            };

            spinner.ValueChanged += (object sender, EventArgs eventArgs) => questionElementManager.SetAnswer(spinner.Value.ToString());
            questionElementManager.OnAnswerValueUpdate += (ElementManagerLeaf elementManagerLeaf, bool calculated) => { if (calculated)
                                                                                                                        {
                                                                                                                            spinner.Value = decimal.Parse(questionElementManager.AnswerToString());
                                                                                                                        }
            };
            questionElementManager.OnActiveChange += (string identifier, bool isActive) => holder.Visible = isActive;
            holder.Visible = questionElementManager.Active;

            holder.Controls.Add(question);
            holder.Controls.Add(spinner);
            return(styler.StyleElement(holder));
        }