Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ValueConfigurationViews/ValueView.cs @ 10204

Last change on this file since 10204 was 5262, checked in by cneumuel, 14 years ago

#1260

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