Ejemplo n.º 1
0
 public ComponentPresentationInfo(Page page, ComponentPresentation componentPresentation, Region owner)
 {
     ComponentPresentation = componentPresentation;
     InnerRegion = GetInnerRegion(page, componentPresentation.ComponentTemplate);
     RegionIndex = Region.ExtractRegionIndex(componentPresentation.ComponentTemplate.Id);
     Owner = owner;
 }
Ejemplo n.º 2
0
        public static IList<Region> GetRegions(Page page)
        {
            int regionCount = 0;
            int pageIndex = 0;
            IList<Region> regions = new List<Region>();
            Region currentRegion = null;
            InnerRegion innerRegion = null;

            // TODO: Have a better page index calculation algorithm that can handle reshuffle of component presentations
            //

            foreach (ComponentPresentation cp in page.ComponentPresentations )
            {
                if ( IsRegion(cp) )
                {
                    currentRegion = new Region(page, cp.Component);
                    currentRegion.Index = ++regionCount;
                    currentRegion.pageIndex = pageIndex;
                    regions.Add(currentRegion);
                }
                else if (innerRegion != null && innerRegion.CanContain(cp))
                {
                    innerRegion.AddToComponentPresentationList(cp);
                }
                else
                {
                    if (currentRegion != null)
                    {
                        ComponentPresentationInfo cpInfo = currentRegion.AddToComponentPresentationList(cp);
                        innerRegion = cpInfo.InnerRegion;
                        if (innerRegion != null)
                        {
                            innerRegion.Index = ++regionCount;
                            innerRegion.pageIndex = pageIndex;
                        }
                    }
                }
                pageIndex++; // This works only if we move the last item around....
            }

            return regions;
        }