Exemplo n.º 1
0
 protected virtual void ReplaceTextBlock(
     ITextBlock targetBlock,
     int startCharPosition,
     int endCharPosition,
     string text)
 {
     if (string.IsNullOrEmpty(text) && startCharPosition == 0 && endCharPosition == targetBlock.Length)
     {
         this.Children.Remove(targetBlock as RadElement);
     }
     else
     {
         string str   = targetBlock.Text.Substring(0, startCharPosition);
         string text1 = targetBlock.Text.Substring(endCharPosition);
         targetBlock.Text = str;
         if (TextBoxWrapPanel.IsSpecialText(text))
         {
             int num = this.InsertTextBlocks(string.IsNullOrEmpty(str) ? targetBlock.Index : targetBlock.Index + 1, text, TextBoxWrapPanel.TextBlockElementType);
             if (string.IsNullOrEmpty(str))
             {
                 targetBlock.Index = num + 1;
             }
             if (!string.IsNullOrEmpty(str) && !string.IsNullOrEmpty(text1))
             {
                 this.InsertTextBlocks(num + 1, text1, TextBoxWrapPanel.TextBlockElementType);
                 return;
             }
         }
         else
         {
             targetBlock.Text += text;
         }
         targetBlock.Text += text1;
     }
 }
Exemplo n.º 2
0
 protected virtual void ReplaceTextRange(
     ITextBlock targetBlock,
     int startCharPosition,
     int endCharPosition,
     string text)
 {
     if (startCharPosition == endCharPosition && string.IsNullOrEmpty(text))
     {
         return;
     }
     if (targetBlock == null)
     {
         this.InsertTextBlocks(0, text, TextBoxWrapPanel.TextBlockElementType);
     }
     else
     {
         bool flag  = string.IsNullOrEmpty(targetBlock.Text) || TextBoxWrapPanel.IsSpecialText(targetBlock.Text);
         int  index = targetBlock.Index;
         if (flag)
         {
             this.ReplaceSpecialTextBlock(targetBlock, startCharPosition, endCharPosition, text);
         }
         else
         {
             this.ReplaceTextBlock(targetBlock, startCharPosition, endCharPosition, text);
         }
         if (!string.IsNullOrEmpty(targetBlock.Text) || !this.Children.Contains(targetBlock as RadElement))
         {
             return;
         }
         this.Children.Remove(targetBlock as RadElement);
     }
 }