1 | using System;
|
---|
2 |
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.MainForm;
|
---|
5 | using HeuristicLab.MainForm.WindowsForms;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
|
---|
8 | [View("ParsedConstraint View")]
|
---|
9 | [Content(typeof(ParsedConstraint), true)]
|
---|
10 | public partial class ParsedConstraintView : AsynchronousContentView {
|
---|
11 |
|
---|
12 | public new ParsedConstraint Content {
|
---|
13 | get => (ParsedConstraint)base.Content;
|
---|
14 | set => base.Content = value;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public ParsedConstraintView() {
|
---|
18 | InitializeComponent();
|
---|
19 | errorOutput.Text = "";
|
---|
20 | }
|
---|
21 |
|
---|
22 | protected override void OnContentChanged() {
|
---|
23 | base.OnContentChanged();
|
---|
24 | if (Content == null) {
|
---|
25 | constraintsInput.Text = string.Empty;
|
---|
26 | errorOutput.Text = "";
|
---|
27 | } else {
|
---|
28 | constraintsInput.Text = Content.Input;
|
---|
29 | constraintsOutput.Content = new ItemList<IntervalConstraint>(Content.Constraints) ?? new ItemList<IntervalConstraint>();
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | private ItemList<IntervalConstraint> ParseConstraints(string input) {
|
---|
34 | ItemList<IntervalConstraint> constraints = new ItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.TargetVariable, Content.AllowedVariables));
|
---|
35 | return constraints;
|
---|
36 | }
|
---|
37 |
|
---|
38 | private void parseBtn_Click(object sender, EventArgs e) {
|
---|
39 | if (constraintsInput.Text != null) {
|
---|
40 | var constaints = ParseConstraints(constraintsInput.Text);
|
---|
41 | constraintsOutput.Content = constaints;
|
---|
42 | Content.Constraints = constaints;
|
---|
43 | Content.Input = constraintsInput.Text;
|
---|
44 | errorOutput.Text = "";
|
---|
45 | } else {
|
---|
46 | errorOutput.Text = "No constraints were found!";
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | private void constraintsInput_TextChanged(object sender, EventArgs e) {
|
---|
51 | errorOutput.Text = "Unparsed changes! Press parse button to save changes.";
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|