Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/29/19 17:45:06 (5 years ago)
Author:
ddorfmei
Message:

#2931: solved the issues found during the review

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.cs

    r16405 r16582  
    2121
    2222using System;
    23 using System.Windows.Forms;
    2423using HeuristicLab.Core.Views;
     24using HeuristicLab.ExactOptimization.LinearProgramming;
    2525using HeuristicLab.MainForm;
    2626using HeuristicLab.MainForm.WindowsForms;
    27 using HeuristicLab.MathematicalOptimization.LinearProgramming;
    28 using HeuristicLab.PluginInfrastructure;
    2927
    30 namespace HeuristicLab.MathematicalOptimization.Views {
     28namespace HeuristicLab.ExactOptimization.Views {
    3129
    3230  [View(nameof(LinearProgrammingProblemView))]
    33   [Content(typeof(LinearProgrammingProblem), true)]
     31  [Content(typeof(LinearProblem), IsDefaultView = true)]
    3432  public partial class LinearProgrammingProblemView : ItemView {
    3533    protected ViewHost definitionView;
    36 
    37     private TypeSelectorDialog problemTypeSelectorDialog;
    3834
    3935    public LinearProgrammingProblemView() {
     
    4238    }
    4339
    44     public new LinearProgrammingProblem Content {
    45       get => (LinearProgrammingProblem)base.Content;
     40    public new LinearProblem Content {
     41      get => (LinearProblem)base.Content;
    4642      set => base.Content = value;
    4743    }
     
    4945    protected override void DeregisterContentEvents() {
    5046      base.DeregisterContentEvents();
     47      Content.NameChanged -= ContentOnNameChanged;
    5148      Content.ProblemDefinitionChanged -= ContentOnProblemDefinitionChanged;
    52       Content.NameChanged -= ContentOnNameChanged;
    5349    }
    5450
     
    6965    }
    7066
    71     private void changeModelTypeButton_Click(object sender, EventArgs e) {
    72       if (problemTypeSelectorDialog == null) {
    73         problemTypeSelectorDialog = new TypeSelectorDialog { Caption = "Select Model Type" };
    74         problemTypeSelectorDialog.TypeSelector.Caption = "Available Model Types";
    75         problemTypeSelectorDialog.TypeSelector.Configure(typeof(ILinearProgrammingProblemDefinition), false, true);
    76       }
    77       if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    78         try {
    79           Content.ProblemDefinition =
    80             (ILinearProgrammingProblemDefinition)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    81         } catch (Exception ex) {
    82           ErrorHandling.ShowErrorDialog(this, ex);
    83         }
    84       }
    85     }
    86 
    8767    private void ContentOnNameChanged(object sender, EventArgs eventArgs) {
    8868      Caption = Content.Name;
     
    9070
    9171    private void ContentOnProblemDefinitionChanged(object sender, EventArgs eventArgs) {
    92       var problemDefinition = ((LinearProgrammingProblem)sender).ProblemDefinition;
    93       definitionView.Content = problemDefinition;
    94 
    95       switch (problemDefinition) {
    96         case null:
    97           modelTypeNameLabel.Text = "none";
    98           break;
    99 
    100         case ProgrammableLinearProgrammingProblemDefinition _:
    101           modelTypeNameLabel.Text = "Script";
    102           break;
    103 
    104         case FileBasedLinearProgrammingProblemDefinition _:
    105           modelTypeNameLabel.Text = "File";
    106           break;
    107 
    108         default:
    109           throw new NotImplementedException("Unknown problem definition type.");
    110       }
     72      definitionView.Content = ((LinearProblem)sender).ProblemDefinition;
    11173    }
    11274  }
Note: See TracChangeset for help on using the changeset viewer.