source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs @ 16773

Last change on this file since 16773 was 16773, checked in by chaider, 10 months ago

#2971

  • Fixes and updates in IntervalConstraintView
  • Changed Parser
File size: 1.8 KB
Line 
1using System;
2
3using HeuristicLab.Core;
4using HeuristicLab.MainForm;
5using HeuristicLab.MainForm.WindowsForms;
6
7namespace 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}
Note: See TracBrowser for help on using the repository browser.