public override void OnNodeDrop(object dataObject, DragOperation operation) { // It allows dropping either project references or projects. // Dropping a project creates a new project reference to that project DotNetProject project = dataObject as DotNetProject; if (project != null) { ProjectReference pr = new ProjectReference(project); DotNetProject p = CurrentNode.GetParentDataItem(typeof(DotNetProject), false) as DotNetProject; if (ProjectReferencesProject(project, p.Name)) { return; } p.References.Add(pr); IdeApp.ProjectOperations.Save(p); return; } // It's dropping a ProjectReference object. ProjectReference pref = dataObject as ProjectReference; ITreeNavigator nav = CurrentNode; if (operation == DragOperation.Move) { NodePosition pos = nav.CurrentPosition; nav.MoveToObject(dataObject); DotNetProject p = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; nav.MoveToPosition(pos); DotNetProject p2 = nav.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; p.References.Remove(pref); // Check if there is a cyclic reference after removing from the source project if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = p.ParentSolution.FindProjectByName(pref.Reference) as DotNetProject; if (pdest == null || ProjectReferencesProject(pdest, p2.Name)) { // Restore the dep p.References.Add(pref); return; } } p2.References.Add(pref); IdeApp.ProjectOperations.Save(p); IdeApp.ProjectOperations.Save(p2); } else { nav.MoveToParent(typeof(DotNetProject)); DotNetProject p = nav.DataItem as DotNetProject; // Check for cyclic referencies if (pref.ReferenceType == ReferenceType.Project) { DotNetProject pdest = p.ParentSolution.FindProjectByName(pref.Reference) as DotNetProject; if (pdest == null || ProjectReferencesProject(pdest, p.Name)) { return; } } p.References.Add((ProjectReference)pref.Clone()); IdeApp.ProjectOperations.Save(p); } }