コード例 #1
0
        public int GetByteSpaceCount()
        {
            ITextItem previtem = item;
            int       count    = 0;

            if (previtem is ITextTrim)
            {
                string leftpart = LeftPart;
                int    enterid  = leftpart.LastIndexOf('\n');
                if (enterid >= 0)
                {
                    for (int i = enterid + 1; i < leftpart.Length; i++)
                    {
                        count += TextChar.GetByteSpaceCount(leftpart[i]);
                    }
                    return(count);
                }
            }
            foreach (char ch in LeftPart)
            {
                count += TextChar.GetByteSpaceCount(ch);
            }
            while (previtem?.Parent != null)
            {
                ITextZone zone = previtem.Parent;
                if (GetByteSpaceCount(zone, previtem.ID - 1, ref count))
                {
                    return(count);
                }
                previtem = previtem.Parent;
            }
            return(count);
        }
コード例 #2
0
 public static bool GetByteSpaceCount(ITextZone zone, int start, ref int count)
 {
     for (int i = start; i >= 0; i--)
     {
         if (zone.Items[i] is ITextTrim)
         {
             ITextTrim trim    = (ITextTrim)(zone.Items[i]);
             int       enterid = trim.ToString().LastIndexOf('\n');
             if (enterid >= 0)
             {
                 string text = trim.ToString().Substring(enterid + 1);
                 foreach (char ch in text)
                 {
                     count += TextChar.GetByteSpaceCount(ch);
                 }
                 return(true);
             }
         }
         if (zone.Items[i] is ITextZone)
         {
             ITextZone _zone = (ITextZone)(zone.Items[i]);
             if (GetByteSpaceCount(_zone, 0, ref count))
             {
                 return(true);
             }
             continue;
         }
         foreach (char ch in zone.Items[i].ToString())
         {
             count += TextChar.GetByteSpaceCount(ch);
         }
     }
     return(false);
 }