コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            _timer.Tick += (_, __) => OnTick();
            _timer.Interval = TimeSpan.FromMilliseconds(100);

            ContentRendered += (_, __) =>
            {
                BoardControl.InitialiseGrid(8, 8);
                BoardControl.AddRooms(SamplePuzzles.SamplePuzzle1.Rooms);
                BoardControl.AddInitialValues(SamplePuzzles.SamplePuzzle1.InitialValues);

                _cancellationTokenSource = new CancellationTokenSource();

                _puzzleSolver = new PuzzleSolver(
                    SamplePuzzles.SamplePuzzle1,
                    OnSolutionFound,
                    OnSearchStep,
                    SynchronizationContext.Current,
                    _cancellationTokenSource.Token);

                _puzzleSolver.SolvePuzzle();
            };

            Closed += (_, __) => _cancellationTokenSource?.Cancel();
        }
コード例 #2
0
 private void OnSolutionFound(IImmutableList<InternalRow> internalRows)
 {
     _searchSteps.Enqueue(null);
     _puzzleSolver = null;
     _cancellationTokenSource = null;
 }