#region License Information /* HeuristicLab * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using HeuristicLab.MainForm; using System; using System.Windows.Forms; namespace HeuristicLab.Optimization.Networks.Views { [View("InputPort View")] [Content(typeof(InputPort<>), true)] [Content(typeof(IInputPort<>), false)] [Content(typeof(IInputPort), false)] public partial class InputPortView : ValuePortView { public new IInputPort Content { get { return (IInputPort)base.Content; } set { base.Content = value; } } public InputPortView() { InitializeComponent(); } private void UpdateOutputPortTextBoxText() { if ((Content == null) || (Content.OutputPort == null)) { outputPortTextBox.Text = string.Empty; } else { outputPortTextBox.Text = Content.OutputPort.Path + "." + Content.OutputPort.ToString(); } } protected override void DeregisterContentEvents() { Content.OutputPortChanged -= Content_OutputPortChanged; base.DeregisterContentEvents(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); Content.OutputPortChanged += Content_OutputPortChanged; } protected override void OnContentChanged() { base.OnContentChanged(); UpdateOutputPortTextBoxText(); } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); outputPortTextBox.Enabled = Content != null && !ReadOnly; } protected virtual void Content_OutputPortChanged(object sender, EventArgs e) { if (InvokeRequired) Invoke(new EventHandler(Content_OutputPortChanged), sender, e); else { UpdateOutputPortTextBoxText(); } } protected virtual void outputPortTextBox_DragEnterOver(object sender, DragEventArgs e) { e.Effect = DragDropEffects.None; if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IOutputPort)) { e.Effect = DragDropEffects.Link; } } protected virtual void outputPortTextBox_DragDrop(object sender, DragEventArgs e) { if (e.Effect != DragDropEffects.None) { IOutputPort port = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IOutputPort; Content.OutputPort = port; } } } }