Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceSpeedUp/HeuristicLab.Optimization.Views/3.3/RunCollectionContentConstraintView.cs @ 12214

Last change on this file since 12214 was 6760, checked in by epitzer, 13 years ago

#1530 integrate changes from trunk

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