示例#1
0
        private void ComputeBoundingBox(TElement element)
        {
            var box = new TRectangle()
            {
                Width  = element.Css.Width.Value,
                Height = element.Css.Height.Value
            };

            var childFloatAttribute = element.GetFloat();

            if (childFloatAttribute == Float.None)
            {
                box.X = BoundingBox.Left;
                box.Y = LeftFloatPosition.Y;

                LeftFloatPosition.X   = BoundingBox.Left;
                LeftFloatPosition.Y  += box.Height;
                RightFloatPosition.Y += box.Height;
            }
            else if (childFloatAttribute == Float.Left)
            {
                box.X = LeftFloatPosition.X;
                box.Y = LeftFloatPosition.Y;

                LeftFloatPosition.X += box.Width;

                if (LeftFloatPosition.X + box.Width > BoundingBox.Width)
                {
                    LeftFloatPosition.X  = BoundingBox.Left;
                    LeftFloatPosition.Y += box.Height;
                }
            }
            else if (childFloatAttribute == Float.Right)
            {
                box.X = RightFloatPosition.X - box.Width;
                box.Y = RightFloatPosition.Y;

                RightFloatPosition.X -= box.Width;

                if (RightFloatPosition.X < BoundingBox.Left)
                {
                    RightFloatPosition.X  = BoundingBox.Width;
                    RightFloatPosition.Y += box.Height;
                }
            }

            element.BoundingBox = box;
        }
示例#2
0
        private void AddToFlowList(TElement element)
        {
            switch (element.GetFloat())
            {
            case Float.None:
                NormalFlowChildren.Add(element);
                break;

            case Float.Left:
            case Float.Right:
                FloatFlowChildren.Add(element);
                break;
            }

            //TODO! Take element's Position into consideration too.
        }