internal override SpacePlan Measure(Size availableSpace) { if (NormalizedTurnCount == 0 || NormalizedTurnCount == 2) { return(base.Measure(availableSpace)); } availableSpace = new Size(availableSpace.Height, availableSpace.Width); var childSpace = base.Measure(availableSpace); if (childSpace.Type == SpacePlanType.Wrap) { return(SpacePlan.Wrap()); } var targetSpace = new Size(childSpace.Height, childSpace.Width); if (childSpace.Type == SpacePlanType.FullRender) { return(SpacePlan.FullRender(targetSpace)); } if (childSpace.Type == SpacePlanType.PartialRender) { return(SpacePlan.PartialRender(targetSpace)); } throw new ArgumentException(); }
internal override SpacePlan Measure(Size availableSpace) { if (!Cells.Any()) { return(SpacePlan.FullRender(Size.Zero)); } UpdateColumnsWidth(availableSpace.Width); var renderingCommands = PlanLayout(availableSpace); if (!renderingCommands.Any()) { return(SpacePlan.Wrap()); } var width = Columns.Sum(x => x.Width); var height = renderingCommands.Max(x => x.Offset.Y + x.Size.Height); var tableSize = new Size(width, height); if (tableSize.Width > availableSpace.Width + Size.Epsilon) { return(SpacePlan.Wrap()); } return(FindLastRenderedRow(renderingCommands) == StartingRowsCount ? SpacePlan.FullRender(tableSize) : SpacePlan.PartialRender(tableSize)); }
internal override SpacePlan Measure(Size availableSpace) { if (!RenderingQueue.Any()) { return(SpacePlan.FullRender(Size.Zero)); } var lines = DivideTextItemsIntoLines(availableSpace.Width, availableSpace.Height).ToList(); if (!lines.Any()) { return(SpacePlan.Wrap()); } var width = lines.Max(x => x.Width); var height = lines.Sum(x => x.LineHeight); if (width > availableSpace.Width + Size.Epsilon || height > availableSpace.Height + Size.Epsilon) { return(SpacePlan.Wrap()); } var fullyRenderedItemsCount = lines .SelectMany(x => x.Elements) .GroupBy(x => x.Item) .Count(x => x.Any(y => y.Measurement.IsLast)); if (fullyRenderedItemsCount == RenderingQueue.Count) { return(SpacePlan.FullRender(width, height)); } return(SpacePlan.PartialRender(width, height)); }
internal override SpacePlan Measure(Size availableSpace) { var targetSpace = new Size( Math.Abs(availableSpace.Width / ScaleX), Math.Abs(availableSpace.Height / ScaleY)); var measure = base.Measure(targetSpace); if (measure.Type == SpacePlanType.Wrap) { return(SpacePlan.Wrap()); } var targetSize = new Size( Math.Abs(measure.Width * ScaleX), Math.Abs(measure.Height * ScaleY)); if (measure.Type == SpacePlanType.PartialRender) { return(SpacePlan.PartialRender(targetSize)); } if (measure.Type == SpacePlanType.FullRender) { return(SpacePlan.FullRender(targetSize)); } throw new ArgumentException(); }
public void Measure_General_EnoughSpace() { TestPlan .For(GetPadding) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure(new Size(340, 260), SpacePlan.FullRender(140, 60)) .CheckMeasureResult(SpacePlan.FullRender(200, 100)); }
public void Measure_FullRender() { TestPlan .For(GetLayers) .MeasureElement(new Size(800, 600)) .ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.FullRender(500, 400)) .CheckMeasureResult(SpacePlan.FullRender(500, 400)); }
internal override SpacePlan Measure(Size availableSpace) { if (Child == null || !FirstPageWasSkipped) { return(SpacePlan.FullRender(Size.Zero)); } return(Child.Measure(availableSpace)); }
internal override SpacePlan Measure(Size availableSpace) { if (Child == null || IsRendered) { return(SpacePlan.FullRender(0, 0)); } return(base.Measure(availableSpace)); }
public void Measure_ReturnsFullRender_WhenSecondChildReturnsFullRender() { TestPlan .For(CreateColumnWithTwoItems) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure("first", new Size(400, 300), SpacePlan.FullRender(200, 100)) .ExpectChildMeasure("second", new Size(400, 200), SpacePlan.FullRender(100, 50)) .CheckMeasureResult(SpacePlan.FullRender(200, 150)); }
internal override SpacePlan Measure(Size availableSpace) { if (IsRendered) { return(SpacePlan.FullRender(0, 0)); } return(SpacePlan.PartialRender(Size.Zero)); }
public void Measure_MaxHeight_Empty() { TestPlan .For(x => new Constrained { MaxHeight = 100 }) .MeasureElement(new Size(400, 150)) .CheckMeasureResult(SpacePlan.FullRender(0, 0)); }
public void Measure_MaxWidth_Empty() { TestPlan .For(x => new Constrained { MaxWidth = 100 }) .MeasureElement(new Size(150, 400)) .CheckMeasureResult(SpacePlan.FullRender(0, 0)); }
public void Measure_ReturnsWrap_WhenContentReturnsFullRender() { TestPlan .For(CreateDecoration) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure("before", new Size(400, 300), SpacePlan.FullRender(100, 50)) .ExpectChildMeasure("after", new Size(400, 300), SpacePlan.FullRender(100, 50)) .ExpectChildMeasure("content", new Size(400, 200), SpacePlan.FullRender(150, 100)) .CheckMeasureResult(SpacePlan.FullRender(150, 200)); }
public void Measure_TakesAvailableSpaceRegardlessOfSize() { TestPlan .For(x => new Image { InternalImage = GenerateImage(400, 300) }) .MeasureElement(new Size(300, 200)) .CheckMeasureResult(SpacePlan.FullRender(300, 200)); }
public void Measure_TakesAvailableSpaceRegardlessOfSize() { TestPlan .For(x => new DynamicImage { Source = GenerateImage }) .MeasureElement(new Size(300, 200)) .CheckMeasureResult(SpacePlan.FullRender(300, 200)); }
public void Measure_FullRender() { TestPlan .For(x => new Unconstrained { Child = x.CreateChild() }) .MeasureElement(new Size(900, 800)) .ExpectChildMeasure(Size.Max, SpacePlan.FullRender(1200, 1600)) .CheckMeasureResult(SpacePlan.FullRender(Size.Zero)); }
public void Measure_ReturnsFullRender_WhenElementReturnsFullRender() { TestPlan .For(x => new ShowEntire { Child = x.CreateChild() }) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(300, 200)) .CheckMeasureResult(SpacePlan.FullRender(300, 200)); }
private static void Measure_FullRender <TElement>() where TElement : Element, IContainer, new() { TestPlan .For(x => new TElement { Child = x.CreateChild() }) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(250, 150)) .CheckMeasureResult(SpacePlan.FullRender(250, 150)); }
public void Measure_MinHeight_PassHeight() { TestPlan .For(x => new Constrained { MinHeight = 100, Child = x.CreateChild() }) .MeasureElement(new Size(400, 200)) .ExpectChildMeasure(new Size(400, 200), SpacePlan.FullRender(400, 150)) .CheckMeasureResult(SpacePlan.FullRender(400, 150)); }
public void Draw_TogglesFirstRenderedFlag_WhenSecondFullyRenders() { TestPlan .For(CreateColumnWithTwoItemsWhereFirstIsFullyRendered) .DrawElement(new Size(400, 300)) .ExpectChildMeasure("second", new Size(400, 300), SpacePlan.FullRender(200, 300)) .ExpectCanvasTranslate(0, 0) .ExpectChildDraw("second", new Size(400, 300)) .ExpectCanvasTranslate(0, 0) .CheckDrawResult() .CheckState <Column>(x => !x.Items.First().IsRendered); }
public void Measure_RotateFlip() { TestPlan .For(x => new SimpleRotate { Child = x.CreateChild(), TurnCount = 2 }) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(200, 100)) .CheckMeasureResult(SpacePlan.FullRender(200, 100)); }
public void Measure_FullRender() { TestPlan .For(x => new MinimalBox { Child = x.CreateChild() }) .MeasureElement(new Size(500, 400)) .ExpectChildMeasure(expectedInput: new Size(500, 400), returns: SpacePlan.FullRender(300, 200)) .ExpectChildDraw(new Size(300, 200)) .CheckDrawResult(); }
public void Draw_WhenFirstChildFullyRenders_AndSecondChildWraps() { TestPlan .For(CreateColumnWithTwoItems) .DrawElement(new Size(400, 300)) .ExpectChildMeasure("first", new Size(400, 300), SpacePlan.FullRender(200, 100)) .ExpectChildMeasure("second", new Size(400, 200), SpacePlan.Wrap()) .ExpectCanvasTranslate(0, 0) .ExpectChildDraw("first", new Size(400, 100)) .ExpectCanvasTranslate(0, 0) .CheckDrawResult(); }
public void Measure_RotateLeft() { TestPlan .For(x => new SimpleRotate { Child = x.CreateChild(), TurnCount = 3 // or -1 }) .MeasureElement(new Size(500, 400)) .ExpectChildMeasure(new Size(400, 500), SpacePlan.FullRender(300, 350)) .CheckMeasureResult(SpacePlan.FullRender(350, 300)); }
public void Measure_ReturnsFullRender_WhenChildReturnsFullRender_AndEnoughSpace() { TestPlan .For(x => new EnsureSpace { Child = x.CreateChild(), MinHeight = 200 }) .MeasureElement(new Size(400, 300)) .ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(300, 250)) .CheckMeasureResult(SpacePlan.FullRender(300, 250)); }
public void Measure_MinWidth_ExtendHeight() { TestPlan .For(x => new Constrained { MinWidth = 100, Child = x.CreateChild() }) .MeasureElement(new Size(200, 400)) .ExpectChildMeasure(new Size(200, 400), SpacePlan.FullRender(50, 400)) .CheckMeasureResult(SpacePlan.FullRender(100, 400)); }
public void Draw_WhenChildFullyRenders() { TestPlan .For(x => new Unconstrained { Child = x.CreateChild() }) .DrawElement(new Size(900, 800)) .ExpectChildMeasure(Size.Max, SpacePlan.FullRender(1600, 1000)) .ExpectChildDraw(new Size(1600, 1000)) .CheckDrawResult(); }
public void Measure_FitHeight_EnoughSpace() { TestPlan .For(x => new AspectRatio { Child = x.CreateChild(), Option = AspectRatioOption.FitHeight, Ratio = 2f }) .MeasureElement(new Size(401, 200)) .ExpectChildMeasure(new Size(400, 200), SpacePlan.FullRender(100, 50)) .CheckMeasureResult(SpacePlan.FullRender(400, 200)); }
public void Measure_NegativeScaleY() { TestPlan .For(x => new Scale { Child = x.CreateChild(), ScaleX = 1, ScaleY = -3 }) .MeasureElement(new Size(800, 600)) .ExpectChildMeasure(new Size(800, 200), SpacePlan.FullRender(800, 100)) .CheckMeasureResult(SpacePlan.FullRender(800, 300)); }
public void Measure_FullRender() { TestPlan .For(x => new Scale { Child = x.CreateChild(), ScaleX = 3, ScaleY = 2 }) .MeasureElement(new Size(900, 800)) .ExpectChildMeasure(new Size(300, 400), SpacePlan.FullRender(250, 300)) .CheckMeasureResult(SpacePlan.FullRender(750, 600)); }