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)); }
protected QuestionWidget(IValue value, QuestionStatement statement, GuiEnvironment guiEnvironment) : base(guiEnvironment) { this.Statement = statement; this.Value = value; this.Dependencies.UnionWith(statement.GetDependencies()); }
public TextFieldWidget( IValue value, QuestionStatement statement, GuiEnvironment guiEnvironment, WidgetStyle style) : base(value, statement, guiEnvironment) { this.CreateControls(statement, style); }
public DatePickerWidget( DateValue value, QuestionStatement statement, GuiEnvironment guiEnvironment, WidgetStyle style) : base(value, statement, guiEnvironment) { this.CreateControls(statement, style); }
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)); }
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; }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); }
public virtual TResult Visit(QuestionStatement statement, TEnvironment environment) { statement.Type.Accept(this, environment); statement.ComputationExpression?.Accept(this, environment); return(default(TResult)); }
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}") { }
public VoidValueType Visit(QuestionStatement statement, ITypeEnvironment environment) { environment.AddSymbol(statement.Identifier, statement.Type); return(new VoidValueType()); }
public override object Visit(QuestionStatement statement, VisitorTypeEnvironment environment) { this.Variables.Add(statement.Identifier); return(base.Visit(statement, environment)); }
public override object Visit(QuestionStatement statement, VisitorTypeEnvironment environment) { statement.ComputationExpression?.Accept(this, environment); return(default(object)); }
public DuplicateQuestionLabelMessage(QuestionStatement question) : base($"Duplicate question label \"{question.Label}\" at: {question.SourceCode}") { }