Beispiel #1
0
 public BlockContainer(BlockContainer bc) //copy
 {
     Items = new IdeCollection <IdeBaseItem>(this, typeof(IBaseBlock));
     Items.CollectionChanged += (a, b) =>
     {
         OnContainerChanged?.Invoke(this, b);
     };
     foreach (var block in bc.Items)
     {
         if (block is SwitchBlockModel switchBlock)
         {
             Items.Add(new SwitchBlockModel(switchBlock, Items));
         }
         else if (block is ConditionalBlockModel conditionalBlock)
         {
             Items.Add(new ConditionalBlockModel(conditionalBlock, Items));
         }
         else if (block is TextLinkModel textLink)
         {
             Items.Add(new TextLinkModel(textLink, Items));
         }
         else if (block is OverlayLinkContainer overlayContainer)
         {
             Items.Add(new OverlayLinkContainer(overlayContainer, Items));
         }
         else if (block is ArtOverlayBlockModel artOverlay)
         {
             Items.Add(new ArtOverlayBlockModel(artOverlay, Items));
         }
     }
 }
Beispiel #2
0
 public BlockContainer() //new
 {
     Items = new IdeCollection <IdeBaseItem>(this, typeof(IBaseBlock));
     Items.CollectionChanged += (a, b) =>
     {
         OnContainerChanged?.Invoke(this, b);
     };
 }
Beispiel #3
0
 public BlockContainer(List <LinkDefinition.LinkWrapper> items) //load
 {
     Items = new IdeCollection <IdeBaseItem>(this, typeof(IBaseBlock));
     foreach (LinkDefinition.LinkWrapper item in items)
     {
         if (item.Conditional != null)
         {
             if (item.Conditional.switchProperty != null)
             {
                 Items.Add(new SwitchBlockModel(item, Items));
             }
             else if (item.Conditional.ifNode != null)
             {
                 Items.Add(new ConditionalBlockModel(item, Items));
             }
         }
         else if (item.Link != null)
         {
             if (item.Link.IsTextLink)
             {
                 Items.Add(new TextLinkModel(item, Items));
             }
             else
             {
                 OverlayLinkContainer container;
                 if (!(Items.LastOrDefault() is OverlayLinkContainer))
                 {
                     container = new OverlayLinkContainer(Items);
                     Items.Add(container); //adds a new link container at the end
                 }
                 else
                 {
                     container = Items.Last() as OverlayLinkContainer;
                     container.Items.CollectionChanged -= (a, b) =>
                     {
                         OnContainerChanged?.Invoke(this, b);
                     };
                 }
                 container.Items.Add(new OverlayLinkModel(item, container.Items));
                 container.Items.CollectionChanged += (a, b) =>
                 {
                     OnContainerChanged?.Invoke(this, b);
                 };
             }
         }
         else if (item.CardArtCrop != null)
         {
             Items.Add(new ArtOverlayBlockModel(item, Items));
         }
     }
     Items.CollectionChanged += (a, b) =>
     {
         OnContainerChanged?.Invoke(this, b);
     };
 }
Beispiel #4
0
 public void AddLink(OverlayLinkModel link, int index)
 {
     // if the next item is the OverlayLinkContainer
     if (index < Items.Count && Items[index] is OverlayLinkContainer nextContainer)
     {
         nextContainer.AddLink(0, link);
     }
     // if the previous item is the OverlayLinkContainer
     else if (index > 0 && Items[index - 1] is OverlayLinkContainer previousContainer)
     {
         previousContainer.AddLink(previousContainer.Items.Count, link);
     }
     // if there isn't any adjacent OverlayLinkContainers
     else
     {
         var newContainer = new OverlayLinkContainer(Items);
         newContainer.Items.CollectionChanged += (a, b) =>
         {
             OnContainerChanged?.Invoke(this, b);
         };
         Items.Insert(index, newContainer);
         newContainer.AddLink(0, link);
     }
 }