示例#1
0
        private bool CanConnectedColorReachCellInColumn(int rowIdx, int colIdx, ColorClassifier colCc)
        {
            var array      = WorkingGrid.GetColumn(colIdx);
            var firstIndex = IndexOf(array, colCc.MyColor);
            var lastIndex  = LastIndexOf(array, colCc.MyColor);

            if (firstIndex <= OutOfBoundsConst)
            {
                return(true);
            }
            if (firstIndex > rowIdx)
            {
                var minIdx = lastIndex - colCc.Count + 1; //3
                if (rowIdx < minIdx)
                {
                    return(false);
                }
            }
            else if (lastIndex < rowIdx)
            {
                var maxIdx = firstIndex + colCc.Count - 1; //5
                if (rowIdx > maxIdx)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        private int CountNumberOfElementsBeforeAndAfterInColumn(int startingRowIdx, int colIdx, Color colorToFind)
        {
            var array = WorkingGrid.GetColumn(colIdx);
            var count = 0;
            var i     = startingRowIdx - 1;

            while (i >= 0 && array[i].Equals(colorToFind))
            {
                count++;
                i--;
            }
            i = startingRowIdx + 1;
            while (i < RowCount && array[i].Equals(colorToFind))
            {
                count++;
                i++;
            }
            return(count);
        }
示例#3
0
 private void SetupSelectionAndFields(Selection selection)
 {
     _selection = selection;
     if (_selection == Selection.Row)
     {
         _items          = Rows;
         _oppositeItems  = Columns;
         _selectionCount = ColCount;
         _getArray       = (rowNumber => WorkingGrid.GetRow(rowNumber));
         _getCell        = ((x, y) => WorkingGrid[x, y]);
     }
     else
     {
         _items          = Columns;
         _oppositeItems  = Rows;
         _selectionCount = RowCount;
         _getArray       = (colNumber => WorkingGrid.GetColumn(colNumber));
         _getCell        = ((x, y) => WorkingGrid[y, x]);
     }
 }