Changeset 16582 for branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.cs
- Timestamp:
- 01/29/19 17:45:06 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.cs
r16405 r16582 21 21 22 22 using System; 23 using System.Windows.Forms;24 23 using HeuristicLab.Core.Views; 24 using HeuristicLab.ExactOptimization.LinearProgramming; 25 25 using HeuristicLab.MainForm; 26 26 using HeuristicLab.MainForm.WindowsForms; 27 using HeuristicLab.MathematicalOptimization.LinearProgramming;28 using HeuristicLab.PluginInfrastructure;29 27 30 namespace HeuristicLab. MathematicalOptimization.Views {28 namespace HeuristicLab.ExactOptimization.Views { 31 29 32 30 [View(nameof(LinearProgrammingProblemView))] 33 [Content(typeof(LinearPro grammingProblem),true)]31 [Content(typeof(LinearProblem), IsDefaultView = true)] 34 32 public partial class LinearProgrammingProblemView : ItemView { 35 33 protected ViewHost definitionView; 36 37 private TypeSelectorDialog problemTypeSelectorDialog;38 34 39 35 public LinearProgrammingProblemView() { … … 42 38 } 43 39 44 public new LinearPro grammingProblem Content {45 get => (LinearPro grammingProblem)base.Content;40 public new LinearProblem Content { 41 get => (LinearProblem)base.Content; 46 42 set => base.Content = value; 47 43 } … … 49 45 protected override void DeregisterContentEvents() { 50 46 base.DeregisterContentEvents(); 47 Content.NameChanged -= ContentOnNameChanged; 51 48 Content.ProblemDefinitionChanged -= ContentOnProblemDefinitionChanged; 52 Content.NameChanged -= ContentOnNameChanged;53 49 } 54 50 … … 69 65 } 70 66 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 87 67 private void ContentOnNameChanged(object sender, EventArgs eventArgs) { 88 68 Caption = Content.Name; … … 90 70 91 71 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; 111 73 } 112 74 }
Note: See TracChangeset
for help on using the changeset viewer.