Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ValueConfigurationViews/ValueView.cs @ 17514

Last change on this file since 17514 was 16996, checked in by gkronber, 6 years ago

#2520 Update plugin dependencies and references for HL.MetaOptimization for new persistence

File size: 2.0 KB
RevLine 
[4839]1using System;
2using System.Data;
3using System.Linq;
4using System.Windows.Forms;
5using HeuristicLab.Core.Views;
6using HeuristicLab.MainForm;
7using HeuristicLab.Core;
8using HeuristicLab.PluginInfrastructure;
9
10namespace HeuristicLab.Problems.MetaOptimization.Views {
11  [View("Value View")]
[4981]12  [Content(typeof(ConstrainedValue), true)]
[4839]13  public partial class ValueView : ItemView {
14
[4981]15    public new ConstrainedValue Content {
16      get { return (ConstrainedValue)base.Content; }
[4839]17      set { base.Content = value; }
18    }
19
20    public ValueView() {
21      InitializeComponent();
22    }
23
24    protected override void OnContentChanged() {
25      base.OnContentChanged();
26      if (Content != null) {
27        valueViewHost.Content = Content.Value;
28      } else {
29        valueViewHost.Content = null;
30      }
[5110]31      SetEnabledStateOfControls();
[4839]32    }
33
[5110]34    protected override void SetEnabledStateOfControls() {
35      base.SetEnabledStateOfControls();
36      if (Content != null) {
37        clearValueButton.Enabled = Content.Value != null && Content.IsNullable; // IsNullable ist in diesem fall nicht richtig gesetzt
38        setValueButton.Enabled = Content.ValueDataType != null;
39      }
40    }
41
[4839]42    private void setValueButton_Click(object sender, EventArgs e) {
[5231]43      var withoutNullValue = Content.ValidValues.Where(x => x != null && !(x is NullValue));
44      var objectSelectorDialog = new ObjectSelectorDialog<IItem>(withoutNullValue.GroupBy(x => ApplicationManager.Manager.GetDeclaringPlugin(x.GetType()).Name));
[5110]45      if (objectSelectorDialog.ShowDialog(this) == DialogResult.OK) {
[4839]46        try {
[5110]47          Content.Value = objectSelectorDialog.Item;
[4839]48          valueViewHost.Content = Content.Value;
49        }
50        catch (Exception ex) {
51          ErrorHandling.ShowErrorDialog(this, ex);
52        }
53      }
[5110]54      SetEnabledStateOfControls();
[4839]55    }
56
57    private void clearValueButton_Click(object sender, EventArgs e) {
58      Content.Value = null;
59      valueViewHost.Content = null;
[5110]60      SetEnabledStateOfControls();
[4839]61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.