[3742] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[5445] | 3 | * Copyright (C) 2002-2011 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 |
|
---|
| 22 | using System;
|
---|
[3614] | 23 | using System.Linq;
|
---|
[6673] | 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.Common;
|
---|
[3614] | 26 | using HeuristicLab.Core.Views;
|
---|
| 27 | using HeuristicLab.MainForm;
|
---|
| 28 |
|
---|
| 29 | namespace 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 |
|
---|
| 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 | }
|
---|
[3614] | 100 | }
|
---|
| 101 | }
|
---|