public AndroidUserCell(Context context, UserCell cell) : base(context) { UserCell = cell; var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.AndroidUserCell, null); HeadingTextView = view.FindViewById <TextView>(Resource.Id.Username); SubheadingTextView = view.FindViewById <TextView>(Resource.Id.UserId); AddView(view); }
public void ValidCell() { string puzzleString = "540070009000901000009460000050040020200000040910600785030590200000180006605200000"; SudokuPuzzle puzzle = new SudokuPuzzle(puzzleString); Cell cell = new UserCell(2) { Value = 6 }; bool res = m_Validator.ValidateCell(puzzle, cell); Assert.IsTrue(res); }
protected override void OnCellPropertyChanged(object sender, PropertyChangedEventArgs args) { base.OnCellPropertyChanged(sender, args); if (args.PropertyName == "IsSelected") { _selected = !_selected; if (_selected) { UserCell extendedViewCell = sender as UserCell; _cellCore.SetBackgroundColor(extendedViewCell.SelectedItemBackgroundColor.ToAndroid()); } else { _cellCore.SetBackground(_unselectedBackground); } } }
private void ParseSudoku(string input) { char[] values = input.ToCharArray(); for (int i = 0; i < values.Length; i++) { int num = int.Parse(values[i].ToString()); Cell cell; if (num == 0) { cell = new UserCell(i); } else { cell = new FixedCell(i, num); } Cells.Add(cell); } }
//TODO: Solve from front and back to see if multiple solutions exist (throw exception) public ISudokuPuzzle Solve() { if (!m_Validator.ValidateSudoku(m_Puzzle)) { throw new InvalidPuzzleException(); } int i = 0; Cell[] userCells = m_Puzzle.Cells.Where(c => c is UserCell).ToArray(); while (i < userCells.Length) { if (i < 0) { throw new UnsolvablePuzzleException(); } UserCell cell = userCells[i] as UserCell; int val = cell.Value + 1; if (val > 9) { cell.Value = 0; i--; continue; } cell.Value = val; if (m_Validator.ValidateCell(m_Puzzle, cell)) { i++; } } return(m_Puzzle); }