Beispiel #1
0
        /// <summary>
        /// Replace the string at the specified index with the specified string.
        /// </summary>
        /// <param name="index">Index of string to replace.</param>
        /// <param name="s">The replacement string.</param>
        public void ChangeString(int index, string s)
        {
            int la        = get_LengthAt(index) * 2;
            int newlength = s.Length * 2;

            if (newlength == la)
            {
                return;
            }
            long b   = _index[index].ToInt64() - SafePtr.handle.ToInt64();
            long dif = newlength - la;

            if (!_lpwstr)
            {
                Native.byteArrAtset(IntPtr.Add(SafePtr.handle, (int)b), BitConverter.GetBytes((long)s.Length), (uint)SizeDescriptorLength);
                b += SizeDescriptorLength;
            }

            if (dif > 0L)
            {
                _mem.PushOut(b, dif);
            }
            else
            {
                _mem.PullIn(b, -dif);
            }

            QuickCopyObject <string>(IntPtr.Add(SafePtr.handle, (int)b), s, (uint)newlength);
            Refresh();
        }