1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using HeuristicLab.MainForm;
|
---|
9 | using HeuristicLab.Optimization.Views;
|
---|
10 | using HeuristicLab.Optimization;
|
---|
11 | using System.Windows.Forms;
|
---|
12 |
|
---|
13 | namespace HeuristicLab.Problems.MetaOptimization.Views {
|
---|
14 | [View("MetaOptimization View")]
|
---|
15 | [Content(typeof(MetaOptimizationProblem), IsDefaultView = true)]
|
---|
16 | public sealed partial class MetaOptimizationProblemView : ProblemView {
|
---|
17 | public new MetaOptimizationProblem Content {
|
---|
18 | get { return (MetaOptimizationProblem)base.Content; }
|
---|
19 | set { base.Content = value; }
|
---|
20 | }
|
---|
21 |
|
---|
22 | public MetaOptimizationProblemView() {
|
---|
23 | InitializeComponent();
|
---|
24 | }
|
---|
25 |
|
---|
26 | protected override void DeregisterContentEvents() {
|
---|
27 | // TODO: Deregister your event handlers here
|
---|
28 | base.DeregisterContentEvents();
|
---|
29 | }
|
---|
30 |
|
---|
31 | protected override void RegisterContentEvents() {
|
---|
32 | base.RegisterContentEvents();
|
---|
33 | // TODO: Register your event handlers here
|
---|
34 | }
|
---|
35 |
|
---|
36 | #region Event Handlers (Content)
|
---|
37 | // TODO: Put event handlers of the content here
|
---|
38 | #endregion
|
---|
39 |
|
---|
40 | protected override void OnContentChanged() {
|
---|
41 | base.OnContentChanged();
|
---|
42 | if (Content == null) {
|
---|
43 | // TODO: Add code when content has been changed and is null
|
---|
44 | } else {
|
---|
45 | // TODO: Add code when content has been changed and is not null
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | protected override void SetEnabledStateOfControls() {
|
---|
50 | base.SetEnabledStateOfControls();
|
---|
51 | // TODO: Enable or disable controls based on whether the content is null or the view is set readonly
|
---|
52 | }
|
---|
53 |
|
---|
54 | #region Event Handlers (child controls)
|
---|
55 |
|
---|
56 | private void createExperimentButton_Click(object sender, EventArgs e) {
|
---|
57 | if (Content != null) {
|
---|
58 | long count = Content.ParameterConfigurationTree.GetCombinationCount();
|
---|
59 |
|
---|
60 | System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.OK;
|
---|
61 | if (count > 512) {
|
---|
62 | result = System.Windows.Forms.MessageBox.Show(string.Format("Do you really want to create {0} optimizers? Be aware that this might take a significant amount of time and memory.", count), "Create Experiment", System.Windows.Forms.MessageBoxButtons.OKCancel);
|
---|
63 | }
|
---|
64 | if (result == System.Windows.Forms.DialogResult.OK) {
|
---|
65 | CreateExperimentDialog dlg = new CreateExperimentDialog();
|
---|
66 | DialogResult dlgResult = dlg.ShowDialog();
|
---|
67 |
|
---|
68 | if (dlgResult == DialogResult.OK) {
|
---|
69 | EngineAlgorithm algorithm = Content.Algorithm;
|
---|
70 | if(Content.Problems.Count > 0) algorithm.Problem = Content.Problems.First();
|
---|
71 | Experiment experiment;
|
---|
72 |
|
---|
73 | if (dlg.CreateBatchRuns) {
|
---|
74 | experiment = Content.ParameterConfigurationTree.GenerateExperiment(algorithm, true, dlg.Repetitions);
|
---|
75 | } else {
|
---|
76 | experiment = Content.ParameterConfigurationTree.GenerateExperiment(algorithm);
|
---|
77 | }
|
---|
78 | MainFormManager.MainForm.ShowContent(experiment);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | #endregion
|
---|
85 |
|
---|
86 | protected void parameterCollectionView_DragEnterOver(object sender, System.Windows.Forms.DragEventArgs e) {
|
---|
87 | e.Effect = DragDropEffects.None;
|
---|
88 | Type type = e.Data.GetData("Type") as Type;
|
---|
89 | if ((type != null) && (Content.AlgorithmType.ValidTypes.Contains(type))) {
|
---|
90 | EngineAlgorithm algorithm = e.Data.GetData("Value") as EngineAlgorithm;
|
---|
91 | if (algorithm.Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) {
|
---|
92 | e.Effect = DragDropEffects.Copy;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|
96 | protected void parameterCollectionView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {
|
---|
97 | if (e.Effect != DragDropEffects.None) {
|
---|
98 | EngineAlgorithm algorithm = e.Data.GetData("Value") as EngineAlgorithm;
|
---|
99 | Content.ImportAlgorithm(algorithm);
|
---|
100 | }
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|