コード例 #1
0
        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();
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: Scale.cs プロジェクト: lmingle/library
        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();
        }
コード例 #5
0
ファイル: PaddingTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #6
0
 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));
 }
コード例 #7
0
        internal override SpacePlan Measure(Size availableSpace)
        {
            if (Child == null || !FirstPageWasSkipped)
            {
                return(SpacePlan.FullRender(Size.Zero));
            }

            return(Child.Measure(availableSpace));
        }
コード例 #8
0
ファイル: ShowOnce.cs プロジェクト: lmingle/library
        internal override SpacePlan Measure(Size availableSpace)
        {
            if (Child == null || IsRendered)
            {
                return(SpacePlan.FullRender(0, 0));
            }

            return(base.Measure(availableSpace));
        }
コード例 #9
0
ファイル: ColumnTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #10
0
ファイル: PageBreak.cs プロジェクト: lmingle/library
        internal override SpacePlan Measure(Size availableSpace)
        {
            if (IsRendered)
            {
                return(SpacePlan.FullRender(0, 0));
            }

            return(SpacePlan.PartialRender(Size.Zero));
        }
コード例 #11
0
 public void Measure_MaxHeight_Empty()
 {
     TestPlan
     .For(x => new Constrained
     {
         MaxHeight = 100
     })
     .MeasureElement(new Size(400, 150))
     .CheckMeasureResult(SpacePlan.FullRender(0, 0));
 }
コード例 #12
0
 public void Measure_MaxWidth_Empty()
 {
     TestPlan
     .For(x => new Constrained
     {
         MaxWidth = 100
     })
     .MeasureElement(new Size(150, 400))
     .CheckMeasureResult(SpacePlan.FullRender(0, 0));
 }
コード例 #13
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));
 }
コード例 #14
0
ファイル: ImageTests.cs プロジェクト: lmingle/library
 public void Measure_TakesAvailableSpaceRegardlessOfSize()
 {
     TestPlan
     .For(x => new Image
     {
         InternalImage = GenerateImage(400, 300)
     })
     .MeasureElement(new Size(300, 200))
     .CheckMeasureResult(SpacePlan.FullRender(300, 200));
 }
コード例 #15
0
ファイル: DynamicImageTests.cs プロジェクト: lmingle/library
 public void Measure_TakesAvailableSpaceRegardlessOfSize()
 {
     TestPlan
     .For(x => new DynamicImage
     {
         Source = GenerateImage
     })
     .MeasureElement(new Size(300, 200))
     .CheckMeasureResult(SpacePlan.FullRender(300, 200));
 }
コード例 #16
0
 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));
 }
コード例 #17
0
ファイル: ShowEntireTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #18
0
 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));
 }
コード例 #19
0
 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));
 }
コード例 #20
0
ファイル: ColumnTests.cs プロジェクト: lmingle/library
 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);
 }
コード例 #21
0
ファイル: SimpleRotateTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #22
0
ファイル: BoxTests.cs プロジェクト: lmingle/library
 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();
 }
コード例 #23
0
ファイル: ColumnTests.cs プロジェクト: lmingle/library
 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();
 }
コード例 #24
0
ファイル: SimpleRotateTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #25
0
ファイル: EnsureSpaceTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #26
0
 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));
 }
コード例 #27
0
 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();
 }
コード例 #28
0
 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));
 }
コード例 #29
0
ファイル: ScaleTests.cs プロジェクト: lmingle/library
 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));
 }
コード例 #30
0
ファイル: ScaleTests.cs プロジェクト: lmingle/library
 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));
 }