예제 #1
0
        public VisualSpanner(
            ScreenContent ScreenContent, ContinuedContentField ContContentField,
            CanvasDefn CanvasDefn)
            : base(ContContentField.RowCol)
        {
            this.SegmentList = new List <VisualTextBlockSegment>();
            var fieldNum = ContContentField.FieldNum;

            // create VisualTextBloc item for each segment of the continued field.
            int segBx = 0;

            foreach (var contField in ScreenContent.ContinuedFieldSegments(fieldNum))
            {
                var  segNum = contField.FieldKey.SegNum;
                bool attrByteOccupySpace = true;
                var  vtb = new VisualTextBlockSegment(
                    this, segNum, segBx,
                    contField.GetShowText(ScreenContent),
                    contField.RowCol as ZeroRowCol, contField.GetAttrByte(ScreenContent),
                    CanvasDefn, attrByteOccupySpace);
                vtb.SetupUnderline();
                this.SegmentList.Add(vtb);
                vtb.ContinuedFieldSegmentCode = contField.ContinuedFieldSegmentCode;
                segBx += contField.GetShowText(ScreenContent).Length;
            }

            this.AttrByte = ContContentField.GetAttrByte(ScreenContent);
        }
예제 #2
0
        private static void CreateTextBlockSegments(
            VisualSpanner Parent,
            string Text, IRowCol StartRowCol, byte?AttrByte,
            CanvasDefn CanvasDefn)
        {
            IRowCol rowCol = StartRowCol;
            string  text   = Text;
            int     segNum = 0;
            int     segBx  = 0;

            // advance past attrByte.
#if skip
            if (AttrByte != null)
            {
                rowCol = rowCol.Advance(1);
            }
#endif
            bool attrByteOccupySpace = true;

            // loop create textblock segments until no more text.
            while (text.Length > 0)
            {
                // space on this row.
                var remLx = rowCol.GetRowRemaining();
                if (attrByteOccupySpace == true)
                {
                    remLx -= 1;
                }

                // text to place on current row.
                int usedLx = 0;
                if (remLx > text.Length)
                {
                    usedLx = text.Length;
                }
                else
                {
                    usedLx = remLx;
                }

                // create the textblock segment.
                if (usedLx > 0)
                {
                    segNum += 1;
                    var vtb = new VisualTextBlockSegment(
                        Parent, segNum, segBx,
                        Text.Substring(segBx, usedLx), rowCol as ZeroRowCol, AttrByte,
                        CanvasDefn, attrByteOccupySpace);
                    vtb.SetupUnderline();
                    Parent.SegmentList.Add(vtb);

                    // advance to next segment in show text.
                    segBx += usedLx;
                    if (text.Length > usedLx)
                    {
                        text = text.Substring(usedLx);
                    }
                    else
                    {
                        text = "";
                    }
                }

                // advance rowCol
                if (attrByteOccupySpace == true)
                {
                    usedLx += 1;
                }
                rowCol = rowCol.Advance(usedLx);

                attrByteOccupySpace = false;
            }
        }