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);
            }
        }
示例#2
0
        public void Dispose()
        {
            if (!_leaveSourceOpen)
            {
                _source?.Dispose();
            }
            _source = null;

            if (!_leaveTransformOpen)
            {
                _transform.InsertionData?.Dispose();
            }
            _transform = default;

            IteratorPool.Return(this);
        }
示例#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);
        }