Added 2 improvements

Added warning message when open "Encrypt/Decrypt" tab;
Added "Reset to
defaults" button;
This commit is contained in:
Sigmanor 2016-01-10 14:37:37 +02:00
parent 5d6592e40f
commit 28d4342b62
5 changed files with 382 additions and 44 deletions

View file

@ -54,6 +54,7 @@ private void InitializeComponent()
this.tabPage3 = new System.Windows.Forms.TabPage();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
@ -79,7 +80,7 @@ private void InitializeComponent()
this.saveSettingsButton.Location = new System.Drawing.Point(183, 225);
this.saveSettingsButton.Name = "saveSettingsButton";
this.saveSettingsButton.Size = new System.Drawing.Size(75, 23);
this.saveSettingsButton.TabIndex = 2;
this.saveSettingsButton.TabIndex = 4;
this.saveSettingsButton.Text = "Save";
this.saveSettingsButton.UseVisualStyleBackColor = true;
this.saveSettingsButton.Click += new System.EventHandler(this.saveSettingsButton_Click);
@ -103,6 +104,7 @@ private void InitializeComponent()
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(260, 218);
this.tabControl1.TabIndex = 4;
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// tabPage1
//
@ -326,9 +328,9 @@ private void InitializeComponent()
this.checkBox2.Enabled = false;
this.checkBox2.Location = new System.Drawing.Point(7, 47);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(120, 17);
this.checkBox2.Size = new System.Drawing.Size(117, 17);
this.checkBox2.TabIndex = 1;
this.checkBox2.Text = "Auto Check Update";
this.checkBox2.Text = "Auto check update";
this.checkBox2.UseVisualStyleBackColor = true;
//
// checkBox1
@ -336,16 +338,27 @@ private void InitializeComponent()
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(7, 18);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(166, 17);
this.checkBox1.Size = new System.Drawing.Size(179, 17);
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "Associate with .enp extension";
this.checkBox1.Text = "Associate with enp file extension";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(6, 225);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(98, 23);
this.button1.TabIndex = 5;
this.button1.Text = "Reset to defaults";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(263, 254);
this.Controls.Add(this.button1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.saveSettingsButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@ -395,5 +408,6 @@ private void InitializeComponent()
private System.Windows.Forms.ComboBox comboBox4;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button button1;
}
}

View file

