using System; using System.Linq; using System.Windows.Forms; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.ParameterConfigurationEncoding.Views; using HeuristicLab.MainForm; using HeuristicLab.Optimization; using HeuristicLab.Optimization.Views; using HeuristicLab.PluginInfrastructure; 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() { base.DeregisterContentEvents(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); } #region Event Handlers (Content) #endregion protected override void OnContentChanged() { base.OnContentChanged(); if (Content == null) { } else { } } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); } #region Event Handlers (child controls) private void createExperimentButton_Click(object sender, EventArgs e) { if (Content != null) { long max = 100000; long count = Content.ParameterConfigurationTree.GetCombinationCount(max); System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.OK; if (count > 512) { if (count == max) { 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); } else { 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) { using (CreateExperimentDialogV2 dialog = new CreateExperimentDialogV2((IAlgorithm)Content.Algorithm.Clone(), ApplicationManager.Manager.GetInstances())) { if (dialog.ShowDialog() == DialogResult.OK) MainFormManager.MainForm.ShowContent(dialog.Experiment); } } } } #endregion private void parameterCollectionView_DragEnterOver(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect = DragDropEffects.None; var type = e.Data.GetData(Constants.DragDropDataFormat).GetType(); if (!ReadOnly && (Content.AlgorithmType.ValidTypes.Contains(type))) { IAlgorithm algorithm = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm; if (algorithm != null && algorithm.Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) { e.Effect = DragDropEffects.Copy; } } } private void parameterCollectionView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Effect != DragDropEffects.None) { IAlgorithm algorithm = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm; Content.ImportAlgorithm(algorithm); } } } }