[6612] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 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
|
---|
[6675] | 21 |
|
---|
| 22 | using System.Linq;
|
---|
[6647] | 23 | using System.Windows.Forms;
|
---|
[6675] | 24 | using HeuristicLab.Common;
|
---|
[6647] | 25 | using HeuristicLab.Core.Views;
|
---|
| 26 | using HeuristicLab.MainForm;
|
---|
| 27 | using HeuristicLab.MainForm.WindowsForms;
|
---|
[6612] | 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
[6647] | 30 | [View("Ensemble Solutions")]
|
---|
| 31 | [Content(typeof(ClassificationEnsembleSolution), false)]
|
---|
| 32 | internal sealed partial class ClassificationEnsembleSolutionModelView : DataAnalysisSolutionEvaluationView {
|
---|
| 33 | private ModelsView view;
|
---|
[6612] | 34 |
|
---|
[6613] | 35 | public ClassificationEnsembleSolutionModelView() {
|
---|
[6612] | 36 | InitializeComponent();
|
---|
[6647] | 37 | view = new ModelsView();
|
---|
| 38 | view.Dock = DockStyle.Fill;
|
---|
| 39 | Controls.Add(view);
|
---|
[6612] | 40 | }
|
---|
| 41 |
|
---|
[6647] | 42 | public new ClassificationEnsembleSolution Content {
|
---|
| 43 | get { return (ClassificationEnsembleSolution)base.Content; }
|
---|
| 44 | set { base.Content = value; }
|
---|
[6612] | 45 | }
|
---|
[6647] | 46 |
|
---|
| 47 | protected override void OnContentChanged() {
|
---|
| 48 | base.OnContentChanged();
|
---|
[6675] | 49 | if (Content != null) {
|
---|
| 50 | view.Locked = Content.ProblemData == ClassificationEnsembleProblemData.EmptyProblemData;
|
---|
[6647] | 51 | view.Content = Content.ClassificationSolutions;
|
---|
[6675] | 52 | } else
|
---|
[6647] | 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<IClassificationSolution> {
|
---|
| 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;
|
---|
| 65 | itemsListView.Enabled = Content != null;
|
---|
| 66 | detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1;
|
---|
| 67 | }
|
---|
[6675] | 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<IClassificationSolution>().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<IClassificationSolution>();
|
---|
| 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 | }
|
---|
[6647] | 89 | }
|
---|
[6612] | 90 | }
|
---|
| 91 | }
|
---|