Example #1
0
        public override object Visit(QuestionStatement statement, QuestionVisitorTypeEnvironment environment)
        {
            // TODO: change string primitives to StringValue?
            // [...].Value.Value is ugly. Since StringValues replace string primitives,
            // maybe we should replace them in the code too?
            if (environment.IsIdentifierDuplicate(statement.Identifier))
            {
                this.Report.Add(new DuplicateQuestionIdentifierMessage(statement));
            }
            else
            {
                environment.AddQuestionIdentifier(statement.Identifier);
            }

            if (environment.IsLableDuplicate(statement.Label.Value.Value))
            {
                this.Report.Add(new DuplicateQuestionLabelMessage(statement));
            }
            else
            {
                environment.AddQuestionLabel(statement.Label.Value.Value);
            }

            return(base.Visit(statement, environment));
        }
Example #2
0
 protected QuestionWidget(IValue value, QuestionStatement statement, GuiEnvironment guiEnvironment)
     : base(guiEnvironment)
 {
     this.Statement = statement;
     this.Value     = value;
     this.Dependencies.UnionWith(statement.GetDependencies());
 }
Example #3
0
 public TextFieldWidget(
     IValue value,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment)
 {
     this.CreateControls(statement, style);
 }
Example #4
0
 public DatePickerWidget(
     DateValue value,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment)
 {
     this.CreateControls(statement, style);
 }
Example #5
0
 public CheckBoxWidget(
     BooleanValue value,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment)
 {
     this.CreateControls(statement, style);
 }
        public override object Visit(QuestionStatement statement, QuestionVisitorTypeEnvironment environment)
        {
            if (statement.ComputationExpression != null)
            {
                this.GetVariables(statement.ComputationExpression).ForEach(x => this.circularDependencyChecker
                                                                           .AddDependency(new Dependency(statement.Identifier, x)));
            }

            return(base.Visit(statement, environment));
        }
Example #7
0
        private void CreateControls(QuestionStatement statement, WidgetStyle style)
        {
            this.Input            = new CheckBox();
            this.Input.Checked   += (e, a) => this.UpdateValue();
            this.Input.Unchecked += (e, a) => this.UpdateValue();
            this.Input.IsEnabled  = !this.IsReadOnly();
            this.Input.IsChecked  = ((BooleanValue)this.Value).Value;

            this.CreateControls(this.Input, statement, style);
        }
 public ValidatedTextFieldWidget(
     IValue value,
     IValidator <string> validator,
     QuestionStatement statement,
     GuiEnvironment guiEnvironment,
     WidgetStyle style)
     : base(value, statement, guiEnvironment, style)
 {
     this.validator = validator;
 }
Example #9
0
        private void CreateControls(QuestionStatement statement, WidgetStyle style)
        {
            this.Input = new DatePicker {
                SelectedDateFormat = DatePickerFormat.Short
            };
            this.Input.SelectedDateChanged += (e, a) => this.UpdateValue();
            this.Input.IsEnabled            = !this.IsReadOnly();
            this.Input.SelectedDate         = ((DateValue)this.Value).Value;

            this.CreateControls(this.Input, statement, style);
        }
Example #10
0
        protected void CreateControls(Control input, QuestionStatement statement, WidgetStyle style)
        {
            var label = new Label {
                Content = statement.Label
            };

            style.Apply(label);
            style.Apply(input);

            this.Controls.Add(statement.Identifier + "Label", label);
            this.Controls.Add(statement.Identifier, input);
        }
Example #11
0
        public Widget Visit(QuestionStatement statement, GuiEnvironment environment)
        {
            var style = new WidgetStyle
            {
                Color = Colors.Black,
                Width = 200,
            };

            var questionWidget = this.CreateWidgetForQuestion(statement, environment, style);

            return(questionWidget);
        }
Example #12
0
        protected void CreateControls(QuestionStatement statement, WidgetStyle style)
        {
            var label = new Label {
                Content = statement.Label
            };

            this.Input           = new TextBox();
            this.Input.KeyUp    += (e, a) => this.UpdateValue();
            this.Input.IsEnabled = !this.IsReadOnly();
            this.Input.Text      = this.Value.ToString();

            this.CreateControls(this.Input, statement, style);
        }
Example #13
0
        protected void CreateControls(QuestionStatement statement, WidgetStyle style)
        {
            var label = new Label {
                Content = statement.Label
            };

            this.Input        = new TextBox();
            this.Input.KeyUp += this.UpdateValue;

            style.Apply(label);
            style.Apply(this.Input);

            this.Controls.Add(label);
            this.Controls.Add(this.Input);
        }
