private void Hack()
        {
            string text = textBoxEncryptedText.Text;

            hacker.Alphabet = alphabet;
            hacker.Analyze(text);

            var table1 = new Dictionary <char, double>();
            var table2 = new Dictionary <char, double>();

            switch (alphabet)
            {
            case Alphabet.Latin:
                table1 = analyzer.LatinTable;
                table2 = hacker.LatinTable;
                break;

            case Alphabet.Ukrainian:
                table1 = analyzer.UkrainianTable;
                table2 = hacker.UkrainianTable;
                break;
            }

            var query = from x in table1
                        orderby x.Value descending
                        select x.Key;
            var query2 = from x in table2
                         orderby x.Value descending
                         select x.Key;

            var substitutions = new Dictionary <char, char>();

            for (int i = 0; i < query.Count(); i++)
            {
                substitutions.Add(query.ElementAt(i), query2.ElementAt(i));
            }

            ObservableCollection <SubTable> collection = new ObservableCollection <SubTable>();

            foreach (var s in substitutions)
            {
                collection.Add(new SubTable {
                    Letter = s.Key, SubLetter = s.Value
                });
            }
            dataGridHackerTable.ItemsSource = collection;
            SubstitutionCypher cipher = new SubstitutionCypher {
                Alphabet = alphabet
            };

            textBoxDecryptedText.Text = cipher.Decrypt(text, substitutions);
        }
        private void Analyze()
        {
            string text        = textBoxAnalyzer.Text.ToLower();
            string correctText = Regex.Replace(text, @"\s+", " ");

            analyzer.Alphabet = alphabet;
            analyzer.Analyze(correctText);

            var table = new Dictionary <char, double>();

            switch (alphabet)
            {
            case Alphabet.Latin:
                table = analyzer.LatinTable;
                break;

            case Alphabet.Ukrainian:
                table = analyzer.UkrainianTable;
                break;
            }

            var query = from x in table
                        orderby x.Value descending
                        select new { Буква = x.Key, Частота = Math.Round(x.Value, 3).ToString() + "%" };

            ObservableCollection <FreqTable> collection = new ObservableCollection <FreqTable>();

            foreach (var q in query)
            {
                collection.Add(new FreqTable {
                    Letter = q.Буква, Frequency = q.Частота
                });
            }

            dataGridFrequencyTable.ItemsSource = collection;
        }