Changeset 17953 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs
- Timestamp:
- 04/21/21 15:27:58 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs
r17461 r17953 1 #region License Information2 / * HeuristicLab3 * Copyright (C) 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 modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation, either version 3 of the License, or10 * (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 of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.19 */20 #endregion1 //#region License Information 2 ///* HeuristicLab 3 // * Copyright (C) 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 21 22 using System; 23 using System.Windows.Forms; 24 using HeuristicLab.Collections; 25 using HeuristicLab.Encodings.ScheduleEncoding; 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Optimization.Views; 22 //TODO: ProblemView - Refactor to new problem view and add visualization 28 23 29 namespace HeuristicLab.Problems.Scheduling.Views { 30 [View("JobShop Scheduling Problem View")] 31 [Content(typeof(JobShopSchedulingProblem), true)] 32 public partial class JobShopSchedulingProblemView : ProblemView { 24 //using System; 25 //using System.Windows.Forms; 26 //using HeuristicLab.Collections; 27 //using HeuristicLab.Encodings.ScheduleEncoding; 28 //using HeuristicLab.MainForm; 29 //using HeuristicLab.Optimization.Views; 33 30 34 public new JobShopSchedulingProblem Content{35 get { return (JobShopSchedulingProblem)base.Content; } 36 set { base.Content = value; } 37 } 31 //namespace HeuristicLab.Problems.Scheduling.Views { 32 // [View("JobShop Scheduling Problem View")] 33 // [Content(typeof(JobShopSchedulingProblem), true)] 34 // public partial class JobShopSchedulingProblemView : ProblemView { 38 35 39 public JobShopSchedulingProblemView() { 40 InitializeComponent(); 41 Controls.Remove(parameterCollectionView); 42 parameterCollectionView.Dock = DockStyle.Fill; 43 problemTabPage.Controls.Add(parameterCollectionView); 44 } 36 // public new JobShopSchedulingProblem Content { 37 // get { return (JobShopSchedulingProblem)base.Content; } 38 // set { base.Content = value; } 39 // } 45 40 46 protected override void OnContentChanged() { 47 base.OnContentChanged(); 48 FillGanttChart(); 49 } 41 // public JobShopSchedulingProblemView() { 42 // InitializeComponent(); 43 // Controls.Remove(parameterCollectionView); 44 // parameterCollectionView.Dock = DockStyle.Fill; 45 // problemTabPage.Controls.Add(parameterCollectionView); 46 // } 50 47 51 protected override void DeregisterContentEvents() { 52 Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged; 53 Content.JobData.ItemsAdded -= JobsOnChanged; 54 Content.JobData.ItemsRemoved -= JobsOnRemoved; 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 += JobsOnRemoved; 67 Content.JobData.ItemsReplaced += JobsOnChanged; 68 Content.JobData.CollectionReset += JobsOnChanged; 69 foreach (var job in Content.JobData) { 70 job.TasksChanged += JobOnTasksChanged; 71 } 72 } 48 // protected override void OnContentChanged() { 49 // base.OnContentChanged(); 50 // FillGanttChart(); 51 // } 73 52 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 } 53 // protected override void DeregisterContentEvents() { 54 // Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged; 55 // Content.JobData.ItemsAdded -= JobsOnChanged; 56 // Content.JobData.ItemsRemoved -= JobsOnRemoved; 57 // Content.JobData.ItemsReplaced -= JobsOnChanged; 58 // Content.JobData.CollectionReset -= JobsOnChanged; 59 // foreach (var job in Content.JobData) { 60 // job.TasksChanged -= JobOnTasksChanged; 61 // } 62 // base.DeregisterContentEvents(); 63 // } 64 // protected override void RegisterContentEvents() { 65 // base.RegisterContentEvents(); 66 // Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged; 67 // Content.JobData.ItemsAdded += JobsOnChanged; 68 // Content.JobData.ItemsRemoved += JobsOnRemoved; 69 // Content.JobData.ItemsReplaced += JobsOnChanged; 70 // Content.JobData.CollectionReset += JobsOnChanged; 71 // foreach (var job in Content.JobData) { 72 // job.TasksChanged += JobOnTasksChanged; 73 // } 74 // } 81 75 82 private void JobsOnRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) { 83 foreach (var job in e.Items) 84 job.Value.TasksChanged -= JobOnTasksChanged; 85 FillGanttChart(); 86 } 76 // private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) { 77 // foreach (var job in e.OldItems) 78 // job.Value.TasksChanged -= JobOnTasksChanged; 79 // foreach (var job in e.Items) 80 // job.Value.TasksChanged += JobOnTasksChanged; 81 // FillGanttChart(); 82 // } 87 83 88 private void JobDataParameterOnValueChanged(object sender, EventArgs e) { 89 Content.JobData.ItemsAdded += JobsOnChanged; 90 Content.JobData.ItemsRemoved += JobsOnRemoved; 91 Content.JobData.ItemsReplaced += JobsOnChanged; 92 Content.JobData.CollectionReset += JobsOnChanged; 93 foreach (var job in Content.JobData) { 94 job.TasksChanged += JobOnTasksChanged; 95 } 96 FillGanttChart(); 97 } 84 // private void JobsOnRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) { 85 // foreach (var job in e.Items) 86 // job.Value.TasksChanged -= JobOnTasksChanged; 87 // FillGanttChart(); 88 // } 98 89 99 private void JobOnTasksChanged(object sender, EventArgs e) { 100 FillGanttChart(); 101 } 90 // private void JobDataParameterOnValueChanged(object sender, EventArgs e) { 91 // Content.JobData.ItemsAdded += JobsOnChanged; 92 // Content.JobData.ItemsRemoved += JobsOnRemoved; 93 // Content.JobData.ItemsReplaced += JobsOnChanged; 94 // Content.JobData.CollectionReset += JobsOnChanged; 95 // foreach (var job in Content.JobData) { 96 // job.TasksChanged += JobOnTasksChanged; 97 // } 98 // FillGanttChart(); 99 // } 102 100 103 private void FillGanttChart() { 104 ganttChart.Reset(); 105 if (Content == null) return; 106 int jobCount = 0; 107 foreach (var j in Content.JobData) { 108 double lastEndTime = 0; 109 foreach (var t in Content.JobData[jobCount].Tasks) { 110 int categoryNr = t.JobNr; 111 string categoryName = "Job" + categoryNr; 112 ganttChart.AddData(categoryName, 113 categoryNr, 114 t.TaskNr, 115 lastEndTime + 1, 116 lastEndTime + t.Duration, 117 "Job" + t.JobNr + " - " + "Task#" + t.TaskNr); 118 lastEndTime += t.Duration; 119 } 120 jobCount++; 121 } 122 } 123 } 124 } 101 // private void JobOnTasksChanged(object sender, EventArgs e) { 102 // FillGanttChart(); 103 // } 104 105 // private void FillGanttChart() { 106 // ganttChart.Reset(); 107 // if (Content == null) return; 108 // int jobCount = 0; 109 // foreach (var j in Content.JobData) { 110 // double lastEndTime = 0; 111 // foreach (var t in Content.JobData[jobCount].Tasks) { 112 // int categoryNr = t.JobNr; 113 // string categoryName = "Job" + categoryNr; 114 // ganttChart.AddData(categoryName, 115 // categoryNr, 116 // t.TaskNr, 117 // lastEndTime + 1, 118 // lastEndTime + t.Duration, 119 // "Job" + t.JobNr + " - " + "Task#" + t.TaskNr); 120 // lastEndTime += t.Duration; 121 // } 122 // jobCount++; 123 // } 124 // } 125 // } 126 //}
Note: See TracChangeset
for help on using the changeset viewer.