Changeset 11538 for branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/NetworkItem.cs
- Timestamp:
- 11/12/14 01:43:03 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Core.Networks/NetworkItem.cs
r11528 r11538 31 31 [StorableClass] 32 32 public abstract class NetworkItem : NamedItem, INetworkItem { 33 public static readonly string PathSeparator = " => ";34 33 public static new Image StaticItemImage { 35 34 get { return HeuristicLab.Common.Resources.VSImageLibrary.Class; } … … 41 40 protected set { 42 41 if (value != parent) { 43 DeregisterParentEvents();44 42 parent = value; 45 RegisterParentEvents();46 OnPathChanged();47 43 } 48 44 } … … 50 46 public virtual IEnumerable<INetworkItem> Children { 51 47 get { return Enumerable.Empty<INetworkItem>(); } 52 }53 public string Path {54 get {55 return parent != null ? parent.Path + PathSeparator + Name : Name;56 }57 48 } 58 49 … … 63 54 protected NetworkItem(string name) : base(name) { } 64 55 protected NetworkItem(string name, string description) : base(name, description) { } 65 66 protected override void OnNameChanging(CancelEventArgs<string> e) {67 base.OnNameChanging(e);68 e.Cancel = e.Cancel || e.Value.Contains(PathSeparator);69 }70 protected override void OnNameChanged() {71 base.OnNameChanged();72 OnPathChanged();73 }74 75 public event EventHandler PathChanged;76 protected virtual void OnPathChanged() {77 var handler = PathChanged;78 if (handler != null) handler(this, EventArgs.Empty);79 }80 81 #region Parent Events82 protected virtual void RegisterParentEvents() {83 if (parent != null) {84 parent.PathChanged += Parent_PathChanged;85 }86 }87 protected virtual void DeregisterParentEvents() {88 if (parent != null) {89 parent.PathChanged -= Parent_PathChanged;90 }91 }92 void Parent_PathChanged(object sender, EventArgs e) {93 OnPathChanged();94 }95 #endregion96 56 } 97 57 }
Note: See TracChangeset
for help on using the changeset viewer.