Пример #1
0
        /// <summary>
        /// Get the large alphabet string for the specified word.
        /// </summary>
        /// <param name="word">The word.</param>
        /// <returns>The word as a multiline alphabet string.</returns>
        public string GetAlphabetString(string word)
        {
            StringBuilder returnValue = new StringBuilder();

            //int letterSize = 5 + 2;         //5 is the letter size; 2 is the space between letters
            StringBuilder[] rows = new StringBuilder[5];
            for (int letterCount = 0; letterCount < word.Length; letterCount++)
            {
                char letter = word[letterCount];

                bool[,] printArray = new bool[5, 5];
                if (CustomChars.ContainsKey(letter.ToString()))
                {
                    printArray = CustomChars[letter.ToString()];
                }
                else
                {
                    switch (letter.ToString().ToUpper())
                    {
                    case "A":
                        printArray = A;
                        break;

                    case "B":
                        printArray = B;
                        break;

                    case "C":
                        printArray = C;
                        break;

                    case "D":
                        printArray = D;
                        break;

                    case "E":
                        printArray = E;
                        break;

                    case "F":
                        printArray = F;
                        break;

                    case "G":
                        printArray = G;
                        break;

                    case "H":
                        printArray = H;
                        break;

                    case "I":
                        printArray = I;
                        break;

                    case "J":
                        printArray = J;
                        break;

                    case "K":
                        printArray = K;
                        break;

                    case "L":
                        printArray = L;
                        break;

                    case "M":
                        printArray = M;
                        break;

                    case "N":
                        printArray = N;
                        break;

                    case "O":
                        printArray = O;
                        break;

                    case "P":
                        printArray = P;
                        break;

                    case "Q":
                        printArray = Q;
                        break;

                    case "R":
                        printArray = R;
                        break;

                    case "S":
                        printArray = S;
                        break;

                    case "T":
                        printArray = T;
                        break;

                    case "U":
                        printArray = U;
                        break;

                    case "V":
                        printArray = V;
                        break;

                    case "W":
                        printArray = W;
                        break;

                    case "X":
                        printArray = X;
                        break;

                    case "Y":
                        printArray = Y;
                        break;

                    case "Z":
                        printArray = Z;
                        break;

                    case "0":
                        printArray = Zero;
                        break;

                    case "1":
                        printArray = One;
                        break;

                    case "2":
                        printArray = Two;
                        break;

                    case "3":
                        printArray = Three;
                        break;

                    case "4":
                        printArray = Four;
                        break;

                    case "5":
                        printArray = Five;
                        break;

                    case "6":
                        printArray = Six;
                        break;

                    case "7":
                        printArray = Seven;
                        break;

                    case "8":
                        printArray = Eight;
                        break;

                    case "9":
                        printArray = Nine;
                        break;

                    case "(":
                        printArray = LeftParentheses;
                        break;

                    case ")":
                        printArray = RightParentheses;
                        break;

                    case " ":
                        printArray = Space;
                        break;

                    case "-":
                        printArray = Hyphen;
                        break;

                    case "!":
                        printArray = ExclamationMark;
                        break;

                    case "#":
                        printArray = Pound;
                        break;

                    default:
                        throw new NotSupportedException("The specified word contains an unsupported character '" + letter.ToString().ToUpper() + "'.");
                    }
                }

                for (int row = 0; row < printArray.GetLength(0); row++)
                {
                    StringBuilder crow = rows[row] == null ? new StringBuilder() : rows[row];


                    for (int col = 0; col < printArray.GetLength(1); col++)
                    {
                        string output = " ";
                        if (printArray[row, col])
                        {
                            output = LetterChar.ToString();
                        }

                        crow.Append(output);
                    }
                    crow.Append("  ");
                    rows[row] = crow;
                    //rows.Add(crow);
                }
            }
            foreach (StringBuilder sb in rows)
            {
                returnValue.AppendLine(sb.ToString());
            }
            return(returnValue.ToString());
        }
Пример #2
0
 public void showBoardPiece(Graphics e)
 {
     e.FillRectangle(SolidBrush, Rectangle);
     e.DrawRectangle(Pen, Rectangle);
     e.DrawString(LetterChar.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), Rectangle);
 }