private static void OnDragOver(object sender, [NotNull] DragEventArgs e) { // Unless we're over a control that accepts drop, we're going to reject the drop. e.Effects = DragDropEffects.None; dataType = DisplayDropAdorner.Never; var items = DragDropHelper.GetItemsToDrop(DragDropHelper.GetDragContainer(e.Data), e.Data as DataObject); if (items != null) { var isInternal = DragDropHelper.ShouldDisplayDropAdorner(DisplayDropAdorner.InternalOnly, items); var isExternal = DragDropHelper.ShouldDisplayDropAdorner(DisplayDropAdorner.ExternalOnly, items); dataType = (isInternal ? DisplayDropAdorner.InternalOnly : DisplayDropAdorner.Never) | (isExternal ? DisplayDropAdorner.ExternalOnly : DisplayDropAdorner.Never); } Activate(); DragLeaveTimer.Reset(); }
internal static bool ShouldDisplayDropAdorner(DisplayDropAdorner rule, IEnumerable <object> itemsToDrop) { switch (rule) { case DisplayDropAdorner.Never: return(false); case DisplayDropAdorner.InternalOnly: return(itemsToDrop.All(x => !(x is UFile))); case DisplayDropAdorner.ExternalOnly: return(itemsToDrop.All(x => x is UFile)); case DisplayDropAdorner.Always: return(true); default: throw new ArgumentOutOfRangeException(nameof(rule)); } }