Ignore:
Timestamp:
05/04/16 15:15:10 (3 years ago)
Author:
jkarder
Message:

#2205: worked on optimization networks

  • added layout algorithm prototype
  • fixed bug in LoadVisualProperties methods
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks.Views.NetworkVisualization/3.3/Primitives/AlgorithmNodeRectangle.cs

    r13799 r13833  
    3030    protected readonly Brush ActiveBrush = new SolidBrush(Color.FromArgb(255, 100, 200, 100));
    3131
     32    public new IAlgorithmNode NetworkItem {
     33      get { return (IAlgorithmNode)base.NetworkItem; }
     34      set { base.NetworkItem = value; }
     35    }
     36
    3237    public AlgorithmNodeRectangle(IChart chart, IAlgorithmNode node)
    3338      : base(chart, node) {
    3439      Brush = InactiveBrush;
    35       node.Algorithm.Started += (sender, args) => Brush = ActiveBrush;
    36       node.Algorithm.Stopped += (sender, args) => Brush = InactiveBrush;
    37       node.StartedAlgorithmsChanged += (sender, args) => Brush = ((IAlgorithmNode)sender).StartedAlgorithms.Any() ? ActiveBrush : InactiveBrush;
    3840    }
     41
     42    protected override void RegisterNetworkItemEvents() {
     43      base.RegisterNetworkItemEvents();
     44      NetworkItem.StartedAlgorithmsChanged += NetworkItem_StartedAlgorithmsChanged;
     45      if (NetworkItem.Algorithm != null) {
     46        NetworkItem.Algorithm.Started += Algorithm_Started; ;
     47        NetworkItem.Algorithm.Stopped += Algorithm_Stopped; ;
     48      }
     49    }
     50
     51    protected override void DeregisterNetworkItemEvents() {
     52      if (NetworkItem.Algorithm != null) {
     53        NetworkItem.Algorithm.Stopped -= Algorithm_Stopped; ;
     54        NetworkItem.Algorithm.Started -= Algorithm_Started; ;
     55      }
     56      NetworkItem.StartedAlgorithmsChanged -= NetworkItem_StartedAlgorithmsChanged;
     57      base.DeregisterNetworkItemEvents();
     58    }
     59
     60    private void NetworkItem_StartedAlgorithmsChanged(object sender, System.EventArgs e) {
     61      Brush = ((IAlgorithmNode)sender).StartedAlgorithms.Any() ? ActiveBrush : InactiveBrush;
     62    }
     63    private void Algorithm_Started(object sender, System.EventArgs e) { Brush = ActiveBrush; }
     64    private void Algorithm_Stopped(object sender, System.EventArgs e) { Brush = InactiveBrush; }
    3965  }
    4066}
Note: See TracChangeset for help on using the changeset viewer.