Ejemplo n.º 1
0
 public static ICharIterator Rent(
     ICharIterator source, bool leaveSourceOpen,
     TransformCharIterator.Transform transform, bool leaveTransformOpen)
 {
     lock (_transformIterators)
     {
         if (_transformIterators.TryTake(out var iterator))
         {
             iterator.Set(source, leaveSourceOpen, transform, leaveTransformOpen);
             return(iterator);
         }
     }
     return(new TransformCharIterator(source, leaveSourceOpen, transform, leaveTransformOpen));
 }
        public void Remove(int index, int count)
        {
            if (index > CurrentText.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var transform = new TransformCharIterator.Transform(offsetInSource: index, count);

            // leave source open as we dispose CurrentText in SetText()
            using (var iter = IteratorPool.Rent(
                       CurrentText, leaveSourceOpen: true, transform, leaveTransformOpen: false))
            {
                SetText(_font, iter, _usedColorFormat);
            }
        }
Ejemplo n.º 3
0
        public void Insert(int index, ICharIterator chars, int offset, int count, bool useColorFormat)
        {
            if (index > CurrentText.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var transform = new TransformCharIterator.Transform(offsetInSource: index, chars, offset, count);

            // leave source open as we dispose CurrentText in SetText()
            using (var iter = IteratorPool.Rent(
                       CurrentText, leaveSourceOpen: true, transform, leaveTransformOpen: true))
            {
                SetText(_font, iter, useColorFormat);
            }

            BuildSprites(measure: false);
        }