Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11449


Ignore:
Timestamp:
10/11/14 03:32:15 (10 years ago)
Author:
swagner
Message:

#2205: Worked on optimization networks

Location:
branches/OptimizationNetworks
Files:
8 added
14 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj

    r11423 r11449  
    8585  </ItemGroup>
    8686  <ItemGroup>
     87    <Compile Include="EntitySelector.cs">
     88      <SubType>UserControl</SubType>
     89    </Compile>
     90    <Compile Include="EntitySelector.Designer.cs">
     91      <DependentUpon>EntitySelector.cs</DependentUpon>
     92    </Compile>
     93    <Compile Include="EntitySelectorDialog.cs">
     94      <SubType>Form</SubType>
     95    </Compile>
     96    <Compile Include="EntitySelectorDialog.Designer.cs">
     97      <DependentUpon>EntitySelectorDialog.cs</DependentUpon>
     98    </Compile>
     99    <Compile Include="EntityView.cs">
     100      <SubType>UserControl</SubType>
     101    </Compile>
     102    <Compile Include="EntityView.Designer.cs">
     103      <DependentUpon>EntityView.cs</DependentUpon>
     104    </Compile>
    87105    <Compile Include="PortView.cs">
    88106      <SubType>UserControl</SubType>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.Designer.cs

    r11438 r11449  
    2727    private System.ComponentModel.IContainer components = null;
    2828
    29     /// <summary>
    30     /// Clean up any resources being used.
    31     /// </summary>
    32     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    33     protected override void Dispose(bool disposing) {
    34       if (disposing) {
    35         if (components != null) components.Dispose();
    36       }
    37       base.Dispose(disposing);
    38     }
    39 
    4029    #region Component Designer generated code
    4130
     
    4534    /// </summary>
    4635    private void InitializeComponent() {
     36      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InputPortView));
    4737      this.outputPortGroupBox = new System.Windows.Forms.GroupBox();
     38      this.setOutputPortButton = new System.Windows.Forms.Button();
     39      this.clearOutputPortButton = new System.Windows.Forms.Button();
    4840      this.outputPortView = new HeuristicLab.Optimization.Networks.Views.PortView();
    4941      this.valueGroupBox.SuspendLayout();
     
    5547      // valueGroupBox
    5648      //
    57       this.valueGroupBox.Location = new System.Drawing.Point(0, 129);
    58       this.valueGroupBox.Size = new System.Drawing.Size(645, 388);
    59       this.valueGroupBox.TabIndex = 6;
     49      this.valueGroupBox.Location = new System.Drawing.Point(0, 82);
     50      this.valueGroupBox.Size = new System.Drawing.Size(645, 435);
     51      this.valueGroupBox.TabIndex = 4;
    6052      //
    6153      // valuePanel
    6254      //
    63       this.valuePanel.Size = new System.Drawing.Size(633, 363);
     55      this.valuePanel.Size = new System.Drawing.Size(633, 410);
    6456      //
    6557      // valueViewHost
    6658      //
    67       this.valueViewHost.Size = new System.Drawing.Size(633, 363);
    68       //
    69       // pathTextBox
    70       //
    71       this.pathTextBox.Location = new System.Drawing.Point(71, 26);
    72       this.pathTextBox.Size = new System.Drawing.Size(549, 20);
     59      this.valueViewHost.Size = new System.Drawing.Size(633, 410);
    7360      //
    7461      // nameTextBox
     
    8370      this.outputPortGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    8471            | System.Windows.Forms.AnchorStyles.Right)));
     72      this.outputPortGroupBox.Controls.Add(this.setOutputPortButton);
     73      this.outputPortGroupBox.Controls.Add(this.clearOutputPortButton);
    8574      this.outputPortGroupBox.Controls.Add(this.outputPortView);
    86       this.outputPortGroupBox.Location = new System.Drawing.Point(0, 52);
     75      this.outputPortGroupBox.Location = new System.Drawing.Point(0, 26);
    8776      this.outputPortGroupBox.Name = "outputPortGroupBox";
    88       this.outputPortGroupBox.Size = new System.Drawing.Size(645, 71);
    89       this.outputPortGroupBox.TabIndex = 5;
     77      this.outputPortGroupBox.Size = new System.Drawing.Size(645, 50);
     78      this.outputPortGroupBox.TabIndex = 3;
    9079      this.outputPortGroupBox.TabStop = false;
    9180      this.outputPortGroupBox.Text = "&Output Port";
    92       this.outputPortGroupBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.outputPortGroupBox_DragDrop);
    93       this.outputPortGroupBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.outputPortGroupBox_DragEnterOver);
    94       this.outputPortGroupBox.DragOver += new System.Windows.Forms.DragEventHandler(this.outputPortGroupBox_DragEnterOver);
     81      //
     82      // setOutputPortButton
     83      //
     84      this.setOutputPortButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Edit;
     85      this.setOutputPortButton.Location = new System.Drawing.Point(6, 19);
     86      this.setOutputPortButton.Name = "setOutputPortButton";
     87      this.setOutputPortButton.Size = new System.Drawing.Size(24, 24);
     88      this.setOutputPortButton.TabIndex = 0;
     89      this.setOutputPortButton.UseVisualStyleBackColor = true;
     90      this.setOutputPortButton.Click += new System.EventHandler(this.setOutputPortButton_Click);
     91      //
     92      // clearOutputPortButton
     93      //
     94      this.clearOutputPortButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Remove;
     95      this.clearOutputPortButton.Location = new System.Drawing.Point(36, 19);
     96      this.clearOutputPortButton.Name = "clearOutputPortButton";
     97      this.clearOutputPortButton.Size = new System.Drawing.Size(24, 24);
     98      this.clearOutputPortButton.TabIndex = 1;
     99      this.clearOutputPortButton.UseVisualStyleBackColor = true;
     100      this.clearOutputPortButton.Click += new System.EventHandler(this.clearOutputPortButton_Click);
    95101      //
    96102      // outputPortView
    97103      //
    98       this.outputPortView.Caption = "Port View";
     104      this.outputPortView.AllowDrop = true;
     105      this.outputPortView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     106            | System.Windows.Forms.AnchorStyles.Left)
     107            | System.Windows.Forms.AnchorStyles.Right)));
     108      this.outputPortView.Caption = "Output Port View";
    99109      this.outputPortView.Content = null;
    100       this.outputPortView.Dock = System.Windows.Forms.DockStyle.Fill;
    101       this.outputPortView.Location = new System.Drawing.Point(3, 16);
     110      this.outputPortView.Location = new System.Drawing.Point(66, 21);
    102111      this.outputPortView.Name = "outputPortView";
    103112      this.outputPortView.ReadOnly = true;
    104       this.outputPortView.Size = new System.Drawing.Size(639, 52);
    105       this.outputPortView.TabIndex = 0;
     113      this.outputPortView.Size = new System.Drawing.Size(573, 23);
     114      this.outputPortView.TabIndex = 2;
     115      this.outputPortView.DragDrop += new System.Windows.Forms.DragEventHandler(this.outputPortView_DragDrop);
     116      this.outputPortView.DragEnter += new System.Windows.Forms.DragEventHandler(this.outputPortView_DragEnterOver);
     117      this.outputPortView.DragOver += new System.Windows.Forms.DragEventHandler(this.outputPortView_DragEnterOver);
    106118      //
    107119      // InputPortView
     
    110122      this.Controls.Add(this.outputPortGroupBox);
    111123      this.Name = "InputPortView";
    112       this.Controls.SetChildIndex(this.pathLabel, 0);
    113       this.Controls.SetChildIndex(this.pathTextBox, 0);
    114124      this.Controls.SetChildIndex(this.nameLabel, 0);
    115125      this.Controls.SetChildIndex(this.nameTextBox, 0);
     
    130140    protected System.Windows.Forms.GroupBox outputPortGroupBox;
    131141    protected PortView outputPortView;
     142    protected System.Windows.Forms.Button clearOutputPortButton;
     143    protected System.Windows.Forms.Button setOutputPortButton;
    132144
    133145
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs

    r11438 r11449  
    3030  [Content(typeof(IInputPort), false)]
    3131  public partial class InputPortView : ValuePortView {
     32    protected EntitySelectorDialog entitySelectorDialog;
     33
    3234    public new IInputPort Content {
    3335      get { return (IInputPort)base.Content; }
     
    3739    public InputPortView() {
    3840      InitializeComponent();
     41    }
     42
     43    protected override void Dispose(bool disposing) {
     44      if (disposing) {
     45        if (entitySelectorDialog != null) entitySelectorDialog.Dispose();
     46        if (components != null) components.Dispose();
     47      }
     48      base.Dispose(disposing);
    3949    }
    4050
     
    5666      base.SetEnabledStateOfControls();
    5767      outputPortGroupBox.Enabled = Content != null && !ReadOnly;
     68      setOutputPortButton.Enabled = Content != null && !ReadOnly;
     69      clearOutputPortButton.Enabled = Content != null && Content.OutputPort != null && !ReadOnly;
    5870    }
    5971
     
    6274        Invoke(new EventHandler(Content_OutputPortChanged), sender, e);
    6375      else {
     76        clearOutputPortButton.Enabled = Content.OutputPort != null && !ReadOnly;
    6477        outputPortView.Content = Content.OutputPort;
    6578      }
    6679    }
    6780
    68     protected virtual void outputPortGroupBox_DragEnterOver(object sender, DragEventArgs e) {
     81    protected virtual void setOutputPortButton_Click(object sender, EventArgs e) {
     82      if (entitySelectorDialog == null) {
     83        entitySelectorDialog = new EntitySelectorDialog();
     84        entitySelectorDialog.Caption = "Select Output Port";
     85      }
     86
     87      IEntity root = Content;
     88      while (root.Parent != null)
     89        root = root.Parent;
     90      entitySelectorDialog.EntitySelector.Root = root;
     91
     92      if (entitySelectorDialog.ShowDialog(this) == DialogResult.OK) {
     93        Content.OutputPort = entitySelectorDialog.EntitySelector.SelectedEntity as IOutputPort;
     94      }
     95    }
     96    protected virtual void clearOutputPortButton_Click(object sender, EventArgs e) {
     97      Content.OutputPort = null;
     98    }
     99
     100    protected virtual void outputPortView_DragEnterOver(object sender, DragEventArgs e) {
    69101      e.Effect = DragDropEffects.None;
    70102      if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IOutputPort)) {
     
    72104      }
    73105    }
    74     protected virtual void outputPortGroupBox_DragDrop(object sender, DragEventArgs e) {
     106    protected virtual void outputPortView_DragDrop(object sender, DragEventArgs e) {
    75107      if (e.Effect != DragDropEffects.None) {
    76108        IOutputPort port = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IOutputPort;
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/NetworkView.cs

    r11409 r11449  
    2828  [Content(typeof(Network), true)]
    2929  [Content(typeof(INetwork), false)]
    30   public partial class NetworkView : NamedItemView {
     30  public partial class NetworkView : EntityView {
    3131    public new INetwork Content {
    3232      get { return (INetwork)base.Content; }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/NodeView.cs

    r11409 r11449  
    2828  [Content(typeof(Node), true)]
    2929  [Content(typeof(INode), false)]
    30   public partial class NodeView : NamedItemView {
     30  public partial class NodeView : EntityView {
    3131    public new INode Content {
    3232      get { return (INode)base.Content; }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.Designer.cs

    r11438 r11449  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.pathLabel = new System.Windows.Forms.Label();
    48       this.pathTextBox = new System.Windows.Forms.TextBox();
    4947      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5048      this.SuspendLayout();
     
    5452      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    5553      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    56       this.nameTextBox.Location = new System.Drawing.Point(69, 0);
    57       this.nameTextBox.Size = new System.Drawing.Size(551, 20);
    58       //
    59       // infoLabel
    60       //
    61       this.infoLabel.Location = new System.Drawing.Point(626, 3);
    62       //
    63       // pathLabel
    64       //
    65       this.pathLabel.AutoSize = true;
    66       this.pathLabel.Location = new System.Drawing.Point(3, 29);
    67       this.pathLabel.Name = "pathLabel";
    68       this.pathLabel.Size = new System.Drawing.Size(32, 13);
    69       this.pathLabel.TabIndex = 3;
    70       this.pathLabel.Text = "&Path:";
    71       //
    72       // pathTextBox
    73       //
    74       this.pathTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    75             | System.Windows.Forms.AnchorStyles.Right)));
    76       this.pathTextBox.Location = new System.Drawing.Point(69, 26);
    77       this.pathTextBox.Name = "pathTextBox";
    78       this.pathTextBox.ReadOnly = true;
    79       this.pathTextBox.Size = new System.Drawing.Size(551, 20);
    80       this.pathTextBox.TabIndex = 4;
    8154      //
    8255      // PortView
    8356      //
    8457      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    85       this.Controls.Add(this.pathTextBox);
    86       this.Controls.Add(this.pathLabel);
    8758      this.Name = "PortView";
    88       this.Size = new System.Drawing.Size(645, 517);
    89       this.Controls.SetChildIndex(this.nameLabel, 0);
    90       this.Controls.SetChildIndex(this.nameTextBox, 0);
    91       this.Controls.SetChildIndex(this.infoLabel, 0);
    92       this.Controls.SetChildIndex(this.pathLabel, 0);
    93       this.Controls.SetChildIndex(this.pathTextBox, 0);
    9459      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    9560      this.ResumeLayout(false);
     
    10065    #endregion
    10166
    102     protected System.Windows.Forms.Label pathLabel;
    103     protected System.Windows.Forms.TextBox pathTextBox;
    10467
    10568
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.cs

    r11438 r11449  
    2929  [Content(typeof(Port), true)]
    3030  [Content(typeof(IPort), false)]
    31   public partial class PortView : NamedItemView {
     31  public partial class PortView : EntityView {
    3232    public new IPort Content {
    3333      get { return (IPort)base.Content; }
     
    3939    }
    4040
    41     protected override void DeregisterContentEvents() {
    42       Content.PathChanged -= Content_PathChanged;
    43       base.DeregisterContentEvents();
    44     }
    45     protected override void RegisterContentEvents() {
    46       base.RegisterContentEvents();
    47       Content.PathChanged += Content_PathChanged;
    48     }
    49 
    5041    protected override void OnContentChanged() {
    5142      base.OnContentChanged();
    52       pathTextBox.Text = Content == null ? string.Empty : Content.Path;
    5343    }
    5444
    5545    protected override void SetEnabledStateOfControls() {
    5646      base.SetEnabledStateOfControls();
    57       pathTextBox.Enabled = Content != null;
    58     }
    59 
    60     protected virtual void Content_PathChanged(object sender, System.EventArgs e) {
    61       if (InvokeRequired)
    62         Invoke(new EventHandler(Content_PathChanged), sender, e);
    63       else {
    64         pathTextBox.Text = Content.Path;
    65       }
    6647    }
    6748  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/ValuePortView.Designer.cs

    r11438 r11449  
    6464            | System.Windows.Forms.AnchorStyles.Right)));
    6565      this.valueGroupBox.Controls.Add(this.valuePanel);
    66       this.valueGroupBox.Location = new System.Drawing.Point(0, 52);
     66      this.valueGroupBox.Location = new System.Drawing.Point(0, 26);
    6767      this.valueGroupBox.Name = "valueGroupBox";
    68       this.valueGroupBox.Size = new System.Drawing.Size(645, 465);
    69       this.valueGroupBox.TabIndex = 5;
     68      this.valueGroupBox.Size = new System.Drawing.Size(645, 491);
     69      this.valueGroupBox.TabIndex = 3;
    7070      this.valueGroupBox.TabStop = false;
    7171      this.valueGroupBox.Text = "Value";
     
    7979      this.valuePanel.Location = new System.Drawing.Point(6, 19);
    8080      this.valuePanel.Name = "valuePanel";
    81       this.valuePanel.Size = new System.Drawing.Size(633, 440);
     81      this.valuePanel.Size = new System.Drawing.Size(633, 466);
    8282      this.valuePanel.TabIndex = 0;
    8383      //
     
    9191      this.valueViewHost.Name = "valueViewHost";
    9292      this.valueViewHost.ReadOnly = false;
    93       this.valueViewHost.Size = new System.Drawing.Size(633, 440);
     93      this.valueViewHost.Size = new System.Drawing.Size(633, 466);
    9494      this.valueViewHost.TabIndex = 0;
    9595      this.valueViewHost.ViewsLabelVisible = true;
     
    101101      this.Controls.Add(this.valueGroupBox);
    102102      this.Name = "ValuePortView";
    103       this.Controls.SetChildIndex(this.pathLabel, 0);
    104       this.Controls.SetChildIndex(this.pathTextBox, 0);
    105103      this.Controls.SetChildIndex(this.nameLabel, 0);
    106104      this.Controls.SetChildIndex(this.nameTextBox, 0);
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11423 r11449  
    8484  </ItemGroup>
    8585  <ItemGroup>
     86    <Compile Include="IEntity.cs" />
    8687    <Compile Include="IPort.cs" />
    8788    <Compile Include="IVariablesNode.cs" />
     89    <Compile Include="Entity.cs" />
    8890    <Compile Include="Port.cs" />
    8991    <Compile Include="VariablesNode.cs" />
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/INode.cs

    r11401 r11449  
    2424
    2525namespace HeuristicLab.Optimization.Networks {
    26   public interface INode : INamedItem {
     26  public interface INode : IEntity {
     27    new INetwork Parent { get; set; }
    2728    IKeyedItemCollection<string, IPort> Ports { get; }
    2829  }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs

    r11431 r11449  
    2424
    2525namespace HeuristicLab.Optimization.Networks {
    26   public interface IPort : INamedItem {
    27     INode Parent { get; set; }
    28     string Path { get; }
    29 
    30     event EventHandler PathChanged;
     26  public interface IPort : IEntity {
     27    new INode Parent { get; set; }
    3128  }
    3229}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Network.cs

    r11409 r11449  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using System.Collections.Generic;
    2526using System.Drawing;
     27using System.Linq;
    2628
    2729namespace HeuristicLab.Optimization.Networks {
     
    3436    public static new Image StaticItemImage {
    3537      get { return HeuristicLab.Common.Resources.VSImageLibrary.Module; }
     38    }
     39
     40    public override IEnumerable<IEntity> Children {
     41      get { return base.Children.Concat(Nodes.AsEnumerable<IEntity>()); }
    3642    }
    3743
     
    4753      : base(original, cloner) {
    4854      nodes = cloner.Clone(original.nodes);
     55      foreach (var n in Nodes)
     56        n.Parent = this;
     57      RegisterNodesEvents();
    4958    }
    5059    public Network()
    5160      : base("Network") {
    5261      nodes = new NodeCollection();
     62      RegisterNodesEvents();
    5363    }
    5464    public Network(string name)
    5565      : base(name) {
    5666      nodes = new NodeCollection();
     67      RegisterNodesEvents();
    5768    }
    5869    public Network(string name, string description)
    5970      : base(name, description) {
    6071      nodes = new NodeCollection();
     72      RegisterNodesEvents();
     73    }
     74
     75    [StorableHook(HookType.AfterDeserialization)]
     76    private void AfterDeserialization() {
     77      foreach (var n in Nodes)
     78        n.Parent = this;
     79      RegisterNodesEvents();
    6180    }
    6281
     
    6483      return new Network(this, cloner);
    6584    }
     85
     86    #region Nodes Events
     87    protected virtual void RegisterNodesEvents() {
     88      nodes.ItemsAdded += Nodes_ItemsAdded;
     89      nodes.ItemsRemoved += Nodes_ItemsRemoved;
     90      nodes.ItemsReplaced += Nodes_ItemsReplaced;
     91      nodes.CollectionReset += Nodes_CollectionReset;
     92    }
     93    protected virtual void Nodes_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<INode> e) {
     94      foreach (var n in e.Items)
     95        n.Parent = this;
     96    }
     97    protected virtual void Nodes_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<INode> e) {
     98      foreach (var n in e.Items)
     99        n.Parent = null;
     100    }
     101    protected virtual void Nodes_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<INode> e) {
     102      foreach (var n in e.OldItems)
     103        n.Parent = null;
     104      foreach (var n in e.Items)
     105        n.Parent = this;
     106    }
     107    protected virtual void Nodes_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<INode> e) {
     108      foreach (var n in e.OldItems)
     109        n.Parent = null;
     110      foreach (var n in e.Items)
     111        n.Parent = this;
     112    }
     113    #endregion
    66114  }
    67115}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs

    r11423 r11449  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using System.Collections.Generic;
     28using System.Linq;
    2729
    2830namespace HeuristicLab.Optimization.Networks {
    2931  [Item("Node", "A node of an optimization network.")]
    3032  [StorableClass]
    31   public class Node : NamedItem, INode {
     33  public class Node : Entity, INode {
    3234    public static new Image StaticItemImage {
    3335      get { return HeuristicLab.Common.Resources.VSImageLibrary.RadialChart; }
     36    }
     37
     38    new public INetwork Parent {
     39      get { return (INetwork)base.Parent; }
     40      set {
     41        // NOTE: never call setter directly as the Parent property is set by the network which contains the node
     42        base.Parent = value;
     43      }
     44    }
     45    public override IEnumerable<IEntity> Children {
     46      get { return base.Children.Concat(Ports.AsEnumerable<IEntity>()); }
    3447    }
    3548
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs

    r11431 r11449  
    2929  [Item("Port", "Abstract base class for ports of an optimization network node.")]
    3030  [StorableClass]
    31   public abstract class Port : NamedItem, IPort {
     31  public abstract class Port : Entity, IPort {
    3232    public static new Image StaticItemImage {
    3333      get { return HeuristicLab.Common.Resources.VSImageLibrary.Field; }
    3434    }
    3535
    36     private INode parent;
    37     public INode Parent {
    38       get { return parent; }
     36    new public INode Parent {
     37      get { return (INode)base.Parent; }
    3938      set {
    4039        // NOTE: never call setter directly as the Parent property is set by the node which contains the port
    41         if (value != parent) {
    42           DeregisterParentEvents();
    43           parent = value;
    44           RegisterParentEvents();
    45           OnPathChanged();
    46         }
    47       }
    48     }
    49     public string Path {
    50       get {
    51         return parent != null ? parent.Name : string.Empty;
     40        base.Parent = value;
    5241      }
    5342    }
     
    5948    protected Port(string name) : base(name) { }
    6049    protected Port(string name, string description) : base(name, description) { }
    61 
    62     public event EventHandler PathChanged;
    63     protected virtual void OnPathChanged() {
    64       var handler = PathChanged;
    65       if (handler != null) handler(this, EventArgs.Empty);
    66     }
    67 
    68     #region Parent Events
    69     protected virtual void RegisterParentEvents() {
    70       if (parent != null) {
    71         parent.NameChanged += Parent_NameChanged;
    72       }
    73     }
    74     protected virtual void DeregisterParentEvents() {
    75       if (parent != null) {
    76         parent.NameChanged -= Parent_NameChanged;
    77       }
    78     }
    79     void Parent_NameChanged(object sender, EventArgs e) {
    80       OnPathChanged();
    81     }
    82     #endregion
    8350  }
    8451}
Note: See TracChangeset for help on using the changeset viewer.