예제 #1
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);
        }
예제 #2
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));
        }
예제 #3
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));
        }