private void OnSelectNewFileButtonClicked(object sender, RoutedEventArgs e) { string key = GetKeyFromUser(); if (String.IsNullOrWhiteSpace(key)) { MessageBox.Show(this, "Ключ не был введён!!!"); return; } key = key.Trim(); OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.CheckFileExists = true; fileDialog.Title = "Выберите файл"; fileDialog.DefaultExt = ".txt"; fileDialog.Filter = "Text documents (.txt)|*.txt"; Nullable <bool> result = fileDialog.ShowDialog(); if (result == false) { MessageBox.Show(this, "Файл не выбран!!"); return; } orginalText = File.ReadAllText(fileDialog.FileName, Encoding.Default); VigenereCipher cipher = new VigenereCipher(alphabet); TextPanel.Text = cipher.Decrypt(orginalText, key); }
private void OnChangeKeyButtonClicked(object sender, RoutedEventArgs e) { if (orginalText == String.Empty) { MessageBox.Show(this, "Нет исходного текста!!!"); return; } string key = GetKeyFromUser(); if (String.IsNullOrWhiteSpace(key)) { MessageBox.Show(this, "Ключ не был введён!!!"); return; } key = key.Trim(); VigenereCipher cipher = new VigenereCipher(alphabet); TextPanel.Text = cipher.Decrypt(orginalText, key); }