source: branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/PathValue.cs @ 16405

Last change on this file since 16405 was 16405, checked in by ddorfmei, 3 months ago

#2931:

  • moved views to separate plugin HeuristicLab.MathematicalOptimization.Views
  • added button in LinearProgrammingProblemView to select the problem definition type
  • added views for problem definitions
  • added ExportFile parameter to LinearProgrammingAlgorithm
  • extended FileValue and FileValueView by the option to save a file
  • code cleanup
File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.IO;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Data {
29  [Item("PathValue", "Represents a path.")]
30  [StorableClass]
31  public abstract class PathValue : Item {
32
33    public EventHandler PathChanged;
34
35    [Storable]
36    private readonly StringValue stringValue = new StringValue();
37    public StringValue StringValue {
38      get { return stringValue; }
39    }
40
41    public string Value {
42      get { return stringValue.Value; }
43      set {
44        if (value == null) value = string.Empty;
45        value = value.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
46        stringValue.Value = value;
47        OnPathChanged();
48      }
49    }
50
51    [StorableConstructor]
52    protected PathValue(bool deserializing) : base(deserializing) { }
53    protected PathValue(PathValue original, Cloner cloner)
54      : base(original, cloner) {
55      stringValue = cloner.Clone(original.stringValue);
56    }
57
58    protected PathValue()
59      : base() {
60      stringValue.ToStringChanged += (o, e) => OnToStringChanged();
61    }
62
63    protected virtual void OnPathChanged() {
64      EventHandler handler = PathChanged;
65      if (handler != null) handler(this, EventArgs.Empty);
66    }
67
68    [StorableHook(HookType.AfterDeserialization)]
69    private void AfterDeserialization() {
70      stringValue.ToStringChanged += (o, e) => OnToStringChanged();
71    }
72
73    public abstract bool Exists();
74
75    public override string ToString() {
76      return stringValue.ToString();
77    }
78
79  }
80}
Note: See TracBrowser for help on using the repository browser.