Exemplo n.º 1
0
        /// <summary>
        /// Fills the slot canvas with instances according to given slot definition.
        /// </summary>
        /// <param name="slotCanvas">The slot canvas that will be filled.</param>
        /// <param name="slot">The slot definition.</param>
        public void FillSlot(SlotCanvas slotCanvas, SlotDefinition slot)
        {
            //recursive check is required only for diagram items 
            //filling some slots - only some of its children can be recursive
            slotCanvas.SetOwner(this);

            var ancestors = new HashSet<DiagramItemDefinition>();
            var current = this;
            while (current != null)
            {
                ancestors.Add(current.Definition);
                current = current.ParentItem;
            }

            foreach (var itemReference in slot.References)
            {
                var itemDefinition = DiagramContext.Diagram.GetItemDefinition(itemReference.DefinitionID);

                var item = new DiagramItem(itemDefinition, this, slotCanvas);
                item.IsRecursive = ancestors.Contains(itemDefinition);
                DiagramContext.Provider.InitializeItemDrawing(item);
                slotCanvas.Children.Add(item);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiagramItem" /> class.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <param name="parentItem">The parent item.</param>
        /// <param name="slot">The slot.</param>
        internal DiagramItem(DiagramItemDefinition definition, DiagramItem parentItem, SlotCanvas slot)
        {
            ContainingDiagramCanvas = slot;
            Definition = definition;
            ParentItem = parentItem;
            ParentItem._children.Add(this);
            DiagramContext = parentItem.DiagramContext;

            initialize();
        }