private void MenuItemEditRecomputeCandidates_Click(object sender, RoutedEventArgs e)
        {
            int[] z = new int[81];
            for (int cell = 0; cell < 81; cell++)
            {
                z[cell] = _puzzle[cell] + 1;
            }

            var grid = SudokuGrid.CreateInstance(z);

            if (new BitwiseSolver().Solve(grid.ToString(), null, 2) == 0)
            {
                Messagings.SukakuCannotUseThisFunction();

                e.Handled = true;
                return;
            }

            _puzzle = new UndoableGrid(grid);
            _puzzle.Unfix();
            _puzzle.ClearStack();

            UpdateImageGrid();
            UpdateUndoRedoControls();
        }
        private void MenuItemAnalyzeSolve_Click(object sender, RoutedEventArgs e)
        {
            if (!applyNormal() && !applySukaku())
            {
                Messagings.FailedToApplyPuzzle();
                e.Handled = true;
                return;
            }

            bool applySukaku()
            {
                var sb = new StringBuilder(SudokuGrid.EmptyString);

                if (new SukakuBitwiseSolver().Solve(
                        _puzzle.ToString($"~{(Settings.TextFormatPlaceholdersAreZero ? "0" : ".")}"), sb, 2) != 1)
                {
                    return(!(e.Handled = true));
                }

                Puzzle = new UndoableGrid(SudokuGrid.Parse(sb.ToString()));
                UpdateImageGrid();
                return(true);
            }

            bool applyNormal()
            {
                var sb = new StringBuilder(SudokuGrid.EmptyString);

                for (int cell = 0; cell < 81; cell++)
                {
                    sb[cell] += (char)(_puzzle[cell] + 1);
                }

                if (new BitwiseSolver().Solve(sb.ToString(), sb, 2) != 1)
                {
                    return(!(e.Handled = true));
                }

                Puzzle = new UndoableGrid(SudokuGrid.Parse(sb.ToString()));
                UpdateImageGrid();
                return(true);
            }
        }
        private void MenuItemEditPasteAsSukaku_Click(object sender, RoutedEventArgs e)
        {
            string puzzleStr = Clipboard.GetText();

            if (!(puzzleStr is null))
            {
                try
                {
                    Puzzle = new UndoableGrid(SudokuGrid.Parse(puzzleStr, GridParsingOption.Sukaku));

                    _menuItemEditUndo.IsEnabled = _menuItemEditRedo.IsEnabled = false;
                    UpdateImageGrid();
                }
                catch (ArgumentException)
                {
                    Messagings.FailedToPasteText();
                }

                _listBoxPaths.ClearValue(ItemsControl.ItemsSourceProperty);
                _listViewSummary.ClearValue(ItemsControl.ItemsSourceProperty);
                _listBoxTechniques.ClearValue(ItemsControl.ItemsSourceProperty);
            }
        }