source: branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.cs @ 16405

Last change on this file since 16405 was 16405, checked in by ddorfmei, 7 months ago

#2931:

  • moved views to separate plugin HeuristicLab.MathematicalOptimization.Views
  • added button in LinearProgrammingProblemView to select the problem definition type
  • added views for problem definitions
  • added ExportFile parameter to LinearProgrammingAlgorithm
  • extended FileValue and FileValueView by the option to save a file
  • code cleanup
File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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;
23using System.Drawing;
24using HeuristicLab.MainForm;
25using HeuristicLab.MathematicalOptimization.LinearProgramming;
26using HeuristicLab.PluginInfrastructure;
27using HeuristicLab.Problems.Programmable;
28using HeuristicLab.Scripting.Views;
29
30namespace HeuristicLab.MathematicalOptimization.Views {
31
32  [View(nameof(ProgrammableLinearProgrammingProblemDefinitionView))]
33  [Content(typeof(ProgrammableLinearProgrammingProblemDefinition), IsDefaultView = true)]
34  public partial class ProgrammableLinearProgrammingProblemDefinitionView : ScriptView {
35
36    public ProgrammableLinearProgrammingProblemDefinitionView() {
37      InitializeComponent();
38    }
39
40    public new ProgrammableLinearProgrammingProblemDefinition Content {
41      get => (ProgrammableLinearProgrammingProblemDefinition)base.Content;
42      set => base.Content = value;
43    }
44
45    public override bool Compile() {
46      try {
47        base.Compile();
48      } catch (ProblemDefinitionScriptException e) {
49        ErrorHandling.ShowErrorDialog(e);
50        return false;
51      }
52      return true;
53    }
54
55    protected override void Content_CodeChanged(object sender, EventArgs e) {
56      base.Content_CodeChanged(sender, e);
57      UpdateInfoTextLabel("Code changed, compilation necessary!", Color.Red);
58    }
59
60    protected override void OnContentChanged() {
61      base.OnContentChanged();
62      variableStoreView.Content = Content?.VariableStore;
63    }
64
65    protected override void SetEnabledStateOfControls() {
66      base.SetEnabledStateOfControls();
67      variableStoreView.Enabled = Content != null && !Locked && !ReadOnly;
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.