void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.wind = ((notepad.Window1)(target)); #line 8 "..\..\Window1.xaml" this.wind.Closing += new System.ComponentModel.CancelEventHandler(this.closeFunc); #line default #line hidden return; case 2: this.confirmButton = ((System.Windows.Controls.Button)(target)); #line 10 "..\..\Window1.xaml" this.confirmButton.Click += new System.Windows.RoutedEventHandler(this.confirmButton_Click); #line default #line hidden return; case 3: this.cancelButton = ((System.Windows.Controls.Button)(target)); #line 11 "..\..\Window1.xaml" this.cancelButton.Click += new System.Windows.RoutedEventHandler(this.cancelButton_Click); #line default #line hidden return; case 4: this.passwordTextBox = ((System.Windows.Controls.PasswordBox)(target)); return; } this._contentLoaded = true; }
private void openButton_Click(object sender, RoutedEventArgs e) // откыть { openFileDialog = new OpenFileDialog(); // // dialog.Filter = "Text documents (*.txt)|*.txt|All files (*.*)|*.*"; // шаблон записи нескольких расширений openFileDialog.Filter = "Текстовый документ (*.notepad)|*.notepad"; // расширения файла openFileDialog.FilterIndex = 0; // индекс выбранного варианта расширения по умолчанию resultOpenDialog = openFileDialog.ShowDialog(); if (resultOpenDialog == true) { // Open document filename = openFileDialog.FileName; // установка переменной значения пути // mainTextBox.Text = filename; // проверка верности пути using (FileStream fs = new FileStream(openFileDialog.FileName, FileMode.OpenOrCreate)) { doc = (TextDoc)formatter.Deserialize(fs); if (doc.isEncrypted) { while (true) { try { passwordWindow = new Window1(); passwordWindow.ShowDialog(); password = passwordWindow.Password; isEncrypted = true; } catch { // password = ""; isEncrypted = false; } if (isEncrypted) { if (password == doc.password) { //mainTextBox.Text = doc.text; mainRichTextBox.Document.Blocks.Clear(); mainRichTextBox.Document.Blocks.Add(new Paragraph(new Run(doc.text))); mainRichTextBox.FontSize = doc.kegel; switch (doc.font) { case 1: mainRichTextBox.FontFamily = new FontFamily("Segoe UI"); firstFont.IsChecked = true; break; case 2: mainRichTextBox.FontFamily = new FontFamily("Ink Free"); secondFont.IsChecked = true; break; case 3: mainRichTextBox.FontFamily = new FontFamily("Source Code Pro Light"); thirdFont.IsChecked = true; break; } isEncryptedLabel.Content = "зашифрован"; encryptButton.Content = "дешивровать"; break; } else { if (passwordWindow.IsCanceled) { break; } else { MessageBox.Show("Введен неверный пароль!"); } } } } } else { isEncryptedLabel.Content = "не зашифрован"; encryptButton.Content = "шивровать"; mainRichTextBox.Document.Blocks.Clear(); mainRichTextBox.Document.Blocks.Add(new Paragraph(new Run(doc.text))); mainRichTextBox.FontSize = doc.kegel; switch (doc.font) { case 1: mainRichTextBox.FontFamily = new FontFamily("Segoe UI"); break; case 2: mainRichTextBox.FontFamily = new FontFamily("Ink Free"); break; case 3: mainRichTextBox.FontFamily = new FontFamily("Source Code Pro Light"); break; } } } } isChanged = false; }