Example #1
0
 public void ShowAllLayersExcept(CardImageLayer notThisCardImageLayer)
 {
     foreach (CardImageLayer cardImageLayer in CardLayers)
     {
         cardImageLayer.IsHidden = cardImageLayer == notThisCardImageLayer;
     }
 }
Example #2
0
 public void HideAllLayersExcept(CardImageLayer notThisCardImageLayer)
 {
     foreach (CardImageLayer cardImageLayer in CardLayers)
     {
         cardImageLayer.IsVisible = cardImageLayer == notThisCardImageLayer;
     }
 }
Example #3
0
 private int GetIndexOfExisting(CardImageLayer selectedLayer)
 {
     for (int i = 0; i < CardLayers.Count; i++)
     {
         if (CardLayers[i].LayerName == selectedLayer.LayerName)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
 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);
 }
Example #7
0
 private static string GetCategory(CardImageLayer cardImageLayer)
 {
     return(cardImageLayer.Details.Name.EverythingBefore("-").Trim());
 }
Example #8
0
 public static void BindToCanvasPosition(CardImageLayer layer, Image image)
 {
     BindProperties(layer, CardImageLayer.XProperty, image, Canvas.LeftProperty);
     BindProperties(layer, CardImageLayer.YProperty, image, Canvas.TopProperty);
 }