source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs @ 16776

Last change on this file since 16776 was 16776, checked in by chaider, 11 months ago

#2971

  • Added Expression change event
  • Added errorProvider Validation
File size: 2.9 KB
Line 
1using System;
2using System.ComponentModel;
3using System.Drawing;
4using System.Runtime.CompilerServices;
5using HeuristicLab.Common;
6using HeuristicLab.Core;
7using HeuristicLab.Problems.DataAnalysis.Annotations;
8using HEAL.Attic;
9
10namespace HeuristicLab.Problems.DataAnalysis {
11  [StorableType("8109BE58-CCFB-4462-A2F4-EEE5DFADAFF7")]
12  [Item("Interval Constraint", "Constraint on intervals.")]
13  public class IntervalConstraint : NamedItem {
14    private string expression;
15    public string Expression {
16      get => expression;
17      set {
18        if (value != expression) {
19          expression = value;
20        }
21      }
22    }
23    public string Definition { get; set; }
24    public Interval Interval { get; set; }
25    private bool inclusiveLowerBound;
26
27    public bool InclusiveLowerBound {
28      get => inclusiveLowerBound;
29      set {
30        if (value != inclusiveLowerBound) {
31          inclusiveLowerBound = value;
32          OnChanged(EventArgs.Empty);
33        }
34      }
35    }
36    public bool InclusiveUpperBound { get; set; }
37    public bool IsDerivation { get; set; }
38
39    private string variable;
40    public string Variable {
41      get => variable;
42      set {
43        if (value != variable) {
44          variable = value;
45          OnChanged(EventArgs.Empty);
46        }
47      }
48    }
49    public int NumberOfDerivation { get; set; }
50
51    public IntervalConstraint() {}
52
53    public IntervalConstraint(string name) {
54      base.name = name;
55    }
56
57    public IntervalConstraint(string expression, string definition, Interval interval, bool inclusiveLowerBound,
58      bool inclusiveUpperBound, bool isDerivation, string variable, int numberOfDerivation) {
59      base.name = expression;
60      Expression = expression;
61      Definition = definition;
62      Interval = interval;
63      InclusiveLowerBound = inclusiveLowerBound;
64      InclusiveUpperBound = inclusiveUpperBound;
65      IsDerivation = isDerivation;
66      Variable = variable;
67      NumberOfDerivation = numberOfDerivation;
68    }
69
70    public override IDeepCloneable Clone(Cloner cloner) {
71      return new IntervalConstraint(this, cloner);
72    }
73
74    protected IntervalConstraint(IntervalConstraint original, Cloner cloner)
75      : base(original, cloner) {
76      this.Expression = original.Expression;
77      this.Definition = original.Definition;
78      this.Interval = original.Interval;
79      this.InclusiveLowerBound = original.InclusiveLowerBound;
80      this.InclusiveUpperBound = original.InclusiveUpperBound;
81      this.IsDerivation = original.IsDerivation;
82      this.Variable = original.Variable;
83      this.NumberOfDerivation = original.NumberOfDerivation;
84    }
85
86    public event EventHandler Changed;
87    protected virtual void OnChanged(EventArgs e) {
88      EventHandler handlers = Changed;
89      if (handlers != null)
90        handlers(this, e);
91    }
92  }
93}
Note: See TracBrowser for help on using the repository browser.