Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingAlgorithmView.cs @ 16582

Last change on this file since 16582 was 16582, checked in by ddorfmei, 5 years ago

#2931: solved the issues found during the review

File size: 2.6 KB
Line 
1using System;
2using System.Windows.Forms;
3using HeuristicLab.ExactOptimization.LinearProgramming;
4using HeuristicLab.MainForm;
5using HeuristicLab.Optimization.Views;
6using HeuristicLab.PluginInfrastructure;
7
8namespace HeuristicLab.ExactOptimization.Views {
9
10  [View(nameof(LinearProgrammingAlgorithmView))]
11  [Content(typeof(LinearProgrammingAlgorithm), IsDefaultView = true)]
12  public partial class LinearProgrammingAlgorithmView : BasicAlgorithmView {
13    public LinearProgrammingAlgorithmView() {
14      InitializeComponent();
15    }
16
17    protected override void newProblemButton_Click(object sender, EventArgs e) {
18      ((LinearProblem)Content.Problem).ProblemDefinition = new ProgrammableLinearProblemDefinition();
19    }
20
21    protected override void openProblemButton_Click(object sender, EventArgs e) {
22      openFileDialog.Title = "Import Model";
23      openFileDialog.Filter = "All Supported Files (*.mps;*.bin;*.prototxt)|*.mps;*.bin;*.prototxt|" +
24                              "Mathematical Programming System Files (*.mps)|*.mps|" +
25                              "Google OR-Tools Protocol Buffers Files (*.bin;*.prototxt)|*.bin;*.prototxt|" +
26                              "All Files (*.*)|*.*";
27
28      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
29        newProblemButton.Enabled = openProblemButton.Enabled = false;
30        problemViewHost.Enabled = false;
31
32        try {
33          ((LinearProblem)Content.Problem).ProblemDefinition = new FileBasedLinearProblemDefinition {
34            FileName = openFileDialog.FileName
35          };
36        } catch (Exception ex) {
37          ErrorHandling.ShowErrorDialog(this, ex);
38        } finally {
39          problemViewHost.Enabled = true;
40          newProblemButton.Enabled = openProblemButton.Enabled = true;
41        }
42      }
43    }
44
45    private void exportModelButton_Click(object sender, EventArgs e) {
46      saveFileDialog.Title = "Export Model";
47      saveFileDialog.Filter = "CPLEX LP File (*.lp)|*.lp|" +
48                              "Mathematical Programming System File (*.mps)|*.mps|" +
49                              "Google OR-Tools Protocol Buffers Text File (*.prototxt)|*.prototxt|" +
50                              "Google OR-Tools Protocol Buffers Binary File (*.bin)|*.bin";
51
52      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
53        ((LinearProblem)Content.Problem).ExportModel(saveFileDialog.FileName);
54      }
55    }
56
57    private void showInRunCheckBox_CheckedChanged(object sender, EventArgs e) {
58      if (Content != null)
59        ((LinearProblem)Content.Problem).ProblemDefinitionParameter.GetsCollected = showInRunCheckBox.Checked;
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.