public void UpdateIsDropAllowed() { if (ViewModel.Instance.DragSource == null && ViewModel.Instance.SelectedSlot == null) { IsDropAllowed = true; } else if (ViewModel.Instance.DragSource != null) { Slot sourceSlot = ViewModel.Instance.DragSource; Item sourceItem = ViewModel.Instance.DraggedItem; IsDropAllowed = IsItemAllowed(sourceItem) && sourceSlot.IsItemAllowed(Item); } else // ViewModel.Instance.SelectedSlot != null { Slot sourceSlot = ViewModel.Instance.SelectedSlot; IsDropAllowed = sourceSlot == this || (AllowedCategory == ItemCategory.All && (Item == null || Item.Category == sourceSlot.AllowedCategory)); } }
public void UpdateIsDropAllowed(Slot selected, Slot source, Item draggedItem) { if (source == null && selected == null) { IsDropAllowed = true; } else if (source != null) { Slot sourceSlot = source; Item sourceItem = draggedItem; IsDropAllowed = AllowedCategory == sourceSlot.AllowedCategory || (IsItemAllowed(sourceItem) && sourceSlot.IsItemAllowed(Item)); } else // selected != null { Slot sourceSlot = selected; IsDropAllowed = sourceSlot == this || (AllowedCategory == ItemCategory.All && Item != null && sourceSlot.AllowedCategory == Item.Category); } OnPropertyChanged("IsDropAllowed"); }