public void ShowAllLayersExcept(CardImageLayer notThisCardImageLayer) { foreach (CardImageLayer cardImageLayer in CardLayers) { cardImageLayer.IsHidden = cardImageLayer == notThisCardImageLayer; } }
public void HideAllLayersExcept(CardImageLayer notThisCardImageLayer) { foreach (CardImageLayer cardImageLayer in CardLayers) { cardImageLayer.IsVisible = cardImageLayer == notThisCardImageLayer; } }
private int GetIndexOfExisting(CardImageLayer selectedLayer) { for (int i = 0; i < CardLayers.Count; i++) { if (CardLayers[i].LayerName == selectedLayer.LayerName) { return(i); } } return(-1); }
void AddImageLayerToCanvas(CardImageLayer layer, Canvas canvas) { Image image; if (layer.LayerName == "Placeholder") { if (layer.PlaceholderWidth == 0) { layer.SetPlaceholderDetails(); } image = layer.PlaceImageIntoPlaceholder(); } else { image = layer.CreateImage(); } canvas.Children.Add(image); Panel.SetZIndex(image, layer.Index); }
public void Replace(CardImageLayer selectedLayer, CardImageLayer newImageLayer, Canvas canvas) { if (selectedLayer == newImageLayer) { return; } selectedLayer.Details.IsSelected = false; newImageLayer.Details.IsSelected = true; int indexOfExisting = GetIndexOfExisting(selectedLayer); if (indexOfExisting < 0) { return; } bool imageFound = false; for (int i = canvas.Children.Count - 1; i >= 0; i--) { if (selectedLayer.ImageMatches(canvas.Children[i])) { canvas.Children.RemoveAt(i); canvas.Children.Insert(i, newImageLayer.CreateImage()); imageFound = true; break; } } if (!imageFound) { System.Diagnostics.Debugger.Break(); } CardLayers.RemoveAt(indexOfExisting); CardLayers.Insert(indexOfExisting, newImageLayer); }
public void Add(CardImageLayer cardImageLayer) { if (cardImageLayer.Details.Name.IndexOf("-") > 0) { string category = GetCategory(cardImageLayer); cardImageLayer.Category = category; cardImageLayer.Details.DisplayName = category; cardImageLayer.AlternateName = cardImageLayer.Details.Name.EverythingAfter("-").Trim(); CardImageLayer existingLayer = GetLayerForCategory(category); if (existingLayer != null) { if (existingLayer.Alternates == null) { existingLayer.Alternates = new AlternateCardImageLayers(); existingLayer.Alternates.CardLayers.Add(existingLayer); } existingLayer.Alternates.CardLayers.Add(cardImageLayer); cardImageLayer.Alternates = existingLayer.Alternates; return; } } CardLayers.Add(cardImageLayer); }
private static string GetCategory(CardImageLayer cardImageLayer) { return(cardImageLayer.Details.Name.EverythingBefore("-").Trim()); }
public static void BindToCanvasPosition(CardImageLayer layer, Image image) { BindProperties(layer, CardImageLayer.XProperty, image, Canvas.LeftProperty); BindProperties(layer, CardImageLayer.YProperty, image, Canvas.TopProperty); }