Exemplo n.º 1
0
	static Control GroupWidget(Racr.AstNode n) {
		var panel = new FlowLayoutPanel();
		panel.AutoSize = true;
		panel.BorderStyle = BorderStyle.Fixed3D;
		panel.Dock = DockStyle.Fill;
		panel.FlowDirection = FlowDirection.TopDown;
		panel.WrapContents = false;
		n.Parent().Widget().Controls.Add(panel);
		return panel;
	}
Exemplo n.º 2
0
	static Racr.AstNode GroupGLookup(Racr.AstNode n, string name) {
		var ret = findL(name, n.Parent(), n.ChildIndex() - 1);
		return (ret != null) ? ret : n.Parent().GLookup(name);
	}
Exemplo n.º 3
0
	static Racr.AstNode FromGLookup(Racr.AstNode n, string name) {
		var ret = findL(name, n.Parent(), n.ChildIndex() - 1);
		return (ret != null) ? ret : n.ErrorQuestion();
	}
Exemplo n.º 4
0
	static bool QuestionIsActive(Racr.AstNode n) {
		return n.IsErrorQuestion() || (n.Parent().IsActive() && n.FindActive(n.GetName()).IsErrorQuestion());
	}
Exemplo n.º 5
0
	static Control ComputedQuestionWidget(Racr.AstNode n) {
		Widget w;
		if (n.Type() == ValueTypes.Boolean) w = new CheckWidget(n.GetLabel(), false);
		else w = new TextWidget(n.GetLabel(), false);
		n.Parent().Widget().Controls.Add(w);
		return w;
	}
Exemplo n.º 6
0
	static Control OrdinaryQuestionWidget(Racr.AstNode n) {
		Widget w;
		if (n.Type() == ValueTypes.Boolean) {
			w = new CheckWidget(n.GetLabel());
			var cb = w.GetCheckBox();
			cb.CheckedChanged += (object sender, EventArgs e) => {
				if (!cb.ContainsFocus) return;
				n.SetValue(cb.Checked);
				n.Root().Render();
			};
		}
		else {
			w = new TextWidget(n.GetLabel());
			var tb = w.GetTextBox();
			tb.TextChanged += (object sender, EventArgs e) => {
				if (!tb.ContainsFocus) return;
				if (n.Type() == ValueTypes.Number) {
					try { n.SetValue(Convert.ToDouble(tb.Text)); }
					catch { return; }
				}
				else n.SetValue(tb.Text);
				n.Root().Render();
			};
		}
		n.Parent().Widget().Controls.Add(w);
		return w;
	}