Beispiel #1
0
        private static void FoldLineAt(TextLine line, int runIndex, int runCharIndex, TextBoxContext context, Stack <int> lineRunsIndex, Stack <int> lineRunsCharIndex)
        {
            TextRun textRun = line.LogicalRuns[runIndex];

            for (int num = line.LogicalRuns.Count - 1; num > runIndex; num--)
            {
                context.TextRunIndex          = lineRunsIndex.Pop();
                context.TextRunCharacterIndex = lineRunsCharIndex.Pop();
                line.LogicalRuns.RemoveAt(num);
            }
            string text = textRun.Text;

            if (runCharIndex < text.Length)
            {
                context.TextRunCharacterIndex -= text.Length - runCharIndex;
                if (textRun.Clone)
                {
                    textRun.TerminateAt(runCharIndex);
                }
                else
                {
                    SCRIPT_LOGATTR[] array = new SCRIPT_LOGATTR[runCharIndex];
                    Array.Copy(textRun.ScriptLogAttr, 0, array, 0, array.Length);
                    string  text2    = text.Substring(0, runCharIndex);
                    TextRun textRun2 = textRun.Split(text2, array);
                    textRun2.Clone             = true;
                    line.LogicalRuns[runIndex] = textRun2;
                }
            }
        }
 public TextRun GetSubRunForLine(TextBoxContext context, ref bool newLine)
 {
     this.AdvanceToNextRun(context);
     if (context.TextRunIndex < this.m_runs.Count)
     {
         TextRun textRun = this.m_runs[context.TextRunIndex];
         string  text    = null;
         bool    flag    = false;
         if (context.TextRunCharacterIndex == 0)
         {
             text = (textRun.Text ?? "");
         }
         else
         {
             flag = true;
             text = textRun.Text.Substring(context.TextRunCharacterIndex);
         }
         int num = text.IndexOf('\n');
         if (num != -1)
         {
             if (num + 1 < text.Length)
             {
                 text = text.Substring(0, num + 1);
                 flag = true;
             }
             newLine = true;
         }
         if (flag)
         {
             SCRIPT_LOGATTR[] array = new SCRIPT_LOGATTR[text.Length];
             Array.Copy(textRun.ScriptLogAttr, context.TextRunCharacterIndex, array, 0, array.Length);
             TextRun textRun2 = textRun.Split(text, array);
             textRun2.CharacterIndexInOriginal += context.TextRunCharacterIndex;
             textRun2.Clone = true;
             context.TextRunCharacterIndex += text.Length;
             return(textRun2);
         }
         context.TextRunCharacterIndex += text.Length;
         return(textRun);
     }
     return(null);
 }