private DragAndDropVisualMode DoHandleSingleObjectDrop <TObject>(DragAndDropArgs args, TObject o, int offset) { var handler = HierarchyDragAndDrop <TObject, Key> .SingleObjectDrop; if (null == handler) { return(DragAndDropVisualMode.Rejected); } var item = GetDragAndDropItem(args); var result = DragAndDropVisualMode.Rejected; ISceneGraphNode resultNode = null; if (item is SceneItem sceneItem) { if (null != (resultNode = handler(m_Session, o, sceneItem.Graph, null, args.dragAndDropPosition == DragAndDropPosition.BetweenItems ? args.insertAtIndex : -1))) { IdsToExpand.Add(sceneItem.id); result = DragAndDropVisualMode.Link; } } if (item is EntityItem entityItem) { var node = entityItem.Node; if (null != (resultNode = handler(m_Session, o, node.Graph as SceneGraph, node, args.dragAndDropPosition == DragAndDropPosition.BetweenItems ? args.insertAtIndex : -1))) { IdsToExpand.Add(entityItem.id); result = DragAndDropVisualMode.Link; } } if (null == resultNode) { return(DragAndDropVisualMode.Rejected); } if (result == DragAndDropVisualMode.Link) { if (resultNode is EntityNode entityNode) { EntityHierarchyWindow.SelectOnNextPaint(entityNode.Guid); } } return(result); }
public void DuplicateSelection() { using (var pooled = ListPool <ISceneGraphNode> .GetDisposable()) { var toSelect = pooled.List; var selection = GetEntitySelection(); foreach (var group in selection.GroupBy( e => m_EntityManager.GetSharedComponentData <SceneGuid>(e.Entity))) { var graph = m_SceneManager.GetGraphForScene(group.Key); var list = group.Cast <ISceneGraphNode>().ToList(); toSelect.AddRange(graph.Duplicate(list)); } EntityHierarchyWindow.SelectOnNextPaint(toSelect.OfType <EntityNode>().Select(e => e.Guid).ToList()); } }