//public event NavigatedEventHandler OnNavigated; public PModelObjectNavigator(PBaseObject owner) { _owner = owner; //levels = new List<string>(); // _positionInLevel = new List<int>(); _path = new PNavigatorPath(); }
//public List<int> GetPathTo(PBaseObject toObject) //{ // List<int> path = new List<int>(); // if (toObject._ownerCollection == null) // return null; // PBaseObject obj = toObject; // while (obj._ownerCollection.Owner != null) // { // path.Insert(0, obj._ownerCollection.IndexOf(obj)); // if (obj._ownerCollection.Owner == this) // { // return path; // } // obj = obj._ownerCollection.Owner; // } // return null; //} public PNavigatorPath GetPathTo(PBaseObject toObject) { PNavigatorPath path = new PNavigatorPath(); if (toObject._ownerCollection == null) return null; PBaseObject obj = toObject; while (obj._ownerCollection.Owner != null) { path.Parts.Insert(0, new PNavigatorPartPath(obj._ownerCollection.Name, obj._ownerCollection.IndexOf(obj))); if (obj._ownerCollection.Owner == this) { return path; } obj = obj._ownerCollection.Owner; } return null; }