public void Dock(DockObject requestor, DockPlacement position, object data) { if (requestor == null || requestor == this) { return; } if (master == null) { Console.WriteLine("Dock operation requested in a non-bound object {0}.", this); Console.WriteLine("This might break."); } if (!requestor.IsBound) { requestor.Bind(Master); } if (requestor.Master != Master) { Console.WriteLine("Cannot dock {0} to {1} as they belong to different masters.", requestor, this); return; } /* first, see if we can optimize things by reordering */ if (position != DockPlacement.None) { DockObject parent = ParentObject; if (OnReorder(requestor, position, data) || (parent != null && parent.OnReorder(requestor, position, data))) { return; } } /* freeze the object, since under some conditions it might * be destroyed when detaching the requestor */ Freeze(); /* detach the requestor before docking */ if (requestor.IsAttached) { requestor.Detach(false); } /* notify interested parties that an object has been docked. */ if (position != DockPlacement.None) { OnDocked(requestor, position, data); DockedHandler handler = Docked; if (handler != null) { DockedArgs args = new DockedArgs(requestor, position); handler(this, args); } } Thaw(); }
public void Dock(DockObject requestor, DockPlacement position, object data) { if (requestor == null || requestor == this) return; if (master == null) { Console.WriteLine ("Dock operation requested in a non-bound object {0}.", this); Console.WriteLine ("This might break."); } if (!requestor.IsBound) requestor.Bind (Master); if (requestor.Master != Master) { Console.WriteLine ("Cannot dock {0} to {1} as they belong to different masters.", requestor, this); return; } /* first, see if we can optimize things by reordering */ if (position != DockPlacement.None) { DockObject parent = ParentObject; if (OnReorder (requestor, position, data) || (parent != null && parent.OnReorder (requestor, position, data))) return; } /* freeze the object, since under some conditions it might be destroyed when detaching the requestor */ Freeze (); /* detach the requestor before docking */ if (requestor.IsAttached) requestor.Detach (false); /* notify interested parties that an object has been docked. */ if (position != DockPlacement.None) { OnDocked (requestor, position, data); DockedHandler handler = Docked; if (handler != null) { DockedArgs args = new DockedArgs (requestor, position); handler (this, args); } } Thaw (); }