Example #1
0
 public StringBuffer(ITcTextStyle style, string filename)
 {
     fname  = filename;
     buffer = File.ReadAllText(filename, defaultEncoder);
     lindex = LineRegion.GetCount(buffer);
     tstyle = style;
 }
Example #2
0
        /// <summary>
        /// Counts the number of lines a single line is broken into when
        /// word-wrapping is enabled
        /// </summary>
        /// <returns>
        /// the total number of measured lines or 1 if there isn't text.
        /// </returns>
        public int[] Measure(ITcTextStyle style)
        {
            List <int> lin = new List <int>();

            string[] tstr = GetStrings();
            if (tstr == null)
            {
                goto fin;
            }
            if (tstr.Length == 0)
            {
                goto fin;
            }
            // calculate line heights (handle stopping this is the line
            // boundary gets to be too much)
            foreach (string srr in tstr)
            {
                lin.Add(Measure(style, srr));
            }
fin:
            if (lin.Count == 0)
            {
                return new int[] { 1 }
            }
            ;
            return(lin.ToArray());
        }
Example #3
0
        /// <summary>
        /// Counts the number of lines a single line is broken into when
        /// word-wrapping is enabled
        /// </summary>
        public int Measure(ITcTextStyle style, string str)
        {
            int c, d;

            style.m_gfx.MeasureString(
                str, style.Font, style.o_rect.Size, style.StrFmt,
                out c, out d);
            return(d);
        }
Example #4
0
        /// <summary>
        /// Calculates the number of lines when WordWrapping is enabled.
        /// If WWrap isn't enabled, calculates the same but to 1 line given
        /// that it's never sent more then a line.
        /// </summary>

        public int GetMeasure(IStringBuffer buffer, ITcTextStyle tstyle, RectangleF R)
        {
            Graphics G = Graphics.FromImage(new Bitmap(640, 480));

            G.PageUnit = tstyle.DrawingUnits;

            Trace.WriteLine(tstyle.DrawingUnits.ToString());
            Trace.WriteLine(tstyle.Font.ToString());
            Trace.WriteLine(tstyle.Font.Unit.ToString());

            List <Region>         m_reg = new List <Region>();
            List <CharacterRange> cra   = new List <CharacterRange>();
            int    i   = 0;
            string tst = buffer.Text.Substring(Start, Length);

            foreach (char X in tst)
            {
                cra.Add(new CharacterRange(i, 1));
                Trace.WriteLine(cra[cra.Count - 1].ToString());
                i++;
            }
            StringFormat fmt = (StringFormat)tstyle.StrFmt.Clone();

            if (cra.Count == 0)
            {
                return(-1);
            }
            fmt.SetMeasurableCharacterRanges(cra.ToArray());
            Region[] rexx = tstyle.m_gfx.MeasureCharacterRanges(
                tst, tstyle.Font, R, fmt
                );
            Trace.WriteLine(tst);
            foreach (Region reg in rexx)
            {
                Trace.WriteLine("?:   " + reg.GetBounds(G).Size.ToString());
            }

            return(-1);
        }
Example #5
0
 /// <summary>
 /// Counts the number of lines a single line is broken into when
 /// word-wrapping is enabled
 /// </summary>
 public int Measure(ITcTextStyle style, string[] str, int i)
 {
     return(Measure(style, str[i]));
 }