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.Windows.Forms;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Core.Views;
|
---|
26 | using HeuristicLab.Data;
|
---|
27 | using HeuristicLab.MainForm;
|
---|
28 | using HeuristicLab.Parameters;
|
---|
29 | using HeuristicLab.PluginInfrastructure;
|
---|
30 | using System.Drawing;
|
---|
31 |
|
---|
32 | namespace HeuristicLab.Problems.Scheduling.Views {
|
---|
33 | [View("JobShop Scheduling Problem View")]
|
---|
34 | [Content(typeof(JobShopSchedulingProblem), true)]
|
---|
35 | public partial class JobShopSchedulingProblemView : NamedItemView {
|
---|
36 | public JobShopSchedulingProblemView() {
|
---|
37 | InitializeComponent();
|
---|
38 | }
|
---|
39 | private SchedulingProblemImportDialog spImportDialog;
|
---|
40 |
|
---|
41 | public new JobShopSchedulingProblem Content {
|
---|
42 | get { return (JobShopSchedulingProblem)base.Content; }
|
---|
43 | set { base.Content = value; }
|
---|
44 | }
|
---|
45 |
|
---|
46 | protected override void OnContentChanged() {
|
---|
47 | base.OnContentChanged();
|
---|
48 | if (Content == null) {
|
---|
49 | parameterCollectionView.Content = null;
|
---|
50 | ganttChart.Reset();
|
---|
51 | } else {
|
---|
52 | parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
|
---|
53 | FillGanttChart(Content);
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | private void FillGanttChart(JobShopSchedulingProblem content) {
|
---|
58 | //Add Jobs as Categories
|
---|
59 | ganttChart.Reset();
|
---|
60 | int jobCount = 0;
|
---|
61 | Random random = new Random(1);
|
---|
62 | foreach (Job j in content.JobData) {
|
---|
63 | double lastEndTime = 0;
|
---|
64 | foreach (Task t in content.JobData[jobCount].Tasks) {
|
---|
65 | int categoryNr = t.JobNr.Value;
|
---|
66 | string categoryName = "Job" + categoryNr;
|
---|
67 | ganttChart.AddJobColor(categoryNr);
|
---|
68 | ganttChart.AddData(categoryName,
|
---|
69 | categoryNr,
|
---|
70 | lastEndTime + 1,
|
---|
71 | lastEndTime + t.Duration.Value,
|
---|
72 | "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.Value.ToString());
|
---|
73 | lastEndTime += t.Duration.Value;
|
---|
74 | }
|
---|
75 | jobCount++;
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | protected override void SetEnabledStateOfControls() {
|
---|
80 | base.SetEnabledStateOfControls();
|
---|
81 | parameterCollectionView.Enabled = Content != null;
|
---|
82 | importButton.Enabled = Content != null && !ReadOnly;
|
---|
83 | }
|
---|
84 |
|
---|
85 | private void importButton_Click(object sender, EventArgs e) {
|
---|
86 | if (spImportDialog == null) spImportDialog = new SchedulingProblemImportDialog();
|
---|
87 |
|
---|
88 | if (spImportDialog.ShowDialog(this) == DialogResult.OK) {
|
---|
89 | try {
|
---|
90 | switch (spImportDialog.Format) {
|
---|
91 | case SPFormat.ORLib:
|
---|
92 | Content.ImportFromORLibrary(spImportDialog.SPFileName);
|
---|
93 | break;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | if (!string.IsNullOrEmpty(spImportDialog.OptimalScheduleFileName))
|
---|
98 | Content.ImportJSMSolution(spImportDialog.OptimalScheduleFileName);
|
---|
99 | OnContentChanged();
|
---|
100 | }
|
---|
101 | catch (Exception ex) {
|
---|
102 | ErrorHandling.ShowErrorDialog(this, ex);
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|
106 | }
|
---|
107 | }
|
---|