Example #14
0
        private void CreateControls(QuestionStatement statement, WidgetStyle style)
        {
            var label = new Label {
                Content = statement.Label
            };

            this.Input            = new CheckBox();
            this.Input.Checked   += this.UpdateValue;
            this.Input.Unchecked += this.UpdateValue;

            style.Apply(label);
            style.Apply(this.Input);

            this.Controls.Add(label);
            this.Controls.Add(this.Input);
        }
Example #15
0
        private void CreateControls(QuestionStatement statement, WidgetStyle style)
        {
            var label = new Label {
                Content = statement.Label
            };

            this.Input = new DatePicker {
                SelectedDateFormat = DatePickerFormat.Short
            };
            this.Input.SelectedDateChanged += this.UpdateValue;

            style.Apply(label);
            style.Apply(this.Input);

            this.Controls.Add(label);
            this.Controls.Add(this.Input);
        }
Example #16
0
        public override object Visit(QuestionStatement statement, IQuestionEnvironment environment)
        {
            if (environment.IsIdentifierDuplicate(statement.Identifier))
            {
                this.Report.Add(new DuplicateQuestionIdentifierMessage(statement));
            }
            else
            {
                environment.AddQuestionIdentifier(statement.Identifier);
            }

            if (environment.IsLabelDuplicate(statement.Label.Value))
            {
                this.Report.Add(new DuplicateQuestionLabelMessage(statement));
            }
            else
            {
                environment.AddQuestionLabel(statement.Label.Value);
            }

            return(base.Visit(statement, environment));
        }
Example #17
0
        private Widget CreateWidgetForQuestion(QuestionStatement statement, GuiEnvironment environment, WidgetStyle style)
        {
            Widget questionWidget;

            switch (statement.Type)
            {
            case BooleanValueType _:
                questionWidget = new CheckBoxWidget(new BooleanValue(false), statement, environment, style);
                break;

            case DateValueType _:
                questionWidget = new DatePickerWidget(new DateValue(DateTime.Now), statement, environment, style);
                break;

            case StringValueType _:
                questionWidget = new TextFieldWidget(new StringValue(string.Empty), statement, environment, style);
                break;

            case DecimalValueType _:
                questionWidget = new ValidatedTextFieldWidget(new DecimalValue(0), new DecimalValidator(), statement, environment, style);
                break;

            case IntegerValueType _:
                questionWidget = new ValidatedTextFieldWidget(new IntegerValue(0), new IntegerValidator(), statement, environment, style);
                break;

            case MoneyValueType _:
                questionWidget = new ValidatedTextFieldWidget(new MoneyValue(0), new MoneyValidator(), statement, environment, style);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(statement.Type));
            }

            return(questionWidget);
        }
Example #18
0
 public virtual TResult Visit(QuestionStatement statement, TEnvironment environment)
 {
     statement.Type.Accept(this, environment);
     statement.ComputationExpression?.Accept(this, environment);
     return(default(TResult));
 }
Example #19
0
 public override object Visit(QuestionStatement statement, QuestionVisitorTypeEnvironment environment)
 {
     this.Mappings[statement.Identifier] = statement.Type;
     return(base.Visit(statement, environment));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DuplicateQuestionIdentifierMessage"/> class.
 /// </summary>
 /// <param name="question">The question.</param>
 public DuplicateQuestionIdentifierMessage(QuestionStatement question)
     : base($"Duplicate question name \"{question.Identifier}\" at: {question.SourceCode}")
 {
 }
Example #21
0
 public VoidValueType Visit(QuestionStatement statement, ITypeEnvironment environment)
 {
     environment.AddSymbol(statement.Identifier, statement.Type);
     return(new VoidValueType());
 }
Example #22
0
 public override object Visit(QuestionStatement statement, VisitorTypeEnvironment environment)
 {
     this.Variables.Add(statement.Identifier);
     return(base.Visit(statement, environment));
 }
Example #23
0
 public override object Visit(QuestionStatement statement, VisitorTypeEnvironment environment)
 {
     statement.ComputationExpression?.Accept(this, environment);
     return(default(object));
 }
Example #24
0
 public DuplicateQuestionLabelMessage(QuestionStatement question)
     : base($"Duplicate question label \"{question.Label}\" at: {question.SourceCode}")
 {
 }