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 TemplateModel(TemplateModel p, IdeCollection <IdeBaseItem> source) : base(source) //copy
        {
            CanBeDefault = true;
            CanEdit      = false;
            _def         = new TemplateDefinition()
            {
                OverlayBlocks = p._def.OverlayBlocks,
                TextBlocks    = p._def.TextBlocks,
                Matches       = p._def.Matches,
            };

            Asset = new AssetController(AssetType.Image);
            Asset.Register(p._def.src);
            _def.src = Asset.SelectedAsset.FullPath;
            Asset.PropertyChanged += AssetUpdated;

            Matches = new IdeCollection <IdeBaseItem>(this);
            Matches.CollectionChanged += (a, b) =>
            {
                BuildMatchDef(b);
            };
            foreach (MatchModel match in p.Matches)
            {
                Matches.Add(new MatchModel(match, Matches));
            }

            OverlayContainer = new BlockContainer(p.OverlayContainer);
            OverlayContainer.OnContainerChanged += (a, b) =>
            {
                _def.OverlayBlocks = OverlayContainer.BuildTemplateBlockDef(b);
            };
            _def.OverlayBlocks = OverlayContainer.BuildTemplateBlockDef(null);
            TextBlockContainer = new BlockContainer(p.TextBlockContainer);
            TextBlockContainer.OnContainerChanged += (a, b) =>
            {
                _def.TextBlocks = TextBlockContainer.BuildTemplateBlockDef(b);
            };
            _def.TextBlocks = TextBlockContainer.BuildTemplateBlockDef(null);

            AddMatchCommand = new RelayCommand(AddMatch);
            AddOverlayConditionalCommand = new RelayCommand(AddOverlayConditional);
            AddOverlaySwitchCommand      = new RelayCommand(AddOverlaySwitch);
            AddTextConditionalCommand    = new RelayCommand(AddTextConditional);
            AddTextSwitchCommand         = new RelayCommand(AddTextSwitch);
            OverlayDropHandler           = new TemplateMainDropHandler()
            {
                IsOverlayHandler = true
            };
            TextDropHandler = new TemplateMainDropHandler()
            {
                IsOverlayHandler = false
            };
            DragHandler = new TemplateMainDragHandler();
        }
Beispiel #3
0
        public TemplateModel(TemplateDefinition t, IdeCollection <IdeBaseItem> source) : base(source) //load
        {
            CanBeDefault = true;
            CanEdit      = false;
            _def         = t;

            Asset = new AssetController(AssetType.Image);
            Asset.Register(t.src);
            Asset.PropertyChanged += AssetUpdated;

            Matches = new IdeCollection <IdeBaseItem>(this);
            foreach (var match in t.Matches)
            {
                Matches.Add(new MatchModel(match, Matches));
            }
            Matches.CollectionChanged += (a, b) =>
            {
                BuildMatchDef(b);
            };
            OverlayContainer = new BlockContainer(t.OverlayBlocks);
            OverlayContainer.OnContainerChanged += (a, b) =>
            {
                _def.OverlayBlocks = OverlayContainer.BuildTemplateBlockDef(b);
            };
            TextBlockContainer = new BlockContainer(t.TextBlocks);
            TextBlockContainer.OnContainerChanged += (a, b) =>
            {
                _def.TextBlocks = TextBlockContainer.BuildTemplateBlockDef(b);
            };
            AddMatchCommand = new RelayCommand(AddMatch);
            AddOverlayConditionalCommand = new RelayCommand(AddOverlayConditional);
            AddOverlaySwitchCommand      = new RelayCommand(AddOverlaySwitch);
            AddTextConditionalCommand    = new RelayCommand(AddTextConditional);
            AddTextSwitchCommand         = new RelayCommand(AddTextSwitch);
            OverlayDropHandler           = new TemplateMainDropHandler()
            {
                IsOverlayHandler = true
            };
            TextDropHandler = new TemplateMainDropHandler()
            {
                IsOverlayHandler = false
            };
            DragHandler = new TemplateMainDragHandler();
        }