Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 16777 was 16777, checked in by chaider, 5 years ago

#2971
-Fixed Dispose problem
-Added event handling for item selection

File size: 3.4 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    private bool isChecked;
52    public bool IsChecked {
53      get => isChecked;
54      set {
55        if (value != isChecked) {
56          isChecked = value;
57          OnChanged(EventArgs.Empty);
58        }
59      }
60    }
61
62    public IntervalConstraint() {
63      name = "Empty";
64      expression = "Empty";
65      Interval = new Interval(0, 0);
66      inclusiveLowerBound = true;
67      inclusiveLowerBound = true;
68      IsDerivation = false;
69      isChecked = false;
70    }
71
72    public IntervalConstraint(string name) {
73      base.name = name;
74      IsChecked = true;
75    }
76
77    public IntervalConstraint(string expression, string definition, Interval interval, bool inclusiveLowerBound,
78      bool inclusiveUpperBound, bool isDerivation, string variable, int numberOfDerivation, bool isChecked) {
79      base.name = expression;
80      Expression = expression;
81      Definition = definition;
82      Interval = interval;
83      InclusiveLowerBound = inclusiveLowerBound;
84      InclusiveUpperBound = inclusiveUpperBound;
85      IsDerivation = isDerivation;
86      Variable = variable;
87      NumberOfDerivation = numberOfDerivation;
88      IsChecked = isChecked;
89    }
90
91    public override IDeepCloneable Clone(Cloner cloner) {
92      return new IntervalConstraint(this, cloner);
93    }
94
95    protected IntervalConstraint(IntervalConstraint original, Cloner cloner)
96      : base(original, cloner) {
97      this.Expression = original.Expression;
98      this.Definition = original.Definition;
99      this.Interval = original.Interval;
100      this.InclusiveLowerBound = original.InclusiveLowerBound;
101      this.InclusiveUpperBound = original.InclusiveUpperBound;
102      this.IsDerivation = original.IsDerivation;
103      this.Variable = original.Variable;
104      this.NumberOfDerivation = original.NumberOfDerivation;
105      this.isChecked = original.isChecked;
106    }
107
108    public event EventHandler Changed;
109    protected virtual void OnChanged(EventArgs e) {
110      EventHandler handlers = Changed;
111      if (handlers != null)
112        handlers(this, e);
113    }
114  }
115}
Note: See TracBrowser for help on using the repository browser.