Ignore:
Timestamp:
02/20/14 14:29:01 (6 years ago)
Author:
gkronber
Message:

#2124 merged all changes from trunk to prepare for trunk-reintegration

Location:
branches/SpectralKernelForGaussianProcesses
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/SpectralKernelForGaussianProcesses

  • branches/SpectralKernelForGaussianProcesses/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r9456 r10479  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
     24using HeuristicLab.Collections;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2326using HeuristicLab.MainForm;
    2427using HeuristicLab.Optimization.Views;
     
    4346    protected override void OnContentChanged() {
    4447      base.OnContentChanged();
    45       if (Content == null) {
    46         ganttChart.Reset();
    47       } else {
    48         FillGanttChart(Content);
     48      FillGanttChart();
     49    }
     50
     51    protected override void DeregisterContentEvents() {
     52      Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged;
     53      Content.JobData.ItemsAdded -= JobsOnChanged;
     54      Content.JobData.ItemsRemoved -= JobsOnChanged;
     55      Content.JobData.ItemsReplaced -= JobsOnChanged;
     56      Content.JobData.CollectionReset -= JobsOnChanged;
     57      foreach (var job in Content.JobData) {
     58        job.TasksChanged -= JobOnTasksChanged;
     59      }
     60      base.DeregisterContentEvents();
     61    }
     62    protected override void RegisterContentEvents() {
     63      base.RegisterContentEvents();
     64      Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;
     65      Content.JobData.ItemsAdded += JobsOnChanged;
     66      Content.JobData.ItemsRemoved += JobsOnChanged;
     67      Content.JobData.ItemsReplaced += JobsOnChanged;
     68      Content.JobData.CollectionReset += JobsOnChanged;
     69      foreach (var job in Content.JobData) {
     70        job.TasksChanged += JobOnTasksChanged;
    4971      }
    5072    }
    5173
    52     private void FillGanttChart(JobShopSchedulingProblem content) {
     74    private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {
     75      foreach (var job in e.OldItems)
     76        job.Value.TasksChanged -= JobOnTasksChanged;
     77      foreach (var job in e.Items)
     78        job.Value.TasksChanged += JobOnTasksChanged;
     79      FillGanttChart();
     80    }
     81
     82    private void JobDataParameterOnValueChanged(object sender, EventArgs e) {
     83      Content.JobData.ItemsAdded += JobsOnChanged;
     84      Content.JobData.ItemsRemoved += JobsOnChanged;
     85      Content.JobData.ItemsReplaced += JobsOnChanged;
     86      Content.JobData.CollectionReset += JobsOnChanged;
     87      foreach (var job in Content.JobData) {
     88        job.TasksChanged += JobOnTasksChanged;
     89      }
     90      FillGanttChart();
     91    }
     92
     93    private void JobOnTasksChanged(object sender, EventArgs e) {
     94      FillGanttChart();
     95    }
     96
     97    private void FillGanttChart() {
    5398      ganttChart.Reset();
     99      if (Content == null) return;
    54100      int jobCount = 0;
    55       foreach (var j in content.JobData) {
     101      foreach (var j in Content.JobData) {
    56102        double lastEndTime = 0;
    57         foreach (var t in content.JobData[jobCount].Tasks) {
     103        foreach (var t in Content.JobData[jobCount].Tasks) {
    58104          int categoryNr = t.JobNr;
    59105          string categoryName = "Job" + categoryNr;
     
    63109            lastEndTime + 1,
    64110            lastEndTime + t.Duration,
    65             "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.ToString());
     111            "Job" + t.JobNr + " - " + "Task#" + t.TaskNr);
    66112          lastEndTime += t.Duration;
    67113        }
Note: See TracChangeset for help on using the changeset viewer.