Free cookie consent management tool by TermsFeed Policy Generator

source: branches/QAP/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs @ 5583

Last change on this file since 5583 was 5583, checked in by abeham, 12 years ago

#1330

  • Worked on QAP
    • Added solution and analyzer
    • Added crude solution view
  • Overwrote instances with those from new QAPLIB site (Pennsylvania)
File size: 3.0 KB
Line 
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
22using System.Windows.Forms;
23using HeuristicLab.Common.Resources;
24using HeuristicLab.Core.Views;
25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27
28namespace HeuristicLab.Problems.QuadraticAssignment.Views {
29  [View("Quadratic Assignment Problem View")]
30  [Content(typeof(QuadraticAssignmentProblem), IsDefaultView = true)]
31  public sealed partial class QuadraticAssignmentProblemView : ParameterizedNamedItemView {
32    public new QuadraticAssignmentProblem Content {
33      get { return (QuadraticAssignmentProblem)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public QuadraticAssignmentProblemView() {
38      InitializeComponent();
39      importInstanceButton.Image = VSImageLibrary.Open;
40    }
41
42    protected override void OnContentChanged() {
43      base.OnContentChanged();
44      instancesComboBox.Items.Clear();
45      if (Content != null) {
46        foreach (string instance in Content.EmbeddedInstances) {
47          instancesComboBox.Items.Add(instance);
48        }
49      }
50    }
51
52    protected override void SetEnabledStateOfControls() {
53      base.SetEnabledStateOfControls();
54      instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null;
55      loadInstanceButton.Enabled = !ReadOnly && !Locked && Content != null && instancesComboBox.SelectedItem != null;
56      importInstanceButton.Enabled = !ReadOnly && !Locked && Content != null;
57    }
58
59    private void instancesComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
60      loadInstanceButton.Enabled = instancesComboBox.SelectedItem != null;
61    }
62
63    private void loadInstanceButton_Click(object sender, System.EventArgs e) {
64      string instance = instancesComboBox.SelectedItem as string;
65      Content.LoadEmbeddedInstance(instance);
66    }
67
68    private void importInstanceButton_Click(object sender, System.EventArgs e) {
69      if (openFileDialog.ShowDialog() == DialogResult.OK) {
70        Content.ImportFileInstance(openFileDialog.FileName);
71      }
72    }
73
74    private void QAPLIBInstancesLabel_Click(object sender, System.EventArgs e) {
75      System.Diagnostics.Process.Start("http://www.seas.upenn.edu/qaplib/");
76    }
77  }
78}
Note: See TracBrowser for help on using the repository browser.