Esempio n. 1
0
        protected override Measurement MeasureOverride(Size availableSize)
        {
            //var doc = Document ?? throw new LayoutException("Document was not set");

            var ms = new Measurement(this);

            lineNodes = new List <LineNode>();
            foreach (var leaf in Leaves)
            {
                leaf.Measure(availableSize);
                var nodes = leaf.GetNodes();
                if (nodes.Length > 0)
                {
                    lineNodes.AddRange(nodes);
                }
            }
            LineNodeTransformer.Clean(lineNodes);
            if (lineNodes.Count > 0)
            {
                var indent = Style.Get(StyleKeys.ParagraphIndent);

                if (indent.Value > 0)
                {
                    lineNodes.Insert(0, LineNode.Box(indent.Point, string.Empty));
                }

                var linebreak       = new Linebreak();
                var breaks          = linebreak.BreakLines(lineNodes, new double[] { availableSize.Width }, new LinebreakOptions());
                var positionedItems = linebreak.PositionItems(lineNodes, new double[] { availableSize.Width }, breaks, false);
                lines = ProduceLines(positionedItems);
                double totalHeight = 0;

                for (int i = 0; i < lines.Length; i++)
                {
                    var line        = lines[i];
                    var height      = 0.0;
                    var lastElement = line[^ 1];
Esempio n. 2
0
        protected override Measurements MeasureOverride(Size availableSize)
        {
            var doc = Document ?? throw new LayoutException("Document was not set");

            var ms = new Measurements();

            lineNodes = new List <LineNode>();
            foreach (var leaf in Leaves)
            {
                leaf.Measure(availableSize);
                var nodes = leaf.GetNodes();
                if (nodes.Length > 0)
                {
                    lineNodes.AddRange(nodes);
                }
            }
            for (int i = 0; i < lineNodes.Count - 1; i++)
            {
                if (lineNodes[i].Type == LineNodeType.Glue && lineNodes[i + 1].Type == LineNodeType.Glue)
                {
                    lineNodes.RemoveAt(i);
                }
            }
            if (lineNodes.Count > 0)
            {
                var linebreak       = new Linebreak();
                var breaks          = linebreak.BreakLines(lineNodes, new double[] { availableSize.Width }, new LinebreakOptions());
                var positionedItems = linebreak.PositionItems(lineNodes, new double[] { availableSize.Width }, breaks, false);
                lines = ProduceLines(positionedItems);

                for (int i = 0; i < lines.Length; i++)
                {
                    var last        = i == lines.Length - 1;
                    var line        = lines[i];
                    var height      = 0.0;
                    var lastElement = line[^ 1];