Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 16380 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
Line 
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")]
17  [Content(typeof(ConstrainedValue), true)]
18  public partial class ValueView : ItemView {
19
20    public new ConstrainedValue Content {
21      get { return (ConstrainedValue)base.Content; }
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      }
36      SetEnabledStateOfControls();
37    }
38
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
47    private void setValueButton_Click(object sender, EventArgs e) {
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));
50      if (objectSelectorDialog.ShowDialog(this) == DialogResult.OK) {
51        try {
52          Content.Value = objectSelectorDialog.Item;
53          valueViewHost.Content = Content.Value;
54        }
55        catch (Exception ex) {
56          ErrorHandling.ShowErrorDialog(this, ex);
57        }
58      }
59      SetEnabledStateOfControls();
60    }
61
62    private void clearValueButton_Click(object sender, EventArgs e) {
63      Content.Value = null;
64      valueViewHost.Content = null;
65      SetEnabledStateOfControls();
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.