[16756] | 1 | using System;
|
---|
[16773] | 2 |
|
---|
[16772] | 3 | using HeuristicLab.Core;
|
---|
[16756] | 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 | }
|
---|
[16773] | 16 |
|
---|
[16756] | 17 | public ParsedConstraintView() {
|
---|
| 18 | InitializeComponent();
|
---|
[16772] | 19 | errorOutput.Text = "";
|
---|
[16756] | 20 | }
|
---|
| 21 |
|
---|
| 22 | protected override void OnContentChanged() {
|
---|
| 23 | base.OnContentChanged();
|
---|
| 24 | if (Content == null) {
|
---|
| 25 | constraintsInput.Text = string.Empty;
|
---|
[16772] | 26 | errorOutput.Text = "";
|
---|
| 27 | } else {
|
---|
[16756] | 28 | constraintsInput.Text = Content.Input;
|
---|
[16772] | 29 | constraintsOutput.Content = new ItemList<IntervalConstraint>(Content.Constraints) ?? new ItemList<IntervalConstraint>();
|
---|
[16756] | 30 | }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
[16772] | 33 | private ItemList<IntervalConstraint> ParseConstraints(string input) {
|
---|
[16773] | 34 | ItemList<IntervalConstraint> constraints = new ItemList<IntervalConstraint>(IntervalConstraintsParser.ParseInput(input, Content.TargetVariable, Content.AllowedVariables));
|
---|
[16772] | 35 | return constraints;
|
---|
[16756] | 36 | }
|
---|
| 37 |
|
---|
| 38 | private void parseBtn_Click(object sender, EventArgs e) {
|
---|
| 39 | if (constraintsInput.Text != null) {
|
---|
[16772] | 40 | var constaints = ParseConstraints(constraintsInput.Text);
|
---|
| 41 | constraintsOutput.Content = constaints;
|
---|
| 42 | Content.Constraints = constaints;
|
---|
[16756] | 43 | Content.Input = constraintsInput.Text;
|
---|
[16772] | 44 | errorOutput.Text = "";
|
---|
| 45 | } else {
|
---|
| 46 | errorOutput.Text = "No constraints were found!";
|
---|
[16756] | 47 | }
|
---|
| 48 | }
|
---|
[16772] | 49 |
|
---|
| 50 | private void constraintsInput_TextChanged(object sender, EventArgs e) {
|
---|
| 51 | errorOutput.Text = "Unparsed changes! Press parse button to save changes.";
|
---|
| 52 | }
|
---|
[16756] | 53 | }
|
---|
| 54 | }
|
---|