using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using HeuristicLab.MainForm; using HeuristicLab.Optimization.Views; using HeuristicLab.Optimization; using System.Windows.Forms; namespace HeuristicLab.Problems.MetaOptimization.Views { [View("MetaOptimization View")] [Content(typeof(MetaOptimizationProblem), IsDefaultView = true)] public sealed partial class MetaOptimizationProblemView : ProblemView { public new MetaOptimizationProblem Content { get { return (MetaOptimizationProblem)base.Content; } set { base.Content = value; } } public MetaOptimizationProblemView() { InitializeComponent(); } protected override void DeregisterContentEvents() { // TODO: Deregister your event handlers here base.DeregisterContentEvents(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); // TODO: Register your event handlers here } #region Event Handlers (Content) // TODO: Put event handlers of the content here #endregion protected override void OnContentChanged() { base.OnContentChanged(); if (Content == null) { // TODO: Add code when content has been changed and is null } else { // TODO: Add code when content has been changed and is not null } } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); // TODO: Enable or disable controls based on whether the content is null or the view is set readonly } #region Event Handlers (child controls) private void createExperimentButton_Click(object sender, EventArgs e) { if (Content != null) { long count = Content.ParameterConfigurationTree.GetCombinationCount(); System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.OK; if (count > 512) { 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); } if (result == System.Windows.Forms.DialogResult.OK) { CreateExperimentDialog dlg = new CreateExperimentDialog(); DialogResult dlgResult = dlg.ShowDialog(); if (dlgResult == DialogResult.OK) { EngineAlgorithm algorithm = Content.Algorithm; if(Content.Problems.Count > 0) algorithm.Problem = Content.Problems.First(); Experiment experiment; if (dlg.CreateBatchRuns) { experiment = Content.ParameterConfigurationTree.GenerateExperiment(algorithm, true, dlg.Repetitions); } else { experiment = Content.ParameterConfigurationTree.GenerateExperiment(algorithm); } MainFormManager.MainForm.ShowContent(experiment); } } } } #endregion protected void parameterCollectionView_DragEnterOver(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect = DragDropEffects.None; Type type = e.Data.GetData("Type") as Type; if ((type != null) && (Content.AlgorithmType.ValidTypes.Contains(type))) { EngineAlgorithm algorithm = e.Data.GetData("Value") as EngineAlgorithm; if (algorithm.Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) { e.Effect = DragDropEffects.Copy; } } } protected void parameterCollectionView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Effect != DragDropEffects.None) { EngineAlgorithm algorithm = e.Data.GetData("Value") as EngineAlgorithm; Content.ImportAlgorithm(algorithm); } } } }