-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainForm.cs
99 lines (84 loc) · 2.69 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using Crypto;
using System;
using System.Windows.Forms;
namespace Encrypted_Notepad
{
public partial class MainForm : Form
{
string SavedText = "";
public MainForm()
{
InitializeComponent();
}
private void mnuNewFile_Click(object sender, EventArgs e)
{
mainTextBox.ResetText();
}
private void mainTextBox_TextChanged(object sender, EventArgs e)
{
SavedText = mainTextBox.Text;
}
private void CutText_Click(object sender, EventArgs e)
{
if (mainTextBox.SelectedText != "")
{
mainTextBox.Cut();
}
}
private void mnuSaveAndEncrypt_Click(object sender, EventArgs e)
{
dlg_saveFile.ShowDialog();
}
private void btn_encrypt_test_Click(object sender, EventArgs e)
{
mainTextBox.Text = DataEncryption.EncryptText(SavedText);
}
private void btn_decrypt_Click(object sender, EventArgs e)
{
mainTextBox.Text = DataEncryption.DecryptText(SavedText);
}
private void cToolStripMenuItem_Click(object sender, EventArgs e)
{
if (mainTextBox.SelectionLength > 0)
{
mainTextBox.Copy();
}
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
{
mainTextBox.Paste();
}
}
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
if (mainTextBox.CanUndo == true)
{
mainTextBox.Undo();
}
}
private void dlg_saveFile_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
if (e.Cancel == true ) { return; }
DataEncryption.SaveEncryptedTextToFile(dlg_saveFile.OpenFile(),DataEncryption.EncryptText(SavedText));
}
private void btn_newFileToolstrip_Click(object sender, EventArgs e)
{
mainTextBox.ResetText();
}
private void mnuDecryptAndOpen_Click(object sender, EventArgs e)
{
dlg_openFile.ShowDialog();
}
private void btn_openFileToolStrip_Click(object sender, EventArgs e)
{
dlg_openFile.ShowDialog();
}
private void dlg_openFile_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
if(e.Cancel == true ) { return; }
DataEncryption.OpenDecryptedTextFile(dlg_openFile.OpenFile());
}
}
}