public static Boolean TryParse(List <TitleSequence> originalWordDataList, Crozzle aCrozzle, out WordDataList aWordDataList) { List <WordData> aList = new List <WordData>(); Errors = new List <String>(); aWordDataList = new WordDataList(originalWordDataList); foreach (TitleSequence block in originalWordDataList) { WordData aWordData; if (WordData.TryParse(block, aCrozzle, out aWordData)) { aWordDataList.Add(aWordData); } else { Errors.AddRange(WordData.Errors); } } aWordDataList.Valid = Errors.Count == 0; return(aWordDataList.Valid); }
public void Insert(WordData wordData) { if (wordData.Location.Row >= 1 && wordData.Location.Row <= Rows && wordData.Location.Column >= 1 && wordData.Location.Column <= Columns) { if (wordData.Orientation.Direction == Orientation.Row) { // Store the letter into the approriate row. String[] row = GridRows[wordData.Location.Row - 1]; int col = wordData.Location.Column - 1; foreach (Char c in wordData.Letters) { if (col < Columns) { row[col++] = new String(c, 1); } } // Store each letter into the ith column, but the same row location. int j = wordData.Location.Column - 1; foreach (Char c in wordData.Letters) { if (j < Columns) { String[] column = GridColumns[j]; column[wordData.Location.Row - 1] = new String(c, 1); j++; } } HorizontalWordDataList.Add(wordData); } else { // Store the letter into the ith row, but the same column location. int j = wordData.Location.Row - 1; foreach (Char c in wordData.Letters) { if (j < Rows) { String[] currentRow = GridRows[j]; currentRow[wordData.Location.Column - 1] = new String(c, 1); j++; } } // Store each letter into the approriate column. String[] column = GridColumns[wordData.Location.Column - 1]; int row = wordData.Location.Row - 1; foreach (Char c in wordData.Letters) { if (row < Rows) { column[row++] = new String(c, 1); } } VerticalWordDataList.Add(wordData); } GridSequences = new CrozzleSequences(GridRows, GridColumns, Configuration); WordDataList.Add(wordData); } }