Exemplo n.º 1
0
        private void Analyze(string text)
        {
            _timer.Start();
            _start = DateTime.Now;
            var resultsArray = _analyzer.AnalyzeText(text);

            _lists = _analyzer.CreateWordsCombinations();

            Dispatcher.Invoke(() =>
            {
                RtbResult.Document.Blocks.Clear();
            });
            _timer.Stop();


            for (var i = 0; i < _analyzer.InputWithWhiteMarks.Count(); ++i)
            {
                var i1 = i;
                Dispatcher.Invoke(() =>
                {
                    switch (_lists[i1].Item1.Count())
                    {
                    case int n when n > 1 && !_lists[i1].Item2:
                        RtbResult.AppendTextColors(resultsArray[i1], new SolidColorBrush(Colors.Firebrick), new SolidColorBrush(Colors.White));
                        break;

                    case 1 when _analyzer.InputWithWhiteMarks[i1] != resultsArray[i1]:
                        RtbResult.AppendTextColors(resultsArray[i1], new SolidColorBrush(Colors.LimeGreen), new SolidColorBrush(Colors.Black));
                        break;

                    case 1 when _analyzer.InputWithWhiteMarks[i1] == resultsArray[i1]:
                        RtbResult.AppendTextColors(resultsArray[i1], new SolidColorBrush(Colors.Transparent), (SolidColorBrush)(FindResource("MyAzure")));
                        break;

                    case int n when n > 1 && _analyzer.InputWithWhiteMarks[i1] != resultsArray[i1]:
                        RtbResult.AppendTextColors(resultsArray[i1], new SolidColorBrush(Colors.GreenYellow), new SolidColorBrush(Colors.Black));
                        break;

                    case int n when n > 1 && _analyzer.InputWithWhiteMarks[i1] == resultsArray[i1]:
                        RtbResult.AppendTextColors(resultsArray[i1], new SolidColorBrush(Colors.Gold), new SolidColorBrush(Colors.Black));
                        break;
                    }
                });
            }
            Dispatcher.Invoke(() =>
            {
                LoadingBar.Visibility = Visibility.Hidden;
                BtnStart.IsEnabled    = true;
                BtnSave.IsEnabled     = true;
                BtnLoad.IsEnabled     = true;
            });
        }