Пример #1
0
        public void BatchFormat(FormattingInstructionCollection instructions)
        {
            BeginUpdate();

            CharacterRange _oldRange = SelectionRange;

            Format _oldFormat = null;

            if (_oldRange.Length == 0)
            {
                _oldFormat = GetSelectionFormat();
            }

            foreach (FormattingInstruction _instruction in instructions)
            {
                SetFormat(_instruction);
            }

            SelectionRange = _oldRange;

            if (_oldRange.Length == 0)
            {
                SetSelectionFormat(_oldFormat);
            }

            EndUpdate();
        }
 /// <summary>
 ///		Creates a synchronized (thread-safe) wrapper for a
 ///     <c>FormattingInstructionCollection</c> instance.
 /// </summary>
 /// <returns>
 ///     An <c>FormattingInstructionCollection</c> wrapper that is synchronized (thread-safe).
 /// </returns>
 public static FormattingInstructionCollection Synchronized(FormattingInstructionCollection list)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(new SyncFormattingInstructionCollection(list));
 }
 /// <summary>
 ///		Creates a read-only wrapper for a
 ///     <c>FormattingInstructionCollection</c> instance.
 /// </summary>
 /// <returns>
 ///     An <c>FormattingInstructionCollection</c> wrapper that is read-only.
 /// </returns>
 public static FormattingInstructionCollection ReadOnly(FormattingInstructionCollection list)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(new ReadOnlyFormattingInstructionCollection(list));
 }
        /// <summary>
        ///		Creates a shallow copy of the <see cref="FormattingInstructionCollection"/>.
        /// </summary>
        public virtual object Clone()
        {
            FormattingInstructionCollection newColl = new FormattingInstructionCollection(m_count);

            Array.Copy(m_array, 0, newColl.m_array, 0, m_count);
            newColl.m_count   = m_count;
            newColl.m_version = m_version;

            return(newColl);
        }
        /// <summary>
        ///		Adds the elements of another <c>FormattingInstructionCollection</c> to the current <c>FormattingInstructionCollection</c>.
        /// </summary>
        /// <param name="x">The <c>FormattingInstructionCollection</c> whose elements should be added to the end of the current <c>FormattingInstructionCollection</c>.</param>
        /// <returns>The new <see cref="FormattingInstructionCollection.Count"/> of the <c>FormattingInstructionCollection</c>.</returns>
        public virtual int AddRange(FormattingInstructionCollection x)
        {
            if (m_count + x.Count >= m_array.Length)
            {
                EnsureCapacity(m_count + x.Count);
            }

            Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
            m_count += x.Count;
            m_version++;

            return(m_count);
        }
            public override int AddRange(FormattingInstructionCollection x)
            {
                int result = 0;

                rwLock.AcquireWriterLock(timeout);

                try
                {
                    result = collection.AddRange(x);
                }
                finally
                {
                    rwLock.ReleaseWriterLock();
                }

                return(result);
            }
 internal SyncFormattingInstructionCollection(FormattingInstructionCollection list) : base(Tag.Default)
 {
     rwLock     = new ReaderWriterLock();
     collection = list;
 }
 /// <summary>
 ///		Initializes a new instance of the <c>Enumerator</c> class.
 /// </summary>
 /// <param name="tc"></param>
 internal Enumerator(FormattingInstructionCollection tc)
 {
     m_collection = tc;
     m_index      = -1;
     m_version    = tc.m_version;
 }
 /// <summary>
 ///		Initializes a new instance of the <c>FormattingInstructionCollection</c> class
 ///		that contains elements copied from the specified <c>FormattingInstructionCollection</c>.
 /// </summary>
 /// <param name="c">The <c>FormattingInstructionCollection</c> whose elements are copied to the new collection.</param>
 public FormattingInstructionCollection(FormattingInstructionCollection c)
 {
     m_array = new FormattingInstruction[c.Count];
     AddRange(c);
 }
 public override int AddRange(FormattingInstructionCollection x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
 internal ReadOnlyFormattingInstructionCollection(FormattingInstructionCollection list) : base(Tag.Default)
 {
     m_collection = list;
 }