Esempio n. 1
0
        public virtual Rectangle MeasureItem(TItem item, Dimension dimension, Size distance, ref Rectangle bounds)
        {
            Action <TItem> visit = null;

            AffectedEdges(ref visit);

            var measure = new MeasureVisitBuilder <TItem> (this.Locator);
            var fBounds = measure.Bounds(ref visit);
            var fSize   = measure.SizeToFit(ref visit, distance, dimension);

            visit(item);

            var colBounds = fBounds();

            if (colBounds.IsEmpty)
            {
                colBounds.Location = bounds.Location;
            }
            colBounds.Size = fSize();

            bounds.Location = bounds.Location.Min(colBounds.Location);
            bounds.Size     = bounds.Size.SizeToFit(colBounds.Size, dimension);

            return(colBounds);
        }
Esempio n. 2
0
        public virtual Tuple <IEnumerable <TItem>, Rectangle> MeasureColumn(IEnumerable <TItem> colItems, AlignerOptions options, ref Rectangle bounds)
        {
            Action <TItem> visit = null;

            var items = new Queue <TItem>();

            visit += i => items.Enqueue(i);
            AffectedEdges(ref visit);

            var measure = new MeasureVisitBuilder <TItem>(this.Locator);
            var fBounds = measure.Bounds(ref visit);
            var fSize   = measure.SizeToFit(ref visit, options.Distance, options.Dimension);

            VisitItems(colItems, visit);

            var colBounds = fBounds();

            if (colBounds.IsEmpty)
            {
                colBounds.Location = bounds.Location;
            }
            colBounds.Size = fSize();

            bounds.Location = bounds.Location.Min(colBounds.Location);
            bounds.Size     = bounds.Size.SizeToFit(colBounds.Size, options.Dimension);

            return(new Tuple <IEnumerable <TItem>, Rectangle>(items, colBounds));
        }
Esempio n. 3
0
        public static Size SizeToFit <TItem> (this ILocator <TItem> loc, IEnumerable <TItem> items, Size distance, Dimension dimension)
        {
            Action <TItem> visit   = null;
            var            measure = new MeasureVisitBuilder <TItem> (loc);
            var            fSize   = measure.SizeToFit(ref visit, distance, dimension);

            items.ForEach(e => visit(e));
            return(fSize());
        }
Esempio n. 4
0
        public static Rectangle Bounds <TItem> (this ILocator <TItem> loc, IEnumerable <TItem> items)
        {
            Action <TItem> visit   = null;
            var            measure = new MeasureVisitBuilder <TItem>(loc);
            var            fBounds = measure.Bounds(ref visit);

            items.ForEach(e => visit(e));
            return(fBounds());
        }
Esempio n. 5
0
        public static Func <Rectangle> Bounds <TItem> (this ILocator <TItem> loc, Action <TItem> visit)
        {
            var measure = new MeasureVisitBuilder <TItem> (loc);

            return(measure.Bounds(ref visit));
        }