diff --git a/Crypto Notepad/App.config b/Crypto Notepad/App.config
index 302f2a2..35a9003 100644
--- a/Crypto Notepad/App.config
+++ b/Crypto Notepad/App.config
@@ -171,6 +171,9 @@
False
+
+
+
True
diff --git a/Crypto Notepad/Forms/MainForm.Designer.cs b/Crypto Notepad/Forms/MainForm.Designer.cs
index 57c7933..bd94eb8 100644
--- a/Crypto Notepad/Forms/MainForm.Designer.cs
+++ b/Crypto Notepad/Forms/MainForm.Designer.cs
@@ -127,6 +127,7 @@ public void InitializeComponent()
this.richTextBoxPanel = new System.Windows.Forms.Panel();
this.richTextBox = new Crypto_Notepad.ExRichTextBox();
this.statusPanelTimer = new System.Windows.Forms.Timer(this.components);
+ this.lockTimer = new System.Windows.Forms.Timer(this.components);
this.mainMenu.SuspendLayout();
this.contextMenu.SuspendLayout();
this.searchPanel.SuspendLayout();
@@ -1191,6 +1192,8 @@ public void InitializeComponent()
this.richTextBoxPanel.Size = new System.Drawing.Size(504, 186);
this.richTextBoxPanel.TabIndex = 21;
//
+ // lockTimer
+ this.lockTimer.Tick += new System.EventHandler(this.LockTimer_Tick);
// richTextBox
//
this.richTextBox.AcceptsTab = true;
diff --git a/Crypto Notepad/Forms/MainForm.cs b/Crypto Notepad/Forms/MainForm.cs
index be18d4f..89eb570 100644
--- a/Crypto Notepad/Forms/MainForm.cs
+++ b/Crypto Notepad/Forms/MainForm.cs
@@ -446,6 +446,12 @@ private void StatusPanelTimer_Tick(object sender, EventArgs e)
statusPanelTimer.Stop();
}
+ private void LockTimer_Tick(object sender, EventArgs e)
+ {
+ LockMainMenu_Click(this, new EventArgs());
+ lockTimer.Enabled = false;
+ }
+
private async Task UnlockFile()
{
try
@@ -709,6 +715,16 @@ private void MainWindow_Activated(object sender, EventArgs e)
{
richTextBox.Modified = true;
}
+ lockTimer.Enabled = false;
+ }
+
+ private void MainForm_Deactivate(object sender, EventArgs e)
+ {
+ if (!string.IsNullOrEmpty(settings.lockTimeout) & settings.lockTimeout != "0" & !string.IsNullOrEmpty(PublicVar.password.Get()))
+ {
+ lockTimer.Interval = int.Parse(settings.lockTimeout) * 60000;
+ lockTimer.Enabled = true;
+ }
}
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
diff --git a/Crypto Notepad/Forms/MainForm.resx b/Crypto Notepad/Forms/MainForm.resx
index 099bff6..20a06a9 100644
--- a/Crypto Notepad/Forms/MainForm.resx
+++ b/Crypto Notepad/Forms/MainForm.resx
@@ -6473,6 +6473,9 @@
389, 17
+
+ 1059, 17
+
99
diff --git a/Crypto Notepad/Forms/SettingsForm.Designer.cs b/Crypto Notepad/Forms/SettingsForm.Designer.cs
index e1f64c1..7ec4e81 100644
--- a/Crypto Notepad/Forms/SettingsForm.Designer.cs
+++ b/Crypto Notepad/Forms/SettingsForm.Designer.cs
@@ -67,6 +67,8 @@ private void InitializeComponent()
this.hashAlgorithmLabel = new System.Windows.Forms.Label();
this.keySizeComboBox = new System.Windows.Forms.ComboBox();
this.statusPanelTabPage = new System.Windows.Forms.TabPage();
+ this.lockTimeoutTextBox = new System.Windows.Forms.PlaceholderTextBox();
+ this.lockTimeoutLabel = new System.Windows.Forms.Label();
this.statusPanelLabelsGroupBox = new System.Windows.Forms.GroupBox();
this.statusPanelLengthCheckBox = new System.Windows.Forms.CheckBox();
this.statusPanelSizeCheckBox = new System.Windows.Forms.CheckBox();
@@ -188,6 +190,27 @@ private void InitializeComponent()
this.minimizeToTrayCheckBox.UseVisualStyleBackColor = true;
this.minimizeToTrayCheckBox.Click += new System.EventHandler(this.MinimizeToTrayCheckBox_Click);
//
+ // lockTimeoutTextBox
+ //
+ this.lockTimeoutTextBox.Location = new System.Drawing.Point(134, 45);
+ this.lockTimeoutTextBox.Name = "lockTimeoutTextBox";
+ this.lockTimeoutTextBox.Placeholder = "";
+ this.lockTimeoutTextBox.PlaceholderActiveForeColor = System.Drawing.Color.DarkGray;
+ this.lockTimeoutTextBox.PlaceholderFont = new System.Drawing.Font("Segoe UI", 8.25F);
+ this.lockTimeoutTextBox.PlaceholderForeColor = System.Drawing.Color.DarkGray;
+ this.lockTimeoutTextBox.Size = new System.Drawing.Size(44, 23);
+ this.lockTimeoutTextBox.TabIndex = 8;
+ this.lockTimeoutTextBox.TextChanged += new System.EventHandler(this.LockTimeoutTextBox_TextChanged);
+ this.lockTimeoutTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.LockTimeoutTextBox_KeyPress);
+ //
+ // lockTimeoutLabel
+ //
+ this.lockTimeoutLabel.AutoSize = true;
+ this.lockTimeoutLabel.Location = new System.Drawing.Point(3, 48);
+ this.lockTimeoutLabel.Name = "lockTimeoutLabel";
+ this.lockTimeoutLabel.Size = new System.Drawing.Size(125, 15);
+ this.lockTimeoutLabel.TabIndex = 7;
+ this.lockTimeoutLabel.Text = "If the app is inactive in";
// mainMenuCheckBox
//
this.mainMenuCheckBox.AutoSize = true;
@@ -954,5 +977,7 @@ private void InitializeComponent()
private System.Windows.Forms.GroupBox statusPanelLabelsGroupBox;
private System.Windows.Forms.Label encryptionHintLabel;
private System.Windows.Forms.ToolTip settingsToolTip;
+ private System.Windows.Forms.PlaceholderTextBox lockTimeoutTextBox;
+ private System.Windows.Forms.Label lockTimeoutLabel;
}
}
\ No newline at end of file
diff --git a/Crypto Notepad/Forms/SettingsForm.cs b/Crypto Notepad/Forms/SettingsForm.cs
index a97460a..079a235 100644
--- a/Crypto Notepad/Forms/SettingsForm.cs
+++ b/Crypto Notepad/Forms/SettingsForm.cs
@@ -28,6 +28,7 @@ private void LoadSettings()
editorOpenLinksWithComboBox.Text = settings.openLinks;
editorBorderComboBox.Text = settings.editorBorder;
fontDialog.Font = settings.editorFont;
+ lockTimeoutTextBox.Text = settings.lockTimeout;
autoLockOnMinimizeCheckBox.Checked = settings.autoLock;
autoCheckUpdatesCheckBox.Checked = settings.autoCheckUpdate;
mainMenuCheckBox.Checked = settings.mainMenuVisible;
@@ -114,6 +115,14 @@ private void PasswordIterationsTextBox_KeyPress(object sender, KeyPressEventArgs
e.Handled = true;
}
}
+
+ private void LockTimeoutTextBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
+ {
+ e.Handled = true;
+ }
+ }
#endregion
@@ -238,6 +247,20 @@ private void EditorPaddingLeftTextBox_TextChanged(object sender, EventArgs e)
}
}
+ private void LockTimeoutTextBox_TextChanged(object sender, EventArgs e)
+ {
+ if (lockTimeoutTextBox.Text != settings.lockTimeout)
+ {
+ settings.lockTimeout = lockTimeoutTextBox.Text;
+ }
+
+ if (string.IsNullOrEmpty(lockTimeoutTextBox.Text) | lockTimeoutTextBox.Text == "0")
+ {
+ MainForm main = Owner as MainForm;
+ main.lockTimer.Enabled = false;
+ }
+ }
+
private void SendToCheckBox_Click(object sender, EventArgs e)
{
if (sendToCheckBox.Checked)
diff --git a/Crypto Notepad/Properties/Settings.Designer.cs b/Crypto Notepad/Properties/Settings.Designer.cs
index 578a04e..26e5075 100644
--- a/Crypto Notepad/Properties/Settings.Designer.cs
+++ b/Crypto Notepad/Properties/Settings.Designer.cs
@@ -712,6 +712,20 @@ public bool passwordGeneratorAdditional {
this["passwordGeneratorAdditional"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string lockTimeout {
+ get {
+ return ((string)(this["lockTimeout"]));
+ }
+ set {
+ this["lockTimeout"] = value;
+ }
+ }
+
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
diff --git a/Crypto Notepad/Properties/Settings.settings b/Crypto Notepad/Properties/Settings.settings
index e29c345..a8b7eda 100644
--- a/Crypto Notepad/Properties/Settings.settings
+++ b/Crypto Notepad/Properties/Settings.settings
@@ -161,6 +161,9 @@
False
+
+
+
True