/// <summary>
        /// get a square on the board gioven the widht and height
        /// </summary>
        /// <param name="width">horizontal position of the square on the board</param>
        /// <param name="height">vertical position of the square on the board</param>
        /// <returns></returns>
        public BasicSquare GetSquareAt(int width, int height)
        {
            foreach (DictionaryEntry dicEnt in hashSquares)
            {
                BasicSquare square = ( BasicSquare )dicEnt.Value;

                if (this.ShowLegend == false)
                {
                    if (square.SquareHorizontalLocation <= width &&
                        (square.SquareHorizontalLocation + square.SquareWidth) >= width &&
                        square.SquareVerticalLocation <= height &&
                        (square.SquareVerticalLocation + square.SquareHeight) >= height)
                    {
                        return(square);
                    }
                }
                else
                {
                    if ((square.SquareHorizontalLocation + this.LegendWidth) <= width &&
                        (square.SquareHorizontalLocation + LegendWidth + square.SquareWidth) >= width &&
                        (square.SquareVerticalLocation + LegendWidth) <= height &&
                        (square.SquareVerticalLocation + LegendWidth + square.SquareHeight) >= height)
                    {
                        return(square);
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// invalidate a given square
        /// </summary>
        /// <param name="strIdentifier">hash table identifier for the string</param>
        public void InvalidateSquare(string identifier)
        {
            BasicSquare square = ( BasicSquare )hashSquares[identifier];

            if (square == null)
            {
                return;
            }

            if (ShowLegend == false)
            {
                Invalidate(new Rectangle(square.SquareHorizontalLocation, square.SquareVerticalLocation, square.SquareWidth, square.SquareHeight));
            }
            else
            {
                Invalidate(new Rectangle(square.SquareHorizontalLocation + LegendWidth, square.SquareVerticalLocation + LegendWidth, square.SquareWidth, square.SquareHeight));
            }

            square.IsValid = false;
        }
        private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Graphics grfx = e.Graphics;

            if (mode == SQUAREMODES.DISPLAYONLY)
            {
                /// this code just gives something to look at when the control is dropped onto a
                /// form the control should be set up programmatically by the container program
                /// which will then select modes etc to use.
                Clear();

                /// create some squares

                hashSquares.Add("AA", new ControlDisplaySquare(100, 100, 0, 0, "AA"));
                hashSquares.Add("AB", new ControlDisplaySquare(100, 100, 0, 100, "AB"));
                hashSquares.Add("AC", new ControlDisplaySquare(100, 100, 0, 200, "AC"));
                hashSquares.Add("BA", new ControlDisplaySquare(100, 100, 100, 0, "BA"));
                hashSquares.Add("BB", new ControlDisplaySquare(100, 100, 100, 100, "BB"));
                hashSquares.Add("BC", new ControlDisplaySquare(100, 100, 100, 200, "BC"));
                hashSquares.Add("CA", new ControlDisplaySquare(100, 100, 200, 0, "CA"));
                hashSquares.Add("CB", new ControlDisplaySquare(100, 100, 200, 100, "CB"));
                hashSquares.Add("CC", new ControlDisplaySquare(100, 100, 200, 200, "CC"));

                (( BasicSquare )hashSquares["AA"]).DrawLegend        = true;
                (( BasicSquare )hashSquares["AC"]).IsBottomSquare    = true;
                (( BasicSquare )hashSquares["BC"]).IsBottomSquare    = true;
                (( BasicSquare )hashSquares["CA"]).IsRightEdgeSquare = true;
                (( BasicSquare )hashSquares["CB"]).IsRightEdgeSquare = true;
                (( BasicSquare )hashSquares["CC"]).IsRightEdgeSquare = true;
                (( BasicSquare )hashSquares["CC"]).IsBottomSquare    = true;

                foreach (DictionaryEntry dicEnt in hashSquares)
                {
                    BasicSquare square = ( BasicSquare )dicEnt.Value;

                    square.DrawSquare(e.Graphics);
                }
            }
            else             /// draw the board
            {
                /// assume that the calls to paint are only made when necassary so draw all squares
                /// this avoids having to call in from the container ( hopefully )

                if (e.ClipRectangle.Width >= BoardWidth)
                {
                    foreach (DictionaryEntry dicEnt in hashSquares)
                    {
                        BasicSquare square = ( BasicSquare )dicEnt.Value;

                        square.IsValid = false;
                    }
                }
                else
                {
                    /// if not drawing the complet board work out which squares need drawing
                    /// NOTE maths is slightly out if using the legend ( but not enough to make much difference )
                    foreach (DictionaryEntry dicEnt in hashSquares)
                    {
                        BasicSquare square = ( BasicSquare )dicEnt.Value;

                        if (e.ClipRectangle.Width >= square.SquareHorizontalLocation ||
                            e.ClipRectangle.Height >= square.SquareVerticalLocation)
                        {
                            square.IsValid = false;
                        }
                    }
                }
            }
        }