[8576] | 1 | using System;
|
---|
| 2 | using System.Linq;
|
---|
| 3 | using System.Windows.Forms;
|
---|
| 4 | using HeuristicLab.Common;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
| 6 | using HeuristicLab.Encodings.ParameterConfigurationEncoding.Views;
|
---|
| 7 | using HeuristicLab.MainForm;
|
---|
| 8 | using HeuristicLab.Optimization;
|
---|
| 9 | using HeuristicLab.Optimization.Views;
|
---|
| 10 | using HeuristicLab.PluginInfrastructure;
|
---|
| 11 |
|
---|
| 12 | namespace HeuristicLab.Problems.MetaOptimization.Views {
|
---|
| 13 | [View("MetaOptimization View")]
|
---|
| 14 | [Content(typeof(MetaOptimizationProblem), IsDefaultView = true)]
|
---|
| 15 | public sealed partial class MetaOptimizationProblemView : ProblemView {
|
---|
| 16 | public new MetaOptimizationProblem Content {
|
---|
| 17 | get { return (MetaOptimizationProblem)base.Content; }
|
---|
| 18 | set { base.Content = value; }
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public MetaOptimizationProblemView() {
|
---|
| 22 | InitializeComponent();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | protected override void DeregisterContentEvents() {
|
---|
| 26 | base.DeregisterContentEvents();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | protected override void RegisterContentEvents() {
|
---|
| 30 | base.RegisterContentEvents();
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | #region Event Handlers (Content)
|
---|
| 34 | #endregion
|
---|
| 35 |
|
---|
| 36 | protected override void OnContentChanged() {
|
---|
| 37 | base.OnContentChanged();
|
---|
| 38 | if (Content == null) {
|
---|
| 39 | } else {
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | protected override void SetEnabledStateOfControls() {
|
---|
| 44 | base.SetEnabledStateOfControls();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | #region Event Handlers (child controls)
|
---|
| 48 |
|
---|
| 49 | private void createExperimentButton_Click(object sender, EventArgs e) {
|
---|
| 50 | if (Content != null) {
|
---|
| 51 | long max = 100000;
|
---|
| 52 | long count = Content.ParameterConfigurationTree.GetCombinationCount(max);
|
---|
| 53 |
|
---|
| 54 | System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.OK;
|
---|
| 55 | if (count > 512) {
|
---|
| 56 | if (count == max) {
|
---|
| 57 | result = System.Windows.Forms.MessageBox.Show(string.Format("Do you really want to create more than {0}+ optimizers? Be aware that this might take a significant amount of time and memory.", count), "Create Experiment", System.Windows.Forms.MessageBoxButtons.OKCancel);
|
---|
| 58 | } else {
|
---|
| 59 | 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);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | if (result == System.Windows.Forms.DialogResult.OK) {
|
---|
| 63 | using (CreateExperimentDialogV2 dialog = new CreateExperimentDialogV2((IAlgorithm)Content.Algorithm.Clone(), ApplicationManager.Manager.GetInstances<IEngine>())) {
|
---|
| 64 | if (dialog.ShowDialog() == DialogResult.OK) MainFormManager.MainForm.ShowContent(dialog.Experiment);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | #endregion
|
---|
| 71 |
|
---|
| 72 | private void parameterCollectionView_DragEnterOver(object sender, System.Windows.Forms.DragEventArgs e) {
|
---|
| 73 | e.Effect = DragDropEffects.None;
|
---|
| 74 | var type = e.Data.GetData(Constants.DragDropDataFormat).GetType();
|
---|
| 75 | if (!ReadOnly && (Content.AlgorithmType.ValidTypes.Contains(type))) {
|
---|
| 76 | IAlgorithm algorithm = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm;
|
---|
| 77 | if (algorithm != null && algorithm.Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) {
|
---|
| 78 | e.Effect = DragDropEffects.Copy;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | private void parameterCollectionView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {
|
---|
| 83 | if (e.Effect != DragDropEffects.None) {
|
---|
| 84 | IAlgorithm algorithm = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm;
|
---|
| 85 | Content.ImportAlgorithm(algorithm);
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|