Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionModelView.cs @ 7531

Last change on this file since 7531 was 7259, checked in by swagner, 13 years ago

Updated year of copyrights to 2012 (#1716)

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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
21
22using System.Linq;
23using System.Windows.Forms;
24using HeuristicLab.Common;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27using HeuristicLab.MainForm.WindowsForms;
28
29namespace HeuristicLab.Problems.DataAnalysis.Views {
30  [View("Ensemble Solutions")]
31  [Content(typeof(ClassificationEnsembleSolution), false)]
32  internal sealed partial class ClassificationEnsembleSolutionModelView : DataAnalysisSolutionEvaluationView {
33    private ModelsView view;
34
35    public ClassificationEnsembleSolutionModelView() {
36      InitializeComponent();
37      view = new ModelsView();
38      view.Dock = DockStyle.Fill;
39      Controls.Add(view);
40    }
41
42    public new ClassificationEnsembleSolution Content {
43      get { return (ClassificationEnsembleSolution)base.Content; }
44      set { base.Content = value; }
45    }
46
47    protected override void OnContentChanged() {
48      base.OnContentChanged();
49      if (Content != null) {
50        view.Locked = Content.ProblemData == ClassificationEnsembleProblemData.EmptyProblemData;
51        view.Content = Content.ClassificationSolutions;
52      } else
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      }
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      }
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.