mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
App name now stored in variable
This commit is contained in:
parent
a091168c41
commit
05e7a8e01e
3 changed files with 27 additions and 28 deletions
|
|
@ -15,7 +15,7 @@ public AboutFrom()
|
||||||
private void AboutWindow_Load(object sender, EventArgs e)
|
private void AboutWindow_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Version vrs = new Version(Application.ProductVersion);
|
Version vrs = new Version(Application.ProductVersion);
|
||||||
AppVersionLabel.Text = string.Format("Crypto Notepad " + "{0}.{1}.{2}", vrs.Major, vrs.Minor, vrs.Build);
|
AppVersionLabel.Text = string.Format(PublicVar.appName + " {0}.{1}.{2}", vrs.Major, vrs.Minor, vrs.Build);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AboutFrom_Click(object sender, EventArgs e)
|
private void AboutFrom_Click(object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ private void DecryptAES()
|
||||||
using (new CenterWinDialog(this))
|
using (new CenterWinDialog(this))
|
||||||
{
|
{
|
||||||
TypedPassword.Value = null;
|
TypedPassword.Value = null;
|
||||||
DialogResult dialogResult = MessageBox.Show("Invalid key!", "Crypto Notepad", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
DialogResult dialogResult = MessageBox.Show("Invalid key!", PublicVar.appName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
||||||
if (dialogResult == DialogResult.Retry)
|
if (dialogResult == DialogResult.Retry)
|
||||||
{
|
{
|
||||||
DecryptAES();
|
DecryptAES();
|
||||||
|
|
@ -118,7 +118,7 @@ private void OpenAsotiations()
|
||||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||||
CustomRTB.Text = de;
|
CustomRTB.Text = de;
|
||||||
|
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
|
|
||||||
filePath = args[1];
|
filePath = args[1];
|
||||||
string cc = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
@ -129,7 +129,7 @@ private void OpenAsotiations()
|
||||||
catch (CryptographicException)
|
catch (CryptographicException)
|
||||||
{
|
{
|
||||||
TypedPassword.Value = null;
|
TypedPassword.Value = null;
|
||||||
DialogResult dialogResult = MessageBox.Show("Invalid key!", "Crypto Notepad", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
DialogResult dialogResult = MessageBox.Show("Invalid key!", PublicVar.appName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
||||||
if (dialogResult == DialogResult.Retry)
|
if (dialogResult == DialogResult.Retry)
|
||||||
{
|
{
|
||||||
OpenAsotiations();
|
OpenAsotiations();
|
||||||
|
|
@ -142,7 +142,7 @@ private void OpenAsotiations()
|
||||||
string opnfile = File.ReadAllText(args[1]);
|
string opnfile = File.ReadAllText(args[1]);
|
||||||
string NameWithotPath = Path.GetFileName(args[1]);
|
string NameWithotPath = Path.GetFileName(args[1]);
|
||||||
CustomRTB.Text = opnfile;
|
CustomRTB.Text = opnfile;
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +173,7 @@ private void SendTo()
|
||||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||||
CustomRTB.Text = de;
|
CustomRTB.Text = de;
|
||||||
|
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
|
|
||||||
filePath = argsPath;
|
filePath = argsPath;
|
||||||
string cc = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
@ -185,7 +185,7 @@ private void SendTo()
|
||||||
catch (CryptographicException)
|
catch (CryptographicException)
|
||||||
{
|
{
|
||||||
TypedPassword.Value = null;
|
TypedPassword.Value = null;
|
||||||
DialogResult dialogResult = MessageBox.Show("Invalid key!", "Crypto Notepad", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
DialogResult dialogResult = MessageBox.Show("Invalid key!", PublicVar.appName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
||||||
if (dialogResult == DialogResult.Retry)
|
if (dialogResult == DialogResult.Retry)
|
||||||
{
|
{
|
||||||
SendTo();
|
SendTo();
|
||||||
|
|
@ -198,7 +198,7 @@ private void SendTo()
|
||||||
string opnfile = File.ReadAllText(argsPath);
|
string opnfile = File.ReadAllText(argsPath);
|
||||||
string NameWithotPath = Path.GetFileName(argsPath);
|
string NameWithotPath = Path.GetFileName(argsPath);
|
||||||
CustomRTB.Text = opnfile;
|
CustomRTB.Text = opnfile;
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
||||||
}
|
}
|
||||||
|
|
@ -207,13 +207,13 @@ private void SendTo()
|
||||||
private void SendToShortcut()
|
private void SendToShortcut()
|
||||||
{
|
{
|
||||||
string shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\SendTo";
|
string shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\SendTo";
|
||||||
string shortcutName = "Crypto Notepad" + ".lnk";
|
string shortcutName = PublicVar.appName + ".lnk";
|
||||||
string shortcutLocation = Path.Combine(shortcutPath, shortcutName);
|
string shortcutLocation = Path.Combine(shortcutPath, shortcutName);
|
||||||
string targetFileLocation = Assembly.GetEntryAssembly().Location;
|
string targetFileLocation = Assembly.GetEntryAssembly().Location;
|
||||||
|
|
||||||
WshShell shell = new WshShell();
|
WshShell shell = new WshShell();
|
||||||
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
|
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
|
||||||
shortcut.Description = "Crypto Notepad";
|
shortcut.Description = PublicVar.appName;
|
||||||
shortcut.IconLocation = targetFileLocation;
|
shortcut.IconLocation = targetFileLocation;
|
||||||
shortcut.TargetPath = targetFileLocation;
|
shortcut.TargetPath = targetFileLocation;
|
||||||
shortcut.Arguments = "/s";
|
shortcut.Arguments = "/s";
|
||||||
|
|
@ -226,11 +226,11 @@ private void ContextMenuEncryptReplace()
|
||||||
|
|
||||||
if (args[1].Contains(".cnp"))
|
if (args[1].Contains(".cnp"))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Looks like this file is already encrypted", "Crypto Notepad", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Looks like this file is already encrypted", PublicVar.appName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogResult res = MessageBox.Show("This action will delete the source file and replace it with encrypted version", "Crypto Notepad", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
DialogResult res = MessageBox.Show("This action will delete the source file and replace it with encrypted version", PublicVar.appName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||||
|
|
||||||
if (res == DialogResult.Cancel)
|
if (res == DialogResult.Cancel)
|
||||||
{
|
{
|
||||||
|
|
@ -274,7 +274,6 @@ private void ContextMenuEncryptReplace()
|
||||||
TypedPassword.Value = null;
|
TypedPassword.Value = null;
|
||||||
filePath = newFile;
|
filePath = newFile;
|
||||||
currentFilename = Path.GetFileName(newFile);
|
currentFilename = Path.GetFileName(newFile);
|
||||||
Text = appName + currentFilename;
|
|
||||||
CustomRTB.Text = noenc;
|
CustomRTB.Text = noenc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,7 +297,7 @@ private void ContextMenuEncrypt()
|
||||||
string opnfile = File.ReadAllText(args[1]);
|
string opnfile = File.ReadAllText(args[1]);
|
||||||
string NameWithotPath = Path.GetFileName(args[1]);
|
string NameWithotPath = Path.GetFileName(args[1]);
|
||||||
CustomRTB.Text = opnfile;
|
CustomRTB.Text = opnfile;
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + NameWithotPath;
|
||||||
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
||||||
currentFilename = Path.GetFileName(args[1]);
|
currentFilename = Path.GetFileName(args[1]);
|
||||||
|
|
@ -372,7 +371,7 @@ private void SaveConfirm(bool exit)
|
||||||
|
|
||||||
using (new CenterWinDialog(this))
|
using (new CenterWinDialog(this))
|
||||||
{
|
{
|
||||||
DialogResult res = MessageBox.Show(messageBoxText, "Crypto Notepad", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
DialogResult res = MessageBox.Show(messageBoxText, PublicVar.appName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||||
if (res == DialogResult.Yes)
|
if (res == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
SaveToolStripMenuItem_Click(this, new EventArgs());
|
SaveToolStripMenuItem_Click(this, new EventArgs());
|
||||||
|
|
@ -444,7 +443,7 @@ private void CheckForUpdates(bool autoCheck)
|
||||||
{
|
{
|
||||||
using (new CenterWinDialog(this))
|
using (new CenterWinDialog(this))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Crypto Notepad is up to date.", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Crypto Notepad is up to date.", PublicVar.appName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -474,8 +473,8 @@ private void AutoLock(bool minimize)
|
||||||
{
|
{
|
||||||
PublicVar.encryptionKey.Set(null);
|
PublicVar.encryptionKey.Set(null);
|
||||||
CustomRTB.Clear();
|
CustomRTB.Clear();
|
||||||
Text = appName.Remove(14);
|
Text = PublicVar.appName;
|
||||||
currentFilename = "";
|
PublicVar.openFileName = null;
|
||||||
filePath = "";
|
filePath = "";
|
||||||
Show();
|
Show();
|
||||||
return;
|
return;
|
||||||
|
|
@ -488,7 +487,7 @@ private void AutoLock(bool minimize)
|
||||||
string opnfile = File.ReadAllText(filePath);
|
string opnfile = File.ReadAllText(filePath);
|
||||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||||
CustomRTB.Text = de;
|
CustomRTB.Text = de;
|
||||||
Text = appName + currentFilename;
|
Text = PublicVar.appName + " – " + PublicVar.openFileName;
|
||||||
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
||||||
CustomRTB.SelectionStart = caretPos;
|
CustomRTB.SelectionStart = caretPos;
|
||||||
|
|
@ -501,7 +500,7 @@ private void AutoLock(bool minimize)
|
||||||
if (ex is CryptographicException)
|
if (ex is CryptographicException)
|
||||||
{
|
{
|
||||||
TypedPassword.Value = null;
|
TypedPassword.Value = null;
|
||||||
DialogResult dialogResult = MessageBox.Show("Invalid key!", "Crypto Notepad", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
DialogResult dialogResult = MessageBox.Show("Invalid key!", PublicVar.appName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
|
||||||
if (dialogResult == DialogResult.Retry)
|
if (dialogResult == DialogResult.Retry)
|
||||||
{
|
{
|
||||||
AutoLock(false);
|
AutoLock(false);
|
||||||
|
|
@ -510,7 +509,7 @@ private void AutoLock(bool minimize)
|
||||||
{
|
{
|
||||||
PublicVar.encryptionKey.Set(null);
|
PublicVar.encryptionKey.Set(null);
|
||||||
CustomRTB.Clear();
|
CustomRTB.Clear();
|
||||||
Text = appName.Remove(14);
|
Text = PublicVar.appName;
|
||||||
filePath = "";
|
filePath = "";
|
||||||
currentFilename = "";
|
currentFilename = "";
|
||||||
Show();
|
Show();
|
||||||
|
|
@ -826,7 +825,7 @@ private void CustomRTB_DragDrop(object sender, DragEventArgs e)
|
||||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||||
CustomRTB.Text = opnfile;
|
CustomRTB.Text = opnfile;
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
||||||
currentFilename = Path.GetFileName(OpenFile.FileName);
|
currentFilename = Path.GetFileName(OpenFile.FileName);
|
||||||
|
|
@ -892,7 +891,7 @@ private void NewToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
CustomRTB.Clear();
|
CustomRTB.Clear();
|
||||||
StreamWriter sw = new StreamWriter(SaveFile.FileName);
|
StreamWriter sw = new StreamWriter(SaveFile.FileName);
|
||||||
string NameWithotPath = Path.GetFileName(SaveFile.FileName);
|
string NameWithotPath = Path.GetFileName(SaveFile.FileName);
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
filePath = SaveFile.FileName;
|
filePath = SaveFile.FileName;
|
||||||
currentFilename = Path.GetFileName(SaveFile.FileName);
|
currentFilename = Path.GetFileName(SaveFile.FileName);
|
||||||
sw.Close();
|
sw.Close();
|
||||||
|
|
@ -918,7 +917,7 @@ private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||||
CustomRTB.Text = opnfile;
|
CustomRTB.Text = opnfile;
|
||||||
Text = appName + NameWithotPath;
|
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||||
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
string cc2 = CustomRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||||
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
CustomRTB.Select(Convert.ToInt32(cc2), 0);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1035,7 +1034,7 @@ private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
}
|
}
|
||||||
sw.Close();
|
sw.Close();
|
||||||
CustomRTB.Text = noenc;
|
CustomRTB.Text = noenc;
|
||||||
Text = appName + Path.GetFileName(filePath);
|
Text = PublicVar.appName + " – " + Path.GetFileName(filePath);
|
||||||
CustomRTB.Select(Convert.ToInt32(saveCaret), 0);
|
CustomRTB.Select(Convert.ToInt32(saveCaret), 0);
|
||||||
PublicVar.encryptionKey.Set(TypedPassword.Value);
|
PublicVar.encryptionKey.Set(TypedPassword.Value);
|
||||||
TypedPassword.Value = null;
|
TypedPassword.Value = null;
|
||||||
|
|
@ -1053,7 +1052,7 @@ private void DeleteFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (new CenterWinDialog(this))
|
using (new CenterWinDialog(this))
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Delete file: " + "\"" + filePath + "\"" + " ?", "Crypto Notepad", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Delete file: " + "\"" + filePath + "\"" + " ?", PublicVar.appName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
File.Delete(filePath);
|
File.Delete(filePath);
|
||||||
CustomRTB.Clear();
|
CustomRTB.Clear();
|
||||||
|
|
@ -1063,8 +1062,7 @@ private void DeleteFileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
ChangeKeyToolbarButton.Enabled = false;
|
ChangeKeyToolbarButton.Enabled = false;
|
||||||
LockToolbarButton.Enabled = false;
|
LockToolbarButton.Enabled = false;
|
||||||
filePath = "";
|
filePath = "";
|
||||||
currentFilename = "Unnamed.cnp";
|
Text = PublicVar.appName;
|
||||||
Text = appName.Remove(14);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ static class PublicVar
|
||||||
public static bool settingsChanged = false;
|
public static bool settingsChanged = false;
|
||||||
public static bool okPressed = false;
|
public static bool okPressed = false;
|
||||||
public static string openFileName = "Crypto Notepad";
|
public static string openFileName = "Crypto Notepad";
|
||||||
|
public const string appName = "Crypto Notepad";
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TypedPassword
|
static class TypedPassword
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue