1 | #region License Information
|
---|
2 |
|
---|
3 | /* HeuristicLab
|
---|
4 | * Copyright (C) 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 |
|
---|
24 | using System;
|
---|
25 | using System.Collections.Generic;
|
---|
26 | using System.ComponentModel;
|
---|
27 | using System.Drawing;
|
---|
28 | using HeuristicLab.Collections;
|
---|
29 | using HeuristicLab.Common;
|
---|
30 | using HeuristicLab.Core;
|
---|
31 | using HEAL.Attic;
|
---|
32 |
|
---|
33 | namespace HeuristicLab.Analysis {
|
---|
34 | [Item("Gantt Data", "Data of a Gantt visualization")]
|
---|
35 | [StorableType("5EF715EE-23B7-416D-85D0-28C61F81C55D")]
|
---|
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(StorableConstructorFlag _) : base(_) { }
|
---|
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 | [StorableType("DDAA9C4C-CE19-4E0D-9AB2-02F8CDF2B8D4")]
|
---|
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(StorableConstructorFlag _) : base(_) { }
|
---|
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 | [StorableType("E2CEFEAE-AEA4-4F1D-94D5-D7AA784982F5")]
|
---|
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(StorableConstructorFlag _) : base(_) { }
|
---|
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 | }
|
---|