private bool ValidateListBox(ProjectEditor editor, DragEventArgs e, bool bExecute, ListBox list) { var sourceItem = e.Data.Get(DragDataFormats.Parent); var targetItem = (e.Source as IControl)?.Parent; if (sourceItem is ListBoxItem source && targetItem is ListBoxItem target) { if (source.Parent == target.Parent) { int sourceIndex = list.ItemContainerGenerator.IndexFromContainer(source); int targetIndex = list.ItemContainerGenerator.IndexFromContainer(target); switch (list.DataContext) { case Library <ShapeStyle> library: { if (e.DragEffects == DragDropEffects.Copy) { if (bExecute) { // TODO: Clone item. } return(true); } else if (e.DragEffects == DragDropEffects.Move) { if (bExecute) { editor?.MoveItem(library, sourceIndex, targetIndex); } return(true); } else if (e.DragEffects == DragDropEffects.Link) { if (bExecute) { editor?.SwapItem(library, sourceIndex, targetIndex); } return(true); } return(false); } case Library <GroupShape> library: { if (e.DragEffects == DragDropEffects.Copy) { if (bExecute) { // TODO: Clone item. } return(true); } else if (e.DragEffects == DragDropEffects.Move) { if (bExecute) { editor?.MoveItem(library, sourceIndex, targetIndex); } return(true); } else if (e.DragEffects == DragDropEffects.Link) { if (bExecute) { editor?.SwapItem(library, sourceIndex, targetIndex); } return(true); } return(false); } default: return(false); } } else if (source.Parent is ListBox sourceList && target.Parent is ListBox targetList) { if (sourceList.DataContext?.GetType() == targetList.DataContext?.GetType()) { if (bExecute) { // TODO: Exchange items between lists. } return(true); } return(false); } return(false); } return(false); }