.
In Depth Banner
Skip Navigation Links

Select your preferred language

The WordPosCollection class.

  /// <summary>

  /// A specialized collection class that manages WordPos objects

  /// </summary>

  public class WordPosCollection : CollectionBase

  {

    bool _containsNewline=false;

    bool _newParagraph=false;

 

    /// <summary>

    ///

    /// </summary>

    public bool NewParagraph

    {

      get{return _newParagraph;}

      set{_newParagraph=value;}

    }

 

    /// <summary>

    /// Readonly property. when true, the formatted text contains a newline whitespace character

    /// </summary>

    public  bool ContainsNewline

    {

      get{return _containsNewline;}

    }

 

    /// <summary>

    /// Strongly typed method to add WordPos objects to the cllection.

    /// </summary>

    /// <param name="wp">The WordPos object to add</param>

    public void Add(WordPos wp)

    {

      if(wp.WhiteSpace==WhiteSpace.NewLine)

        _containsNewline=true;

      List.Add(wp);

    }

 

    /// <summary>

    /// Indexer that gets and sets WordPos objecs at a specified index within the collection

    /// </summary>

    public WordPos this[int index]

    {

      get{return (WordPos)List[index];}

      set

      {

        if(value.WhiteSpace==WhiteSpace.NewLine)

          this._containsNewline=true;

        List[index]=value;

      }

    }

 

    /// <summary>

    /// Removes the last WordPos object from the collection.

    /// </summary>

    public void RemoveLast()

    {

      List.RemoveAt(List.Count-1);

    }

 

    /// <summary>

    /// Returns the last WordPos object in the collection.

    /// </summary>

    /// <returns>The last WordPos object in the collection</returns>

    public WordPos Last()

    {

      if(List.Count==0)

        return null;

      return (WordPos)List[List.Count-1];

    }

  }

 

 

Return to the article.

Copyright © Bob Powell 2000-.  All rights reserved.