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 void TerminateAt(int index)
 {
     this.m_text = this.m_text.Remove(index, this.m_text.Length - index);
     SCRIPT_LOGATTR[] array = new SCRIPT_LOGATTR[index];
     Array.Copy(this.ScriptLogAttr, 0, array, 0, array.Length);
     this.ScriptLogAttr     = array;
     this.m_cachedGlyphData = null;
 }
 public TexRunShapeData(TextRun run, bool storeGlyph, int startIndex)
     : this(run, storeGlyph)
 {
     SCRIPT_LOGATTR[] scriptLogAttr = run.ScriptLogAttr;
     if (startIndex > 0 && scriptLogAttr != null)
     {
         int num  = scriptLogAttr.Length;
         int num2 = num - startIndex;
         SCRIPT_LOGATTR[] array = new SCRIPT_LOGATTR[num2];
         Array.Copy(scriptLogAttr, startIndex, array, 0, num2);
         this.m_scriptLogAttr = array;
     }
 }
 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);
 }
 private static void AnalyzeForBreakPositions(List <TextRun> itemRuns, string itemsText)
 {
     if (itemsText.Length != 0)
     {
         SCRIPT_ANALYSIS  sCRIPT_ANALYSIS = itemRuns[0].SCRIPT_ANALYSIS;
         SCRIPT_LOGATTR[] array           = new SCRIPT_LOGATTR[itemsText.Length];
         int num = Win32.ScriptBreak(itemsText, itemsText.Length, ref sCRIPT_ANALYSIS, array);
         if (Win32.Failed(num))
         {
             Marshal.ThrowExceptionForHR(num);
         }
         int num2 = 0;
         for (int i = 0; i < itemRuns.Count; i++)
         {
             TextRun          textRun = itemRuns[i];
             int              length  = textRun.Text.Length;
             SCRIPT_LOGATTR[] array2  = new SCRIPT_LOGATTR[length];
             Array.Copy(array, num2, array2, 0, length);
             textRun.ScriptLogAttr = array2;
             num2 += length;
         }
     }
 }