[6612] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7259] | 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[6612] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
[6666] | 21 |
|
---|
| 22 | using System.Linq;
|
---|
[6642] | 23 | using System.Windows.Forms;
|
---|
[6666] | 24 | using HeuristicLab.Common;
|
---|
[6642] | 25 | using HeuristicLab.Core.Views;
|
---|
| 26 | using HeuristicLab.MainForm;
|
---|
| 27 | using HeuristicLab.MainForm.WindowsForms;
|
---|
[6612] | 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
[6642] | 30 | [View("Ensemble Solutions")]
|
---|
| 31 | [Content(typeof(RegressionEnsembleSolution), false)]
|
---|
| 32 | internal sealed partial class RegressionEnsembleSolutionModelView : DataAnalysisSolutionEvaluationView {
|
---|
| 33 | private ModelsView view;
|
---|
[6612] | 34 |
|
---|
| 35 | public RegressionEnsembleSolutionModelView() {
|
---|
| 36 | InitializeComponent();
|
---|
[6642] | 37 | view = new ModelsView();
|
---|
| 38 | view.Dock = DockStyle.Fill;
|
---|
| 39 | Controls.Add(view);
|
---|
[6612] | 40 | }
|
---|
| 41 |
|
---|
[6642] | 42 | public new RegressionEnsembleSolution Content {
|
---|
| 43 | get { return (RegressionEnsembleSolution)base.Content; }
|
---|
| 44 | set { base.Content = value; }
|
---|
[6612] | 45 | }
|
---|
[6642] | 46 |
|
---|
| 47 | protected override void OnContentChanged() {
|
---|
| 48 | base.OnContentChanged();
|
---|
[6666] | 49 | if (Content != null) {
|
---|
| 50 | view.Locked = Content.ProblemData == RegressionEnsembleProblemData.EmptyProblemData;
|
---|
[6642] | 51 | view.Content = Content.RegressionSolutions;
|
---|
[6666] | 52 | } else
|
---|
[6642] | 53 | view.Content = null;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public override System.Drawing.Image ViewImage {
|
---|
| 57 | get { return HeuristicLab.Common.Resources.VSImageLibrary.Properties; }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | private class ModelsView : ItemCollectionView<IRegressionSolution> {
|
---|
| 61 | protected override void SetEnabledStateOfControls() {
|
---|
| 62 | base.SetEnabledStateOfControls();
|
---|
| 63 | addButton.Enabled = Content != null && !Content.IsReadOnly && !Locked;
|
---|
| 64 | removeButton.Enabled = Content != null && !Content.IsReadOnly && !Locked && itemsListView.SelectedItems.Count > 0;
|
---|
[6666] | 65 | itemsListView.Enabled = Content != null && !Locked;
|
---|
[6642] | 66 | detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1;
|
---|
| 67 | }
|
---|
[6666] | 68 |
|
---|
| 69 | protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
|
---|
| 70 | validDragOperation = false;
|
---|
| 71 | if (ReadOnly || Locked) return;
|
---|
| 72 | if (Content.IsReadOnly) return;
|
---|
| 73 |
|
---|
| 74 | var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 75 | validDragOperation = dropData.GetObjectGraphObjects().OfType<IRegressionSolution>().Any();
|
---|
| 76 | }
|
---|
| 77 | protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
|
---|
| 78 | if (e.Effect != DragDropEffects.None) {
|
---|
| 79 | var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 80 | var solutions = dropData.GetObjectGraphObjects().OfType<IRegressionSolution>();
|
---|
| 81 | if (e.Effect.HasFlag(DragDropEffects.Copy)) {
|
---|
| 82 | Cloner cloner = new Cloner();
|
---|
| 83 | solutions = solutions.Select(s => cloner.Clone(s));
|
---|
| 84 | }
|
---|
| 85 | foreach (var solution in solutions)
|
---|
| 86 | Content.Add(solution);
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
[6642] | 89 | }
|
---|
[6612] | 90 | }
|
---|
| 91 | }
|
---|