Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Analysis/3.3/DataVisualization/GanttData.cs @ 14836

Last change on this file since 14836 was 14737, checked in by abeham, 8 years ago

#2744:

  • GanttData: Derived from NamedItem instead of Item and implement appropriate constructors
  • GanttRow: Implemented appropriate constructors and choosing a default name
  • GanttDataView: Added additional event handler for tracking category colors dictionary
  • GanttDataView: Set title property of GanttChart
  • GanttChart: Added a title (which is hidden by default)
File size: 6.3 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23
24using System;
25using System.Collections.Generic;
26using System.ComponentModel;
27using System.Drawing;
28using HeuristicLab.Collections;
29using HeuristicLab.Common;
30using HeuristicLab.Core;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32
33namespace HeuristicLab.Analysis {
34  [Item("Gantt Data", "Data of a Gantt visualization")]
35  [StorableClass]
36  public class GanttData : NamedItem {
37
38    [Storable]
39    private NamedItemCollection<GanttRow> rows;
40    public NamedItemCollection<GanttRow> Rows { get { return rows; } }
41
42    [Storable]
43    private ObservableDictionary<string, Color> categoryColors;
44    public ObservableDictionary<string, Color> CategoryColors { get { return categoryColors; } }
45
46    [StorableConstructor]
47    protected GanttData(bool deserializing) : base(deserializing) {}
48    protected GanttData(GanttData original, Cloner cloner)
49      : base(original, cloner) {
50      rows = cloner.Clone(original.rows);
51      categoryColors = new ObservableDictionary<string, Color>(original.categoryColors);
52    }
53    public GanttData() : this("Gantt Data", "Data of a Gantt visualization") { }
54    public GanttData(string name) : this(name, string.Empty) { }
55    public GanttData(string name, string description) : base(name, description) {
56      rows = new NamedItemCollection<GanttRow>();
57      categoryColors = new ObservableDictionary<string, Color>();
58    }
59    public GanttData(IEnumerable<GanttRow> rows) : this("Gantt Data", rows) { }
60    public GanttData(string name, IEnumerable<GanttRow> rows) : this(name, string.Empty, rows) { }
61    public GanttData(string name, string description, IEnumerable<GanttRow> rows) : base(name, description) {
62      this.rows = new NamedItemCollection<GanttRow>(rows);
63      categoryColors = new ObservableDictionary<string, Color>();
64    }
65
66    public override IDeepCloneable Clone(Cloner cloner) {
67      return new GanttData(this, cloner);
68    }
69  }
70
71  [Item("Gantt Row", "Row of a Gantt chart")]
72  [StorableClass]
73  public class GanttRow : NamedItem {
74    [Storable]
75    private ItemList<GanttItem> items;
76    public ItemList<GanttItem> Items { get { return items; } }
77
78    [StorableConstructor]
79    protected GanttRow(bool deserializing) : base(deserializing) {}
80    protected GanttRow(GanttRow original, Cloner cloner)
81      : base(original, cloner) {
82      items = cloner.Clone(original.items);
83    }
84    public GanttRow() : this("Gantt Row", "Row of a Gantt chart") { }
85    public GanttRow(string name) : this(name, string.Empty) { }
86    public GanttRow(string name, string description) : base(name, description) {
87      items = new ItemList<GanttItem>();
88    }
89    public GanttRow(IEnumerable<GanttItem> items) : this("Gantt Row", items) { }
90    public GanttRow(string name, IEnumerable<GanttItem> items) : this(name, string.Empty, items) { }
91    public GanttRow(string name, string description, IEnumerable<GanttItem> items) : base(name, description) {
92      this.items = new ItemList<GanttItem>(items);
93    }
94
95    public override IDeepCloneable Clone(Cloner cloner) {
96      return new GanttRow(this, cloner);
97    }
98  }
99
100  [Item("Gantt Item", "Item of a Gantt chart row")]
101  [StorableClass]
102  public class GanttItem : Item, INotifyPropertyChanged {
103
104    [Storable]
105    private DateTime startDate;
106    public DateTime StartDate {
107      get { return startDate; }
108      set {
109        if (startDate == value) return;
110        startDate = value;
111        OnPropertyChanged("StartDate");
112      }
113    }
114
115    [Storable]
116    private DateTime endDate;
117    public DateTime EndDate {
118      get { return endDate; }
119      set {
120        if (endDate == value) return;
121        endDate = value;
122        OnPropertyChanged("EndDate");
123      }
124    }
125
126    [Storable]
127    private string toolTip;
128    public string ToolTip {
129      get { return toolTip; }
130      set {
131        if (toolTip == value) return;
132        toolTip = value;
133        OnPropertyChanged("ToolTip");
134      }
135    }
136
137    [Storable]
138    private string category;
139    public string Category {
140      get { return category; }
141      set {
142        if (category == value) return;
143        category = value;
144        OnPropertyChanged("Category");
145      }
146    }
147
148    [Storable]
149    private bool showLabel;
150    public bool ShowLabel {
151      get { return showLabel; }
152      set {
153        if (showLabel == value) return;
154        showLabel = value;
155        OnPropertyChanged("ShowLabel");
156      }
157    }
158
159    [StorableConstructor]
160    protected GanttItem(bool deserializing) : base(deserializing) { }
161    protected GanttItem(GanttItem original, Cloner cloner)
162      : base(original, cloner) {
163      startDate = original.startDate;
164      endDate = original.endDate;
165      toolTip = original.toolTip;
166      category = original.category;
167      showLabel = original.showLabel;
168    }
169    public GanttItem() : this(DateTime.Now, DateTime.Now) { }
170    public GanttItem(DateTime start, DateTime end) {
171      startDate = start;
172      endDate = end;
173      toolTip = string.Empty;
174      category = string.Empty;
175      showLabel = false;
176    }
177
178    public override IDeepCloneable Clone(Cloner cloner) {
179      return new GanttItem(this, cloner);
180    }
181
182    public event PropertyChangedEventHandler PropertyChanged;
183    protected virtual void OnPropertyChanged(string propertyName) {
184      var handler = PropertyChanged;
185      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
186    }
187  }
188}
Note: See TracBrowser for help on using the repository browser.