.
In Depth Banner
Skip Navigation Links

Select your preferred language

The WordPos class

  /// <summary>

  /// WordPos is a description for a word and  position.

  /// </summary>

  /// <remarks>

  /// The WordPos object maintains data about the linear position within the margins of a page,

  /// the physical width of a word, the font and its whitespace characteristics.

  /// </remarks>

  public class WordPos  : ICloneable

  {

    public float PagePos;

    public string Word;

    public float WordWidth;

    public WhiteSpace WhiteSpace;

    public Font Font;

 

    /// <summary>

    /// Constructor

    /// </summary>

    public WordPos()

    {

    }

 

    /// <summary>

    /// Constructor for a whitespace word position

    /// </summary>

    /// <param name="ws">The WhiteSpace type to use</param>

    public WordPos(WhiteSpace ws)

    {

      WhiteSpace = ws;

      PagePos=0;

      Word = "";

      WordWidth = 0;

    }

 

    /// <summary>

    /// Constructor

    /// </summary>

    /// <param name="ws">The WhiteSpace type</param>

    /// <param name="pp">Page position</param>

    /// <param name="word">The string definition of the word</param>

    /// <param name="ww">Word Width</param>

    /// <param name="font">the Font used to draw the word</param>

    protected WordPos(WhiteSpace ws, float pp, string word, float ww, Font font)

    {

      WhiteSpace = ws;

      PagePos=pp;

      Word = word;

      WordWidth = ww;

      Font=font;

    }

    

    /// <summary>

    /// Creates a string definition of this object for diagnostic purposes

    /// </summary>

    /// <returns>a string describing the contents of the WordPos object</returns>

    public override string ToString()

    {

      return string.Format("WordPos:\r\n"+

        "\tPagePos = {0}\r\n"+

        "\tWord = {1}\r\n"+

        "\tWordWidth = {2}\r\n"+

        "\tWhiteSpace = {3}\r\n",

        PagePos,

        Word,

        WordWidth,

        WhiteSpace);

    }

 

    /// <summary>

    /// Creates a copy of the object

    /// </summary>

    /// <returns>a copy of the current object</returns>

    object ICloneable.Clone()

    {

      return this.Clone();

    }

 

    /// <summary>

    /// returns a copy of the object

    /// </summary>

    /// <returns>An exact copy of the object</returns>

    public WordPos Clone()

    {

      return new WordPos(WhiteSpace, 

        PagePos,

        Word,    

        WordWidth, 

        Font); 

    }

 

  }

 

Return to the article

Copyright © Bob Powell 2000-.  All rights reserved.