Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintViews/RunCollectionContentConstraintView.cs @ 10402

Last change on this file since 10402 was 9835, checked in by bburlacu, 11 years ago

#1772: Merged remaining trunk changes into the EvolutionaryTracking branch.

File size: 3.8 KB
RevLine 
[3742]1#region License Information
2/* HeuristicLab
[9835]3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3742]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;
[3614]23using System.Linq;
[6673]24using System.Windows.Forms;
25using HeuristicLab.Common;
[3614]26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
28
29namespace HeuristicLab.Optimization.Views {
[6673]30  [Content(typeof(RunCollectionContentConstraint), true)]
31  public partial class RunCollectionContentConstraintView : ItemView {
32    public RunCollectionContentConstraintView() {
[3614]33      InitializeComponent();
[6673]34      runsView.ShowDetails = false;
[3614]35    }
36
[6673]37    public new RunCollectionContentConstraint Content {
38      get { return (RunCollectionContentConstraint)base.Content; }
[3614]39      set { base.Content = value; }
40    }
41
42    protected override void OnContentChanged() {
43      base.OnContentChanged();
44      if (Content != null) {
45        chbActive.Checked = Content.Active;
[5007]46        ReadOnly = Content.Active;
[6673]47        runsView.RunCollection = Content.ConstrainedValue;
48        runsView.Content = Content.ConstraintData;
49      } else {
[5007]50        chbActive.Checked = false;
[6673]51        runsView.RunCollection = null;
52        runsView.Content = null;
[3614]53      }
54    }
55
56    protected override void RegisterContentEvents() {
57      base.RegisterContentEvents();
[6673]58      Content.ActiveChanged += new EventHandler(Content_ActiveChanged);
[3614]59    }
60
61    protected override void DeregisterContentEvents() {
62      base.DeregisterContentEvents();
[6673]63      Content.ActiveChanged -= new EventHandler(Content_ActiveChanged);
[3614]64    }
65
[3904]66    protected override void SetEnabledStateOfControls() {
67      base.SetEnabledStateOfControls();
[6673]68      chbActive.Enabled = !Locked && Content != null;
69      runsView.Enabled = !Locked && Content != null;
[3614]70    }
71
72    protected virtual void Content_ActiveChanged(object sender, EventArgs e) {
[6673]73      chbActive.Checked = Content.Active;
74      ReadOnly = Content.Active;
[3614]75    }
76    protected virtual void chbActive_CheckedChanged(object sender, EventArgs e) {
[4152]77      if (Content != null)
78        Content.Active = chbActive.Checked;
[3614]79    }
[6673]80
81    private class RunSetView : ItemSetView<IRun> {
82      public RunCollection RunCollection { get; set; }
83
[7130]84      public RunSetView()
85        : base() {
86        addButton.Enabled = false;
87      }
88
89      protected override void SetEnabledStateOfControls() {
90        base.SetEnabledStateOfControls();
91        addButton.Enabled = false;
92      }
93
[6673]94      protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
95        base.itemsListView_DragEnter(sender, e);
96        if (RunCollection != null) {
97          var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
98          foreach (var run in dropData.GetObjectGraphObjects().OfType<IRun>())
99            validDragOperation = validDragOperation && RunCollection.Contains(run);
100        }
101      }
102
103      protected override void itemsListView_DragOver(object sender, DragEventArgs e) {
104        e.Effect = DragDropEffects.None;
[7130]105        if (validDragOperation && !draggedItemsAlreadyContained) {
[6673]106          e.Effect = DragDropEffects.Link;
107        }
108      }
109    }
[3614]110  }
111}
Note: See TracBrowser for help on using the repository browser.