Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HookOperatorView.cs @ 11519

Last change on this file since 11519 was 11519, checked in by swagner, 9 years ago

#2205: Worked on optimization networks

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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 HeuristicLab.MainForm;
23using HeuristicLab.Operators.Views;
24using System;
25using System.Windows.Forms;
26
27namespace HeuristicLab.Optimization.Networks.Views {
28  [View("HookOperator View")]
29  [Content(typeof(HookOperator), true)]
30  [Content(typeof(IHookOperator), false)]
31  public partial class HookOperatorView : OperatorView {
32    public new IHookOperator Content {
33      get { return (IHookOperator)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public HookOperatorView() {
38      InitializeComponent();
39      errorProvider.SetIconAlignment(portView, ErrorIconAlignment.MiddleRight);
40      errorProvider.SetIconPadding(portView, 2);
41    }
42
43    protected override void DeregisterContentEvents() {
44      Content.PortChanged -= Content_PortChanged;
45      base.DeregisterContentEvents();
46    }
47    protected override void RegisterContentEvents() {
48      base.RegisterContentEvents();
49      Content.PortChanged += Content_PortChanged;
50    }
51
52    protected override void OnContentChanged() {
53      base.OnContentChanged();
54      portView.Content = Content == null ? null : Content.Port;
55      parameterCollectionView.Content = Content == null ? null : Content.Parameters;
56    }
57
58    protected override void SetEnabledStateOfControls() {
59      base.SetEnabledStateOfControls();
60      portGroupBox.Enabled = Content != null && !ReadOnly && !Locked;
61      clearPortButton.Enabled = Content != null && Content.Port != null && !ReadOnly && !Locked;
62    }
63
64    protected virtual void Content_PortChanged(object sender, EventArgs e) {
65      if (InvokeRequired)
66        Invoke(new EventHandler(Content_PortChanged), sender, e);
67      else {
68        clearPortButton.Enabled = Content.Port != null && !ReadOnly && !Locked;
69        portView.Content = Content.Port;
70      }
71    }
72
73    protected virtual void clearPortButton_Click(object sender, EventArgs e) {
74      Content.Port = null;
75    }
76    protected virtual void portView_DragEnterOver(object sender, DragEventArgs e) {
77      e.Effect = DragDropEffects.None;
78      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IGenericPort;
79
80      if (!ReadOnly && (data != null)) {
81        e.Effect = DragDropEffects.Link;
82      }
83    }
84    protected virtual void portView_DragDrop(object sender, DragEventArgs e) {
85      if (e.Effect != DragDropEffects.None) {
86        var port = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IGenericPort;
87        Content.Port = port;
88      }
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.