mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Auto lock if the app is inactive #48
This commit is contained in:
parent
e7583a09a5
commit
ea61a872c0
8 changed files with 90 additions and 0 deletions
|
|
@ -171,6 +171,9 @@
|
|||
<setting name="passwordGeneratorAdditional" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="lockTimeout" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="statusPanelReadonly" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
|
|
|
|||
3
Crypto Notepad/Forms/MainForm.Designer.cs
generated
3
Crypto Notepad/Forms/MainForm.Designer.cs
generated
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -6473,6 +6473,9 @@
|
|||
<metadata name="statusPanelTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>389, 17</value>
|
||||
</metadata>
|
||||
<metadata name="lockTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>1059, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>99</value>
|
||||
</metadata>
|
||||
|
|
|
|||
25
Crypto Notepad/Forms/SettingsForm.Designer.cs
generated
25
Crypto Notepad/Forms/SettingsForm.Designer.cs
generated
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
14
Crypto Notepad/Properties/Settings.Designer.cs
generated
14
Crypto Notepad/Properties/Settings.Designer.cs
generated
|
|
@ -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()]
|
||||
|
|
|
|||
|
|
@ -161,6 +161,9 @@
|
|||
<Setting Name="passwordGeneratorAdditional" Provider="PortableSettingsProvider" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="lockTimeout" Provider="PortableSettingsProvider" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="statusPanelReadonly" Provider="PortableSettingsProvider" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
|
|
|
|||
Loading…
Reference in a new issue