Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4830 was 4830, checked in by cneumuel, 13 years ago

#1215 worked on metaoptimization

File size: 1.6 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(IParameterConfiguration), false)]
18  public partial class ValueView : ItemView {
19
20    public new IParameterConfiguration Content {
21      get { return (IParameterConfiguration)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      valueViewHost.Content = Content.Value;
32    }
33
34    private void setValueButton_Click(object sender, EventArgs e) {
35      var typeSelectorDialog = new TypeSelectorDialog();
36      typeSelectorDialog.Caption = "Select Value";
37      typeSelectorDialog.TypeSelector.Configure(Content.Parameter.DataType, false, true);
38
39      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
40        try {
41          Content.Value = (IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
42          valueViewHost.Content = Content.Value;
43        }
44        catch (Exception ex) {
45          ErrorHandling.ShowErrorDialog(this, ex);
46        }
47      }
48    }
49
50    private void clearValueButton_Click(object sender, EventArgs e) {
51      Content.Value = null;
52      valueViewHost.Content = null;
53    }
54  }
55}
Note: See TracBrowser for help on using the repository browser.