mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Code formatting
This commit is contained in:
parent
35949efb8c
commit
c280500615
3 changed files with 13 additions and 72 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Media;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -95,7 +95,6 @@ private void OldKeyTextBox_TextChanged(object sender, EventArgs e)
|
|||
{
|
||||
acceptButton.Enabled = false;
|
||||
}
|
||||
|
||||
if (oldKeyTextBox.Text.Length > 0)
|
||||
{
|
||||
oldKeyPlaceholder.Visible = false;
|
||||
|
|
@ -116,7 +115,6 @@ private void NewKeyTextBox_TextChanged(object sender, EventArgs e)
|
|||
{
|
||||
acceptButton.Enabled = false;
|
||||
}
|
||||
|
||||
if (newKeyTextBox.Text.Length > 0)
|
||||
{
|
||||
newKeyPlaceholder.Visible = false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Crypto_Notepad
|
||||
|
|
@ -82,8 +82,7 @@ private void OkButton_Click(object sender, EventArgs e)
|
|||
TypedPassword.Value = keyTextBox.Text;
|
||||
keyTextBox.Focus();
|
||||
PublicVar.okPressed = true;
|
||||
Hide();
|
||||
|
||||
Hide();
|
||||
}
|
||||
/*Buttons*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Crypto_Notepad.Properties;
|
||||
using Crypto_Notepad.Properties;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -77,7 +77,6 @@ private void DecryptAES()
|
|||
PublicVar.openFileName = Path.GetFileName(filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,9 +112,8 @@ private void OpenAsotiations()
|
|||
{
|
||||
OpenAsotiations();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string opnfile = File.ReadAllText(args[1]);
|
||||
|
|
@ -133,7 +131,6 @@ private void SendTo()
|
|||
StartPosition = FormStartPosition.CenterScreen
|
||||
};
|
||||
string fileExtension = Path.GetExtension(argsPath);
|
||||
|
||||
if (fileExtension == ".cnp")
|
||||
{
|
||||
try
|
||||
|
|
@ -157,9 +154,8 @@ private void SendTo()
|
|||
{
|
||||
SendTo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string opnfile = File.ReadAllText(argsPath);
|
||||
|
|
@ -176,14 +172,11 @@ private void ContextMenuEncryptReplace()
|
|||
MessageBox.Show(this, "Looks like this file is already encrypted", PublicVar.appName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult res = MessageBox.Show(this, "This action will delete the source file and replace it with encrypted version", PublicVar.appName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||
|
||||
if (res == DialogResult.Cancel)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
if (!args[1].Contains(".cnp"))
|
||||
{
|
||||
string opnfile = File.ReadAllText(args[1]);
|
||||
|
|
@ -240,17 +233,14 @@ private void DeleteUpdateFiles()
|
|||
string UpdaterExe = exePath + "Updater.exe";
|
||||
string UpdateZip = exePath + "Crypto-Notepad-Update.zip";
|
||||
string ZipDll = exePath + "Ionic.Zip.dll";
|
||||
|
||||
if (File.Exists(UpdaterExe))
|
||||
{
|
||||
File.Delete(UpdaterExe);
|
||||
}
|
||||
|
||||
if (File.Exists(UpdateZip))
|
||||
{
|
||||
File.Delete(UpdateZip);
|
||||
}
|
||||
|
||||
if (File.Exists(ZipDll))
|
||||
{
|
||||
File.Delete(ZipDll);
|
||||
|
|
@ -274,7 +264,6 @@ private void SaveConfirm()
|
|||
{
|
||||
messageBoxText = "Save file: " + "\"" + PublicVar.openFileName + "\"" + " with a new key? ";
|
||||
}
|
||||
|
||||
using (new CenterWinDialog(this))
|
||||
{
|
||||
DialogResult res = MessageBox.Show(this, messageBoxText, PublicVar.appName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||
|
|
@ -302,7 +291,6 @@ private void CheckForUpdates(bool autoCheck)
|
|||
string version = Application.ProductVersion;
|
||||
string exePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\";
|
||||
int appVersion = Convert.ToInt32(version.Replace(".", "")), serverVersion = Convert.ToInt32(content.Replace(".", ""));
|
||||
|
||||
if (serverVersion > appVersion)
|
||||
{
|
||||
if (statusPanel.Visible)
|
||||
|
|
@ -368,12 +356,10 @@ private void CheckForUpdates(bool autoCheck)
|
|||
private async void StatusPanelMessage(string type)
|
||||
{
|
||||
string ready = "Ready";
|
||||
|
||||
if (statusPanelLabel.Text == "New version is available")
|
||||
{
|
||||
ready = "New version is available";
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "save":
|
||||
|
|
@ -429,7 +415,6 @@ private void StatusPanelTextInfo()
|
|||
{
|
||||
linesCount = 1;
|
||||
}
|
||||
|
||||
statusPanelLengthLabel.Text = "Length: " + richTextBox.TextLength;
|
||||
statusPaneLinesLabel.Text = "Lines: " + linesCount;
|
||||
statusPaneLnLabel.Text = "Ln: " + currentLine;
|
||||
|
|
@ -489,7 +474,6 @@ private void LoadSettings()
|
|||
lineNumbers.Dock = DockStyle.Left;
|
||||
rightToLeftContextMenu.Checked = false;
|
||||
}
|
||||
|
||||
if (settings.insertKey == "Disable")
|
||||
{
|
||||
insertMainMenu.ShortcutKeys = Keys.Insert;
|
||||
|
|
@ -498,19 +482,16 @@ private void LoadSettings()
|
|||
{
|
||||
insertMainMenu.ShortcutKeys = Keys.None;
|
||||
}
|
||||
|
||||
if (settings.autoCheckUpdate)
|
||||
{
|
||||
CheckForUpdates(false);
|
||||
}
|
||||
|
||||
if (settings.windowLocation.ToString() != "{X=0,Y=0}")
|
||||
{
|
||||
Location = settings.windowLocation;
|
||||
}
|
||||
Size = settings.windowSize;
|
||||
WindowState = settings.windowState;
|
||||
|
||||
if (settings.toolbarBorder)
|
||||
{
|
||||
toolbarPanel.BorderStyle = BorderStyle.FixedSingle;
|
||||
|
|
@ -519,37 +500,28 @@ private void LoadSettings()
|
|||
{
|
||||
toolbarPanel.BorderStyle = BorderStyle.None;
|
||||
}
|
||||
|
||||
TopMost = settings.alwaysOnTop;
|
||||
alwaysOnTopMainMenu.Checked = settings.alwaysOnTop;
|
||||
|
||||
if (settings.closeToTray | settings.minimizeToTray)
|
||||
{
|
||||
trayIcon.Visible = true;
|
||||
}
|
||||
|
||||
wordWrapMainMenu.Checked = settings.editorWrap;
|
||||
|
||||
toolbarPanel.BackColor = settings.toolbarBackColor;
|
||||
toolbarPanel.Visible = settings.toolbarVisible;
|
||||
|
||||
mainMenu.Visible = settings.mainMenuVisible;
|
||||
rightToLeftContextMenu.Checked = settings.editorRightToLeft;
|
||||
|
||||
lineNumbers.BackColor = settings.lineNumbersBackColor;
|
||||
lineNumbers.Font = settings.editorFont;
|
||||
lineNumbers.ForeColor = settings.lineNumbersForeColor;
|
||||
|
||||
statusPanel.ForeColor = settings.statusPanelFontColor;
|
||||
statusPanel.BackColor = settings.statusPanelBackColor;
|
||||
statusPanel.Visible = settings.statusPanelVisible;
|
||||
|
||||
richTextBox.WordWrap = settings.editorWrap;
|
||||
richTextBox.ForeColor = settings.editroForeColor;
|
||||
richTextBox.BackColor = settings.editorBackColor;
|
||||
richTextBox.Font = settings.editorFont;
|
||||
BackColor = settings.editorBackColor;
|
||||
|
||||
searchPanel.BackColor = settings.searchPanelBackColor;
|
||||
searchPanel.ForeColor = settings.searchPanelForeColor;
|
||||
searchTextBox.BackColor = settings.searchPanelBackColor;
|
||||
|
|
@ -557,7 +529,6 @@ private void LoadSettings()
|
|||
searchCaseSensitiveCheckBox.ForeColor = settings.searchPanelForeColor;
|
||||
searchWholeWordCheckBox.ForeColor = settings.searchPanelForeColor;
|
||||
searchFindNextButton.ForeColor = settings.searchPanelForeColor;
|
||||
|
||||
lineNumbers.Visible = bool.Parse(settings.lineNumbersVisible);
|
||||
lineNumbers.Show_BorderLines = bool.Parse(settings.borderLinesVisible);
|
||||
lineNumbers.Show_GridLines = bool.Parse(settings.gridLinesVisible);
|
||||
|
|
@ -694,14 +665,11 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
|||
settings.windowLocation = Location;
|
||||
settings.windowState = WindowState;
|
||||
}
|
||||
|
||||
if (WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
settings.windowState = WindowState;
|
||||
}
|
||||
settings.Save();
|
||||
|
||||
|
||||
if (settings.closeToTray)
|
||||
{
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
|
|
@ -715,7 +683,6 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (richTextBox.Modified)
|
||||
{
|
||||
if (PublicVar.openFileName == string.Empty | PublicVar.openFileName == null)
|
||||
|
|
@ -734,7 +701,6 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
|||
{
|
||||
messageBoxText = "Save file: " + "\"" + PublicVar.openFileName + "\"" + " with a new key? ";
|
||||
}
|
||||
|
||||
using (new CenterWinDialog(this))
|
||||
{
|
||||
DialogResult res = MessageBox.Show(this, messageBoxText, PublicVar.appName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||
|
|
@ -743,7 +709,6 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
|||
trayIcon.Visible = false;
|
||||
SaveMainMenu_Click(this, new EventArgs());
|
||||
}
|
||||
|
||||
if (res == DialogResult.Cancel)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
|
@ -764,17 +729,14 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
{
|
||||
Visible = false;
|
||||
searchPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
|
||||
|
||||
LoadSettings();
|
||||
DeleteUpdateFiles();
|
||||
MenuIcons(settings.menuIcons);
|
||||
Toolbaricons(settings.oldToolbarIcons);
|
||||
|
||||
if (args.Length == 2) /*drag & drop to executable*/
|
||||
{
|
||||
OpenAsotiations();
|
||||
}
|
||||
|
||||
if (args.Contains("/s")) /*send to*/
|
||||
{
|
||||
foreach (var arg in args)
|
||||
|
|
@ -783,22 +745,18 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
}
|
||||
SendTo();
|
||||
}
|
||||
|
||||
if (args.Contains("/o")) /*decrypt & open cnp*/
|
||||
{
|
||||
OpenAsotiations();
|
||||
}
|
||||
|
||||
if (args.Contains("/e")) /*encrypt*/
|
||||
{
|
||||
ContextMenuEncrypt();
|
||||
}
|
||||
|
||||
if (args.Contains("/er")) /*encrypt and replace*/
|
||||
{
|
||||
ContextMenuEncryptReplace();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
debugMainMenu.Visible = true;
|
||||
#endif
|
||||
|
|
@ -835,7 +793,7 @@ private void RichTextBox_KeyDown(object sender, KeyEventArgs e)
|
|||
e.Handled = e.SuppressKeyPress = true;
|
||||
findPos = 0;
|
||||
}
|
||||
|
||||
if (e.KeyCode == Keys.Enter & searchPanel.Visible & !string.IsNullOrEmpty(searchTextBox.Text))
|
||||
if (e.KeyCode == Keys.Enter & searchPanel.Visible & searchTextBox.Text != "")
|
||||
{
|
||||
SearchFindNextButton_Click(this, new EventArgs());
|
||||
|
|
@ -849,7 +807,6 @@ private void RichTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
|
|||
{
|
||||
Process.Start(e.LinkText);
|
||||
}
|
||||
|
||||
if (settings.openLinks == "Shift+LMB")
|
||||
{
|
||||
if ((ModifierKeys & Keys.Shift) != 0)
|
||||
|
|
@ -857,7 +814,6 @@ private void RichTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
|
|||
Process.Start(e.LinkText);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.openLinks == "Control+LMB")
|
||||
{
|
||||
if ((ModifierKeys & Keys.Control) != 0)
|
||||
|
|
@ -974,14 +930,12 @@ private void NewMainMenu_Click(object sender, EventArgs e)
|
|||
{
|
||||
saveFileDialog.FileName = "Unnamed.cnp";
|
||||
PublicVar.encryptionKey.Set(TypedPassword.Value);
|
||||
|
||||
PublicVar.okPressed = false;
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
TypedPassword.Value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
richTextBox.Clear();
|
||||
StreamWriter sw = new StreamWriter(saveFileDialog.FileName);
|
||||
string NameWithotPath = Path.GetFileName(saveFileDialog.FileName);
|
||||
|
|
@ -1013,9 +967,7 @@ private void OpenMainMenu_Click(object sender, EventArgs e)
|
|||
Text = PublicVar.appName + " – " + NameWithotPath;
|
||||
return;
|
||||
}
|
||||
|
||||
DecryptAES();
|
||||
|
||||
richTextBox.Modified = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1053,22 +1005,18 @@ private void SaveAsMainMenu_Click(object sender, EventArgs e)
|
|||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
if (string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
|
||||
{
|
||||
enterKeyForm.ShowDialog();
|
||||
}
|
||||
|
||||
if (saveFileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TypedPassword.Value == null)
|
||||
{
|
||||
TypedPassword.Value = PublicVar.encryptionKey.Get();
|
||||
}
|
||||
|
||||
filePath = saveFileDialog.FileName;
|
||||
string enc = AES.Encrypt(richTextBox.Text, TypedPassword.Value, null, settings.HashAlgorithm, Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize));
|
||||
using (StreamWriter writer = new StreamWriter(filePath))
|
||||
|
|
@ -1076,7 +1024,6 @@ private void SaveAsMainMenu_Click(object sender, EventArgs e)
|
|||
writer.Write(enc);
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
richTextBox.Modified = false;
|
||||
Text = PublicVar.appName + " – " + Path.GetFileName(filePath);
|
||||
PublicVar.encryptionKey.Set(TypedPassword.Value);
|
||||
|
|
@ -1546,7 +1493,7 @@ private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
|
|||
e.Handled = e.SuppressKeyPress = true;
|
||||
findPos = 0;
|
||||
}
|
||||
|
||||
if (e.KeyCode == Keys.Enter & searchPanel.Visible & !string.IsNullOrEmpty(searchTextBox.Text))
|
||||
if (e.KeyCode == Keys.Enter & searchPanel.Visible & searchTextBox.Text != "")
|
||||
{
|
||||
SearchFindNextButton_Click(this, new EventArgs());
|
||||
|
|
@ -1612,19 +1559,16 @@ private void SearchFindNextButton_Click(object sender, EventArgs e)
|
|||
FindText(searchTextBox.Text, RichTextBoxFinds.None);
|
||||
return;
|
||||
}
|
||||
|
||||
if (searchWholeWordCheckBox.Checked & searchCaseSensitiveCheckBox.Checked)
|
||||
{
|
||||
FindText(searchTextBox.Text, RichTextBoxFinds.MatchCase | RichTextBoxFinds.WholeWord);
|
||||
return;
|
||||
}
|
||||
|
||||
if (searchCaseSensitiveCheckBox.Checked)
|
||||
{
|
||||
FindText(searchTextBox.Text, RichTextBoxFinds.MatchCase);
|
||||
return;
|
||||
}
|
||||
|
||||
if (searchWholeWordCheckBox.Checked)
|
||||
{
|
||||
FindText(searchTextBox.Text, RichTextBoxFinds.WholeWord);
|
||||
|
|
@ -1661,7 +1605,6 @@ private void FileLockedPanel_VisibleChanged(object sender, EventArgs e)
|
|||
dropDownItem.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
PublicVar.encryptionKey.Set(null);
|
||||
caretPos = richTextBox.SelectionStart;
|
||||
richTextBox.Visible = false;
|
||||
|
|
@ -1687,7 +1630,6 @@ private void FileLockedPanel_VisibleChanged(object sender, EventArgs e)
|
|||
mainMenu.Enabled = true;
|
||||
fileLockedKeyTextBox.Text = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void FileLockedOkButton_Click(object sender, EventArgs e)
|
||||
|
|
@ -1714,7 +1656,7 @@ private void FileLockedShowKey_Click(object sender, EventArgs e)
|
|||
{
|
||||
fileLockedKeyTextBox.UseSystemPasswordChar = true;
|
||||
fileLockedShowKey.Image = Resources.eye_half;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FileLockedKeyTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
@ -1780,5 +1722,7 @@ private void VariablesMainMenu_Click(object sender, EventArgs e)
|
|||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue