private void DeleteInternalLayer(int position) { InternalLayerDisplay display = internalLayerDisplays[position]; AddInternalLayerButton button = addLayerButtons[position + 1]; internalLayerDisplays.Remove(display); addLayerButtons.Remove(button); InternalLayersPanel.Children.Remove(display); InternalLayersPanel.Children.Remove(button); internalLayerDisplays.GetRange(position, internalLayerDisplays.Count - position).ForEach(x => x.Position--); if (addLayerButtons.Count > position + 1) { addLayerButtons.GetRange(position + 1, addLayerButtons.Count - position).ForEach(x => x.Position--); } }
private void AddInternalLayer(int position, int length) // To the left of current layer at this position { internalLayerDisplays.GetRange(position, internalLayerDisplays.Count - position).ForEach((x) => x.Position++); InternalLayerDisplay display = new InternalLayerDisplay(DeleteInternalLayer, position, length); // Every layer has an AddLayerButton after it, so multiply by 2 // Also add 1 to account for the initial Add button int positionToPlaceLayerDisplay = position * 2 + 1; if (positionToPlaceLayerDisplay == InternalLayersPanel.Children.Count) { InternalLayersPanel.Children.Add(display); internalLayerDisplays.Add(display); } else { InternalLayersPanel.Children.Insert(positionToPlaceLayerDisplay, display); internalLayerDisplays.Insert(position, display); } AddAddInternalLayerButton(position + 1); // Button to create a layer at the NEXT index }