@ -2,6 +2,7 @@
using System;
using System.Drawing;
using System.IO;
using System.Media;
using System.Reflection;
using System.Windows.Forms;
@ -9,7 +10,6 @@ namespace Crypto_Notepad
{
public partial class SettingsForm : Form
{
Properties.Settings ps = Properties.Settings.Default;
MainWindow ma = new MainWindow();
@ -40,51 +40,42 @@ private void SettingsForm_Load(object sender, EventArgs e)
private void saveSettingsButton_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
AssociateExtension(Assembly.GetEntryAssembly().Location, "enp");
}
if (checkBox1.Checked == false)
{
DissociateExtension(Assembly.GetEntryAssembly().Location, "enp");
}
ps.RichForeColor = panel1.BackColor;
ps.RichBackColor = panel2.BackColor;
ps.HighlightsColor = panel3.BackColor;
ps.RichTextFont = comboBox1.Text;
ps.RichTextSize = Convert.ToInt32(comboBox2.Text.ToString());
ps.AssociateCheck = checkBox1.Checked;
ps.HashAlgorithm = comboBox4.Text;
ps.KeySize = Convert.ToInt32(comboBox3.Text.ToString());
ps.TheSalt = textBox1.Text;
ps.PasswordIterations = Convert.ToInt32(textBox2.Text.ToString());
ps.Save();
MainWindow.settingsChanged = true;
this.Hide();
SetSettings("Save");
}
public static void AssociateExtension(string applicationExecutablePath, string extension)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes", true);
key.CreateSubKey("." + extension).SetValue(string.Empty, extension + "_auto_file");
key = key.CreateSubKey(extension + "_auto_file");
key.CreateSubKey("DefaultIcon").SetValue(string.Empty, Path.GetDirectoryName(Application.ExecutablePath) + "\\EncryptPad.exe" + ",0");
key = key.CreateSubKey("Shell");
key.SetValue(string.Empty, "Open");
key = key.CreateSubKey("Open");
key.CreateSubKey("Command").SetValue(string.Empty, "\"" + applicationExecutablePath + "\" \"%1\"");
key.CreateSubKey("ddeexec\\Topic").SetValue(string.Empty, "System");
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes", true);
key.CreateSubKey("." + extension).SetValue(string.Empty, extension + "_auto_file");
key = key.CreateSubKey(extension + "_auto_file");
key.CreateSubKey("DefaultIcon").SetValue(string.Empty, Path.GetDirectoryName(Application.ExecutablePath) + "\\Crypto Notepad.exe" + ",0");
key = key.CreateSubKey("Shell");
key.SetValue(string.Empty, "Open");
key = key.CreateSubKey("Open");
key.CreateSubKey("Command").SetValue(string.Empty, "\"" + applicationExecutablePath + "\" \"%1\"");
key.CreateSubKey("ddeexec\\Topic").SetValue(string.Empty, "System");
}
catch (Exception)
{
}
}
public static void DissociateExtension(string applicationExecutablePath, string extension)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes", true);
key.DeleteSubKeyTree(extension + "_auto_file");
key.DeleteSubKeyTree("." + extension);
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes", true);
key.DeleteSubKeyTree(extension + "_auto_file");
key.DeleteSubKeyTree("." + extension);
}
catch (Exception)
{
}
}
private void panel1_Click_1(object sender, EventArgs e)
@ -116,5 +107,74 @@ private void panel3_Click(object sender, EventArgs e)
}
panel3.BackColor = colorDialog1.Color;
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if ((tabControl1.SelectedTab == tabControl1.TabPages["tabPage2"]) && (ps.WarningMsg == false))
{
SystemSounds.Beep.Play();
WarningMsgBox w = new WarningMsgBox();
w.ShowDialog(this);
}
}
private void button1_Click(object sender, EventArgs e)
{
using (new CenterWinDialog(this))
{
DialogResult result = MessageBox.Show("Reset to defaults?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
SetSettings("Default");
}
}
}
private void SetSettings(string value)
{
if (value == "Save")
{
if (checkBox1.Checked == true)
{
AssociateExtension(Assembly.GetEntryAssembly().Location, "enp");
}
if (checkBox1.Checked == false)
{
DissociateExtension(Assembly.GetEntryAssembly().Location, "enp");
}
ps.RichForeColor = panel1.BackColor;
ps.RichBackColor = panel2.BackColor;
ps.HighlightsColor = panel3.BackColor;
ps.RichTextFont = comboBox1.Text;
ps.RichTextSize = Convert.ToInt32(comboBox2.Text.ToString());
ps.AssociateCheck = checkBox1.Checked;
ps.HashAlgorithm = comboBox4.Text;
ps.KeySize = Convert.ToInt32(comboBox3.Text.ToString());
ps.TheSalt = textBox1.Text;
ps.PasswordIterations = Convert.ToInt32(textBox2.Text.ToString());
ps.Save();
MainWindow.settingsChanged = true;
this.Hide();
}
if (value == "Default")
{
checkBox1.Checked = false;
panel1.BackColor = Color.FromArgb(228, 228, 228);
panel2.BackColor = Color.FromArgb(56, 56, 56);
panel3.BackColor = Color.FromArgb(101, 51, 6);
comboBox1.Text = "Consolas";
comboBox2.Text = 11.ToString();
checkBox1.Checked = false;
comboBox4.Text = "SHA1";
comboBox3.Text = 192.ToString();
textBox2.Text = 2.ToString();
}
}
}
}

119
Crypto Notepad/WarningMsgBox.Designer.cs generated Normal file
View file

@ -0,0 +1,119 @@
namespace Crypto_Notepad
{
partial class WarningMsgBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(209, 98);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "OK";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(294, 87);
this.panel1.TabIndex = 1;
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.label1.Location = new System.Drawing.Point(84, 7);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(206, 69);
this.label1.TabIndex = 1;
this.label1.Text = "If you change settings in this tab, decrypt the previously encrypted files will n" +
"ot be possible.";
//
// pictureBox1
//
this.pictureBox1.Image = global::Crypto_Notepad.Properties.Resources.Warning_icon_hi;
this.pictureBox1.Location = new System.Drawing.Point(7, 7);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(71, 69);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(12, 101);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(172, 17);
this.checkBox1.TabIndex = 2;
this.checkBox1.Text = "Don\'t show this message again";
this.checkBox1.UseVisualStyleBackColor = true;
//
// WarningMsgBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(294, 130);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "WarningMsgBox";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Warning";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
}
}

View file

@ -0,0 +1,25 @@
using System;
using System.Windows.Forms;
namespace Crypto_Notepad
{
public partial class WarningMsgBox : Form
{
Properties.Settings ps = Properties.Settings.Default;
public WarningMsgBox()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
ps.WarningMsg = true;
ps.Save();
}
this.Close();
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>