// Methods public PlaceholderAwareEnumerator(CollectionView collectionView, IEnumerator baseEnumerator, NewItemPlaceholderPosition placeholderPosition, object newItem) { this._collectionView = collectionView; this._timestamp = collectionView.Timestamp; this._baseEnumerator = baseEnumerator; this._placeholderPosition = placeholderPosition; this._newItem = newItem; }
private async Task ProcessSelectedOrdersShift(IDropInfo dropInfo, List <ProductionOrder> draggedItems, string selectedESR) { int insertIndex = (dropInfo.InsertIndex != dropInfo.UnfilteredInsertIndex) ? dropInfo.UnfilteredInsertIndex : dropInfo.InsertIndex; if (dropInfo.VisualTarget is ItemsControl itemsControl) { IEditableCollectionView editableItems = itemsControl.Items; if (editableItems != null) { NewItemPlaceholderPosition newItemPlaceholderPosition = editableItems.NewItemPlaceholderPosition; if (newItemPlaceholderPosition == NewItemPlaceholderPosition.AtBeginning && insertIndex == 0) { insertIndex++; } else if (newItemPlaceholderPosition == NewItemPlaceholderPosition.AtEnd && insertIndex == itemsControl.Items.Count) { insertIndex--; } } // Hack to guarantee we don't insert after the Target Item position if (dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem || dropInfo.InsertPosition.Equals(RelativeInsertPosition.AfterTargetItem | RelativeInsertPosition.TargetItemCenter)) { insertIndex = insertIndex - 1; } ProductionOrder targetLocationOrder = PlannedItems[insertIndex]; // Block Swaps that are not allowed bool allowed = await CheckIfSwapIsAllowed(selectedESR, targetLocationOrder); if (!allowed) { return; } // Removing the "Planner" Groupings UnsetCollectionGroupings(PlannedItems); // Removal of the Selected Rows foreach (ProductionOrder selectedItem in draggedItems) { int oldIndex = PlannedItems.IndexOf(selectedItem); PlannedItems.RemoveAt(oldIndex); if (oldIndex < insertIndex) { insertIndex--; } } // Insertion of the Selected Rows in the new positions foreach (ProductionOrder selectedItem in draggedItems) { // Update the dragged ProductionOrder to the new ESR before Insertion selectedItem.PlantID = targetLocationOrder.PlantID; selectedItem.Plant = targetLocationOrder.Plant; PlannedItems.Insert(insertIndex++, selectedItem); } // Updating the "Planner" SetCollectionGrouping(PlannedItems, "Plant.Name"); ResetPlannerSelectionState(); PlannedItems.SortCollectionBy(m => m.Plant.Name); RaisePropertyChanged("PlannedItems"); } }