예제 #1
0
 private Boolean ValidateRowColumn(RowColumn rowColumn)
 {
     if (this.mRowColumn != null)
     {
         Regex regex = new Regex("[A-F]", RegexOptions.IgnoreCase);
         // Validate that the row is within the defined criteria
         if (!regex.IsMatch(this.mRowColumn.Row))
         {
             throw new ArgumentOutOfRangeException("Row", "Row value must be A - F.");
         }
         // Validate that the column is within the the defined criteria
         if (this.mRowColumn.Column < 1 || this.mRowColumn.Column > 12)
         {
             throw new ArgumentOutOfRangeException("Column", "Column value must be 1 - 12.");
         }
     }
     else
     {
         throw new ArgumentNullException("RowColumn", "RowColumn cannot be Null");
     }
     return(true);
 }
예제 #2
0
        private void DeterminePosition()
        {
            // Use the lowest y coordinate to determine the row
            int rowInt = Math.Min(V1y, Math.Min(V2y, V3y)) / 10;
            // Convert the row to its character equivalent
            string row = ((char)(rowInt + 65)).ToString();

            int maxX = Math.Max(V1x, Math.Max(V2x, V3x));
            int minX = Math.Min(V1x, Math.Min(V2x, V3x));

            // Get the most occurring x coordinate to determine if the verticle leg is on the left or right side
            int[] list          = new int[] { V1x, V2x, V3x };
            int   mostOccurring = list.GroupBy(x => x).OrderByDescending(x => x.Count()).First().Key;
            int   column        = mostOccurring / 10 * 2;

            // Vertical leg is on the right
            if (mostOccurring == minX)
            {
                column += 1;
            }

            mRowColumn = new RowColumn(row, column);
        }
예제 #3
0
 public Triangle(RowColumn mRowColumn)
 {
     this.mRowColumn = mRowColumn;
     CalculateCoordinates();
 }