[6121] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2011 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.ComponentModel;
|
---|
| 25 | using System.Drawing;
|
---|
| 26 | using System.Data;
|
---|
| 27 | using System.Linq;
|
---|
| 28 | using System.Text;
|
---|
| 29 | using System.Windows.Forms;
|
---|
| 30 | using HeuristicLab.Core.Views;
|
---|
| 31 | using HeuristicLab.MainForm;
|
---|
| 32 | using HeuristicLab.Core;
|
---|
[6294] | 33 | using HeuristicLab.Encodings.SchedulingEncoding;
|
---|
[6121] | 34 |
|
---|
| 35 | namespace HeuristicLab.Problems.Scheduling.Views {
|
---|
| 36 | [View("Schedule View")]
|
---|
| 37 | [Content(typeof(Schedule), true)]
|
---|
| 38 | public partial class ScheduleView : NamedItemView {
|
---|
| 39 | public ScheduleView() {
|
---|
| 40 | InitializeComponent();
|
---|
| 41 | }
|
---|
| 42 |
|
---|
[6260] | 43 |
|
---|
| 44 | protected override void DeregisterContentEvents() {
|
---|
| 45 | Content.QualityChanged -= new EventHandler(Content_QualityChanged);
|
---|
| 46 | Content.ResourcesChanged -= new EventHandler(Content_ResourcesChanged);
|
---|
| 47 |
|
---|
| 48 | base.DeregisterContentEvents();
|
---|
| 49 | }
|
---|
| 50 | protected override void RegisterContentEvents() {
|
---|
| 51 | base.RegisterContentEvents();
|
---|
| 52 | Content.QualityChanged += new EventHandler(Content_QualityChanged);
|
---|
| 53 | Content.ResourcesChanged += new EventHandler(Content_ResourcesChanged);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 |
|
---|
[6121] | 57 | public new Schedule Content {
|
---|
| 58 | get { return (Schedule)base.Content; }
|
---|
| 59 | set { base.Content = value; }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | protected override void OnContentChanged() {
|
---|
| 63 | base.OnContentChanged();
|
---|
| 64 | if (Content == null) {
|
---|
[6177] | 65 | ResetGanttChart();
|
---|
[6121] | 66 | } else {
|
---|
[6177] | 67 | FillGanttChart(Content);
|
---|
[6121] | 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[6177] | 71 | private void ResetGanttChart() {
|
---|
| 72 | ganttChart.Reset();
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | private void FillGanttChart(Schedule content) {
|
---|
[6260] | 76 | ResetGanttChart();
|
---|
[6177] | 77 | int resCount = 0;
|
---|
[6260] | 78 | Random random = new Random (1);
|
---|
[6177] | 79 | foreach (Resource r in content.Resources) {
|
---|
[6294] | 80 | foreach (ScheduledTask t in content.Resources[resCount].Tasks) {
|
---|
| 81 | int categoryNr = 0;
|
---|
| 82 | string toolTip = "Task#";// +t.TaskNr;
|
---|
[6177] | 83 | string categoryName = "ScheduleTasks";
|
---|
[6294] | 84 | if (t is ScheduledTask) {
|
---|
| 85 | categoryNr = ((ScheduledTask)t).JobNr.Value;
|
---|
[6260] | 86 | categoryName = "Job" + categoryNr;
|
---|
[6177] | 87 | toolTip = categoryName + " - " + toolTip;
|
---|
[6260] | 88 | }
|
---|
| 89 | ganttChart.AddJobColor(categoryNr);
|
---|
[6177] | 90 | ganttChart.AddData("Resource" + r.Index,
|
---|
[6260] | 91 | categoryNr,
|
---|
[6177] | 92 | t.StartTime.Value,
|
---|
| 93 | t.EndTime.Value,
|
---|
[6260] | 94 | toolTip);
|
---|
[6177] | 95 | }
|
---|
| 96 | resCount++;
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[6121] | 100 | protected override void SetEnabledStateOfControls() {
|
---|
| 101 | base.SetEnabledStateOfControls();
|
---|
[6177] | 102 | ganttChart.Enabled = Content != null;
|
---|
[6121] | 103 | }
|
---|
[6260] | 104 |
|
---|
| 105 |
|
---|
| 106 | private void Content_QualityChanged(object sender, EventArgs e) {
|
---|
| 107 | if (InvokeRequired)
|
---|
| 108 | Invoke(new EventHandler(Content_QualityChanged), sender, e);
|
---|
| 109 | else {
|
---|
| 110 | if (Content == null) {
|
---|
| 111 | ResetGanttChart();
|
---|
| 112 | } else {
|
---|
| 113 | FillGanttChart(Content);
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | private void Content_ResourcesChanged(object sender, EventArgs e) {
|
---|
| 119 | if (InvokeRequired)
|
---|
| 120 | Invoke(new EventHandler(Content_ResourcesChanged), sender, e);
|
---|
| 121 | else {
|
---|
| 122 | if (Content == null) {
|
---|
| 123 | ResetGanttChart();
|
---|
| 124 | } else {
|
---|
| 125 | FillGanttChart(Content);
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
[6121] | 129 | }
|
---|
| 130 | }
|
---|