From 01f1b554e9671ccd9dd4d9b7ed02dca10e9a42e3 Mon Sep 17 00:00:00 2001 From: rookiestyle Date: Sat, 11 May 2024 10:35:30 +0200 Subject: [PATCH] Don't show asterisks for empty fields If column data is hidden using asterisks, KeePass shows asterisks even for empty fields. ColoredPassword now offers an option in the advanced settings to not show asterisks for empty fields. This option is inactive by default. --- Translations/ColoredPassword.de.language.xml | 6 +- .../ColoredPassword.template.language.xml | 4 + src/ColoredPassword.cs | 71 +++++++++- src/Options.Designer.cs | 131 ++++++++++-------- src/Options.cs | 14 +- src/PluginTranslation.cs | 4 + src/Properties/AssemblyInfo.cs | 6 +- src/Util.cs | 47 +++++++ version.info | 4 +- 9 files changed, 222 insertions(+), 65 deletions(-) diff --git a/Translations/ColoredPassword.de.language.xml b/Translations/ColoredPassword.de.language.xml index b277504..cbba110 100644 --- a/Translations/ColoredPassword.de.language.xml +++ b/Translations/ColoredPassword.de.language.xml @@ -4,7 +4,7 @@ Increment the TranslationVersion every time the translation file is updated Also update the version.info file --> - 7 + 8 Active Aktiv @@ -49,4 +49,8 @@ SyncColors Synchronisiere Schriftfarben + + DontShowAsterisks + Zeige keine * für leere Felder, auch wenn '{0}' aktiv ist + \ No newline at end of file diff --git a/Translations/ColoredPassword.template.language.xml b/Translations/ColoredPassword.template.language.xml index d99fa38..259f1a6 100644 --- a/Translations/ColoredPassword.template.language.xml +++ b/Translations/ColoredPassword.template.language.xml @@ -49,4 +49,8 @@ SyncColors Snychronize font colors + + DontShowAsterisks + Don't show asterisks for empty fields if '{0}' is active + \ No newline at end of file diff --git a/src/ColoredPassword.cs b/src/ColoredPassword.cs index e2dacbe..4c964da 100644 --- a/src/ColoredPassword.cs +++ b/src/ColoredPassword.cs @@ -6,6 +6,7 @@ using KeePass.App.Configuration; using KeePass.Plugins; using KeePass.UI; +using KeePassLib; using KeePassLib.Utility; using PluginTools; @@ -49,10 +50,76 @@ public override bool Initialize(IPluginHost host) SinglePwDisplay.Enabled = ColorConfig.SinglePwDisplayActive; + m_host.MainWindow.UIStateUpdated += OnUIStateUpdated; + return true; } - private void MainWindow_FormLoadPost(object sender, EventArgs e) + private void OnUIStateUpdated(object sender, EventArgs e) + { + if (!ColorConfig.DontShowAsteriskForEmptyFields) return; + Dictionary dHiddenColumns = new Dictionary(); + for (int i = 0; i < KeePass.Program.Config.MainWindow.EntryListColumns.Count; i++) + { + var col = KeePass.Program.Config.MainWindow.EntryListColumns[i]; + if (!col.HideWithAsterisks) continue; + dHiddenColumns[i] = new CP_ColumnType(col); + } + + if (dHiddenColumns.Count == 0) return; + + ListView lv = (ListView)Tools.GetControl("m_lvEntries"); + if (lv == null) + { + PluginDebug.AddError("Could not find m_lvEntries", 0); + return; + } + + try + { + lv.BeginUpdate(); + + for (int i = lv.Items.Count - 1; i >= 0; i--) + { + ListViewItem lvi = null; + PwListItem li = null; + try + { + //This can throw if multiple concurrent changes are in progress + //Can happen when e. g. doing Edit Entries (quick) - Expire npw + lvi = lv.Items[i]; + li = (lvi.Tag as PwListItem); + } + catch { } + if (li == null) continue; + + if (li.Entry == null) + { + PluginDebug.AddError("List entry does not contain valid PwEntry", 0, lvi.Text); + continue; //should never happen but on the other side... you never know + } + + foreach (var col in dHiddenColumns) + { + if (lvi.SubItems[col.Key].Text != PwDefs.HiddenPassword) continue; + if (col.Value.IsEmpty(li.Entry)) lvi.SubItems[col.Key].Text = string.Empty; + } + } + } + catch (Exception ex) + { + bool bDM = PluginDebug.DebugMode; + PluginDebug.DebugMode = true; + PluginDebug.AddError("Exception during OnUIStateUpdate", -1, ex.Message, ex.Source, ex.StackTrace); + PluginDebug.DebugMode = bDM; + } + finally + { + if (lv != null) lv.EndUpdate(); + } + } + + private void MainWindow_FormLoadPost(object sender, EventArgs e) { m_host.MainWindow.FormLoadPost -= MainWindow_FormLoadPost; @@ -396,6 +463,7 @@ private void OptionsForm_Shown(object sender, EventArgs e) o.cbSyncColorsWithPrintForm.Checked = ColorConfig.SyncColorsWithPrintForm; o.cbSinglePwDisplay.Checked = ColorConfig.SinglePwDisplayActive; o.cbColorPwGen.Checked = ColorConfig.ColorPwGen; + o.cbDontShowAsterisk.Checked = ColorConfig.DontShowAsteriskForEmptyFields; o.ctbExample.ColorText(); ColorConfig.Testmode = true; } @@ -425,6 +493,7 @@ private void OptionsClosed(object sender, Tools.OptionsFormsEventArgs e) ColorConfig.SyncColorsWithPrintForm = o.cbSyncColorsWithPrintForm.Checked; SinglePwDisplay.Enabled = ColorConfig.SinglePwDisplayActive = o.cbSinglePwDisplay.Checked; ColorConfig.ColorPwGen = o.cbColorPwGen.Checked; + ColorConfig.DontShowAsteriskForEmptyFields = o.cbDontShowAsterisk.Checked; ColorConfig.Write(); if (ColorConfig.Active) ColorPasswords(ColorConfig.Active); } diff --git a/src/Options.Designer.cs b/src/Options.Designer.cs index 5c72c3d..5c7f80f 100644 --- a/src/Options.Designer.cs +++ b/src/Options.Designer.cs @@ -52,23 +52,24 @@ private void InitializeComponent() this.bForeColorSpecial = new System.Windows.Forms.Button(); this.bBackColorSpecial = new System.Windows.Forms.Button(); this.tpAdvanced = new System.Windows.Forms.TabPage(); + this.gSyncColorsWithPrintForm = new System.Windows.Forms.GroupBox(); + this.cbSyncColorsWithPrintForm = new System.Windows.Forms.CheckBox(); this.gPasswordGenerator = new System.Windows.Forms.GroupBox(); this.cbColorPwGen = new System.Windows.Forms.CheckBox(); this.gEntryView = new System.Windows.Forms.GroupBox(); + this.cbDontShowAsterisk = new System.Windows.Forms.CheckBox(); this.cbSinglePwDisplay = new System.Windows.Forms.CheckBox(); this.cbColorEntryViewKeepBackgroundColor = new System.Windows.Forms.CheckBox(); this.cbColorEntryView = new System.Windows.Forms.CheckBox(); - this.gSyncColorsWithPrintForm = new System.Windows.Forms.GroupBox(); - this.cbSyncColorsWithPrintForm = new System.Windows.Forms.CheckBox(); this.gExample.SuspendLayout(); this.pError.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tpSettings.SuspendLayout(); this.cgActive.SuspendLayout(); this.tpAdvanced.SuspendLayout(); + this.gSyncColorsWithPrintForm.SuspendLayout(); this.gPasswordGenerator.SuspendLayout(); this.gEntryView.SuspendLayout(); - this.gSyncColorsWithPrintForm.SuspendLayout(); this.SuspendLayout(); // // gExample @@ -78,7 +79,7 @@ private void InitializeComponent() this.gExample.AutoSize = true; this.gExample.Controls.Add(this.ctbExample); this.gExample.Location = new System.Drawing.Point(5, 315); - this.gExample.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.gExample.Margin = new System.Windows.Forms.Padding(5); this.gExample.Name = "gExample"; this.gExample.Padding = new System.Windows.Forms.Padding(0); this.gExample.Size = new System.Drawing.Size(1428, 132); @@ -106,7 +107,7 @@ private void InitializeComponent() this.pError.Controls.Add(this.lError2); this.pError.Controls.Add(this.lError); this.pError.Location = new System.Drawing.Point(5, 428); - this.pError.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.pError.Margin = new System.Windows.Forms.Padding(5); this.pError.Name = "pError"; this.pError.Padding = new System.Windows.Forms.Padding(18, 8, 18, 8); this.pError.Size = new System.Drawing.Size(1428, 95); @@ -143,7 +144,7 @@ private void InitializeComponent() this.tabControl1.Controls.Add(this.tpSettings); this.tabControl1.Controls.Add(this.tpAdvanced); this.tabControl1.Location = new System.Drawing.Point(0, 0); - this.tabControl1.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.tabControl1.Margin = new System.Windows.Forms.Padding(5); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(1452, 620); @@ -155,9 +156,9 @@ private void InitializeComponent() this.tpSettings.Controls.Add(this.gExample); this.tpSettings.Controls.Add(this.cgActive); this.tpSettings.Location = new System.Drawing.Point(10, 48); - this.tpSettings.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.tpSettings.Margin = new System.Windows.Forms.Padding(5); this.tpSettings.Name = "tpSettings"; - this.tpSettings.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.tpSettings.Padding = new System.Windows.Forms.Padding(5); this.tpSettings.Size = new System.Drawing.Size(1432, 562); this.tpSettings.TabIndex = 0; this.tpSettings.Text = "Settings"; @@ -180,9 +181,9 @@ private void InitializeComponent() this.cgActive.Controls.Add(this.bForeColorSpecial); this.cgActive.Controls.Add(this.bBackColorSpecial); this.cgActive.Location = new System.Drawing.Point(5, 5); - this.cgActive.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.cgActive.Margin = new System.Windows.Forms.Padding(5); this.cgActive.Name = "cgActive"; - this.cgActive.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.cgActive.Padding = new System.Windows.Forms.Padding(5); this.cgActive.Size = new System.Drawing.Size(1428, 310); this.cgActive.TabIndex = 0; this.cgActive.Text = "cgActive"; @@ -202,7 +203,7 @@ private void InitializeComponent() // this.bForeColorDefault.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bForeColorDefault.Location = new System.Drawing.Point(996, 34); - this.bForeColorDefault.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bForeColorDefault.Margin = new System.Windows.Forms.Padding(5); this.bForeColorDefault.Name = "bForeColorDefault"; this.bForeColorDefault.Size = new System.Drawing.Size(68, 53); this.bForeColorDefault.TabIndex = 15; @@ -214,7 +215,7 @@ private void InitializeComponent() // this.bBackColorDefault.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bBackColorDefault.Location = new System.Drawing.Point(1259, 34); - this.bBackColorDefault.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bBackColorDefault.Margin = new System.Windows.Forms.Padding(5); this.bBackColorDefault.Name = "bBackColorDefault"; this.bBackColorDefault.Size = new System.Drawing.Size(68, 53); this.bBackColorDefault.TabIndex = 17; @@ -237,7 +238,7 @@ private void InitializeComponent() // this.bForeColorLower.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bForeColorLower.Location = new System.Drawing.Point(996, 96); - this.bForeColorLower.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bForeColorLower.Margin = new System.Windows.Forms.Padding(5); this.bForeColorLower.Name = "bForeColorLower"; this.bForeColorLower.Size = new System.Drawing.Size(68, 53); this.bForeColorLower.TabIndex = 16; @@ -249,7 +250,7 @@ private void InitializeComponent() // this.bBackColorLower.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bBackColorLower.Location = new System.Drawing.Point(1259, 96); - this.bBackColorLower.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bBackColorLower.Margin = new System.Windows.Forms.Padding(5); this.bBackColorLower.Name = "bBackColorLower"; this.bBackColorLower.Size = new System.Drawing.Size(68, 53); this.bBackColorLower.TabIndex = 18; @@ -271,7 +272,7 @@ private void InitializeComponent() // this.bForeColorDigit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bForeColorDigit.Location = new System.Drawing.Point(996, 158); - this.bForeColorDigit.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bForeColorDigit.Margin = new System.Windows.Forms.Padding(5); this.bForeColorDigit.Name = "bForeColorDigit"; this.bForeColorDigit.Size = new System.Drawing.Size(68, 53); this.bForeColorDigit.TabIndex = 19; @@ -283,7 +284,7 @@ private void InitializeComponent() // this.bBackColorDigit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bBackColorDigit.Location = new System.Drawing.Point(1259, 158); - this.bBackColorDigit.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bBackColorDigit.Margin = new System.Windows.Forms.Padding(5); this.bBackColorDigit.Name = "bBackColorDigit"; this.bBackColorDigit.Size = new System.Drawing.Size(68, 53); this.bBackColorDigit.TabIndex = 20; @@ -305,7 +306,7 @@ private void InitializeComponent() // this.bForeColorSpecial.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bForeColorSpecial.Location = new System.Drawing.Point(996, 220); - this.bForeColorSpecial.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bForeColorSpecial.Margin = new System.Windows.Forms.Padding(5); this.bForeColorSpecial.Name = "bForeColorSpecial"; this.bForeColorSpecial.Size = new System.Drawing.Size(68, 53); this.bForeColorSpecial.TabIndex = 21; @@ -317,7 +318,7 @@ private void InitializeComponent() // this.bBackColorSpecial.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.bBackColorSpecial.Location = new System.Drawing.Point(1259, 220); - this.bBackColorSpecial.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.bBackColorSpecial.Margin = new System.Windows.Forms.Padding(5); this.bBackColorSpecial.Name = "bBackColorSpecial"; this.bBackColorSpecial.Size = new System.Drawing.Size(68, 53); this.bBackColorSpecial.TabIndex = 22; @@ -331,21 +332,44 @@ private void InitializeComponent() this.tpAdvanced.Controls.Add(this.gPasswordGenerator); this.tpAdvanced.Controls.Add(this.gEntryView); this.tpAdvanced.Location = new System.Drawing.Point(10, 48); - this.tpAdvanced.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.tpAdvanced.Margin = new System.Windows.Forms.Padding(5); this.tpAdvanced.Name = "tpAdvanced"; - this.tpAdvanced.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.tpAdvanced.Padding = new System.Windows.Forms.Padding(5); this.tpAdvanced.Size = new System.Drawing.Size(1432, 562); this.tpAdvanced.TabIndex = 1; this.tpAdvanced.Text = "Advanced"; this.tpAdvanced.UseVisualStyleBackColor = true; // + // gSyncColorsWithPrintForm + // + this.gSyncColorsWithPrintForm.Controls.Add(this.cbSyncColorsWithPrintForm); + this.gSyncColorsWithPrintForm.Location = new System.Drawing.Point(5, 290); + this.gSyncColorsWithPrintForm.Margin = new System.Windows.Forms.Padding(5); + this.gSyncColorsWithPrintForm.Name = "gSyncColorsWithPrintForm"; + this.gSyncColorsWithPrintForm.Padding = new System.Windows.Forms.Padding(5); + this.gSyncColorsWithPrintForm.Size = new System.Drawing.Size(1428, 85); + this.gSyncColorsWithPrintForm.TabIndex = 7; + this.gSyncColorsWithPrintForm.TabStop = false; + this.gSyncColorsWithPrintForm.Text = "Sync with print form"; + // + // cbSyncColorsWithPrintForm + // + this.cbSyncColorsWithPrintForm.AutoSize = true; + this.cbSyncColorsWithPrintForm.Location = new System.Drawing.Point(18, 34); + this.cbSyncColorsWithPrintForm.Margin = new System.Windows.Forms.Padding(5); + this.cbSyncColorsWithPrintForm.Name = "cbSyncColorsWithPrintForm"; + this.cbSyncColorsWithPrintForm.Size = new System.Drawing.Size(300, 36); + this.cbSyncColorsWithPrintForm.TabIndex = 5; + this.cbSyncColorsWithPrintForm.Text = "Sync with print form"; + this.cbSyncColorsWithPrintForm.UseVisualStyleBackColor = true; + // // gPasswordGenerator // this.gPasswordGenerator.Controls.Add(this.cbColorPwGen); - this.gPasswordGenerator.Location = new System.Drawing.Point(5, 165); - this.gPasswordGenerator.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.gPasswordGenerator.Location = new System.Drawing.Point(5, 205); + this.gPasswordGenerator.Margin = new System.Windows.Forms.Padding(5); this.gPasswordGenerator.Name = "gPasswordGenerator"; - this.gPasswordGenerator.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.gPasswordGenerator.Padding = new System.Windows.Forms.Padding(5); this.gPasswordGenerator.Size = new System.Drawing.Size(1428, 85); this.gPasswordGenerator.TabIndex = 6; this.gPasswordGenerator.TabStop = false; @@ -355,7 +379,7 @@ private void InitializeComponent() // this.cbColorPwGen.AutoSize = true; this.cbColorPwGen.Location = new System.Drawing.Point(18, 34); - this.cbColorPwGen.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.cbColorPwGen.Margin = new System.Windows.Forms.Padding(5); this.cbColorPwGen.Name = "cbColorPwGen"; this.cbColorPwGen.Size = new System.Drawing.Size(473, 36); this.cbColorPwGen.TabIndex = 5; @@ -364,26 +388,41 @@ private void InitializeComponent() // // gEntryView // + this.gEntryView.Controls.Add(this.cbDontShowAsterisk); this.gEntryView.Controls.Add(this.cbSinglePwDisplay); this.gEntryView.Controls.Add(this.cbColorEntryViewKeepBackgroundColor); this.gEntryView.Controls.Add(this.cbColorEntryView); this.gEntryView.Location = new System.Drawing.Point(5, 5); - this.gEntryView.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.gEntryView.Margin = new System.Windows.Forms.Padding(5); this.gEntryView.Name = "gEntryView"; - this.gEntryView.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); - this.gEntryView.Size = new System.Drawing.Size(1428, 160); + this.gEntryView.Padding = new System.Windows.Forms.Padding(5); + this.gEntryView.Size = new System.Drawing.Size(1428, 200); this.gEntryView.TabIndex = 5; this.gEntryView.TabStop = false; + this.gEntryView.Tag = "KEEPENABLED"; this.gEntryView.Text = "Entry list"; // + // cbDontShowAsterisk + // + this.cbDontShowAsterisk.AutoSize = true; + this.cbDontShowAsterisk.Location = new System.Drawing.Point(18, 142); + this.cbDontShowAsterisk.Margin = new System.Windows.Forms.Padding(5); + this.cbDontShowAsterisk.Name = "cbDontShowAsterisk"; + this.cbDontShowAsterisk.Size = new System.Drawing.Size(509, 36); + this.cbDontShowAsterisk.TabIndex = 7; + this.cbDontShowAsterisk.Tag = "KEEPENABLED"; + this.cbDontShowAsterisk.Text = "Don\'t show asterisks for empty fields"; + this.cbDontShowAsterisk.UseVisualStyleBackColor = true; + // // cbSinglePwDisplay // this.cbSinglePwDisplay.AutoSize = true; this.cbSinglePwDisplay.Location = new System.Drawing.Point(18, 108); - this.cbSinglePwDisplay.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.cbSinglePwDisplay.Margin = new System.Windows.Forms.Padding(5); this.cbSinglePwDisplay.Name = "cbSinglePwDisplay"; this.cbSinglePwDisplay.Size = new System.Drawing.Size(429, 36); this.cbSinglePwDisplay.TabIndex = 6; + this.cbSinglePwDisplay.Tag = "KEEPENABLED"; this.cbSinglePwDisplay.Text = "Single click password to show"; this.cbSinglePwDisplay.UseVisualStyleBackColor = true; // @@ -391,7 +430,7 @@ private void InitializeComponent() // this.cbColorEntryViewKeepBackgroundColor.AutoSize = true; this.cbColorEntryViewKeepBackgroundColor.Location = new System.Drawing.Point(18, 71); - this.cbColorEntryViewKeepBackgroundColor.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.cbColorEntryViewKeepBackgroundColor.Margin = new System.Windows.Forms.Padding(5); this.cbColorEntryViewKeepBackgroundColor.Name = "cbColorEntryViewKeepBackgroundColor"; this.cbColorEntryViewKeepBackgroundColor.Size = new System.Drawing.Size(479, 36); this.cbColorEntryViewKeepBackgroundColor.TabIndex = 4; @@ -402,43 +441,20 @@ private void InitializeComponent() // this.cbColorEntryView.AutoSize = true; this.cbColorEntryView.Location = new System.Drawing.Point(18, 34); - this.cbColorEntryView.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.cbColorEntryView.Margin = new System.Windows.Forms.Padding(5); this.cbColorEntryView.Name = "cbColorEntryView"; this.cbColorEntryView.Size = new System.Drawing.Size(255, 36); this.cbColorEntryView.TabIndex = 5; this.cbColorEntryView.Text = "Color entry view"; this.cbColorEntryView.UseVisualStyleBackColor = true; // - // gSyncColorsWithPrintForm - // - this.gSyncColorsWithPrintForm.Controls.Add(this.cbSyncColorsWithPrintForm); - this.gSyncColorsWithPrintForm.Location = new System.Drawing.Point(5, 250); - this.gSyncColorsWithPrintForm.Margin = new System.Windows.Forms.Padding(5); - this.gSyncColorsWithPrintForm.Name = "gSyncColorsWithPrintForm"; - this.gSyncColorsWithPrintForm.Padding = new System.Windows.Forms.Padding(5); - this.gSyncColorsWithPrintForm.Size = new System.Drawing.Size(1428, 85); - this.gSyncColorsWithPrintForm.TabIndex = 7; - this.gSyncColorsWithPrintForm.TabStop = false; - this.gSyncColorsWithPrintForm.Text = "Sync with print form"; - // - // cbSyncColorsWithPrintForm - // - this.cbSyncColorsWithPrintForm.AutoSize = true; - this.cbSyncColorsWithPrintForm.Location = new System.Drawing.Point(18, 34); - this.cbSyncColorsWithPrintForm.Margin = new System.Windows.Forms.Padding(5); - this.cbSyncColorsWithPrintForm.Name = "cbSyncColorsWithPrintForm"; - this.cbSyncColorsWithPrintForm.Size = new System.Drawing.Size(300, 36); - this.cbSyncColorsWithPrintForm.TabIndex = 5; - this.cbSyncColorsWithPrintForm.Text = "Sync with print form"; - this.cbSyncColorsWithPrintForm.UseVisualStyleBackColor = true; - // // Options // this.AutoScaleDimensions = new System.Drawing.SizeF(16F, 31F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScroll = true; this.Controls.Add(this.tabControl1); - this.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.Margin = new System.Windows.Forms.Padding(5); this.Name = "Options"; this.Size = new System.Drawing.Size(1452, 693); this.Resize += new System.EventHandler(this.Options_Resize); @@ -451,12 +467,12 @@ private void InitializeComponent() this.cgActive.ResumeLayout(false); this.cgActive.PerformLayout(); this.tpAdvanced.ResumeLayout(false); + this.gSyncColorsWithPrintForm.ResumeLayout(false); + this.gSyncColorsWithPrintForm.PerformLayout(); this.gPasswordGenerator.ResumeLayout(false); this.gPasswordGenerator.PerformLayout(); this.gEntryView.ResumeLayout(false); this.gEntryView.PerformLayout(); - this.gSyncColorsWithPrintForm.ResumeLayout(false); - this.gSyncColorsWithPrintForm.PerformLayout(); this.ResumeLayout(false); } @@ -493,5 +509,6 @@ private void InitializeComponent() internal System.Windows.Forms.Button bBackColorSpecial; private System.Windows.Forms.GroupBox gSyncColorsWithPrintForm; internal System.Windows.Forms.CheckBox cbSyncColorsWithPrintForm; - } + internal System.Windows.Forms.CheckBox cbDontShowAsterisk; + } } diff --git a/src/Options.cs b/src/Options.cs index 1c317ec..e0d4877 100644 --- a/src/Options.cs +++ b/src/Options.cs @@ -46,6 +46,8 @@ public Options() gSyncColorsWithPrintForm.Text = KeePass.Resources.KPRes.Print; cbSyncColorsWithPrintForm.Text = PluginTranslate.SyncColors; + + cbDontShowAsterisk.Text = string.Format(PluginTranslate.DontShowAsterisks, KeePass.Resources.KPRes.HideUsingAsterisks); } private void OnColorSelect(object sender, EventArgs e) @@ -80,7 +82,17 @@ private void cbLowercase_CheckedChanged(object sender, EventArgs e) private void cgActive_CheckedChanged(object sender, RookieUI.CheckedGroupCheckEventArgs e) { - foreach (Control c in tpAdvanced.Controls) c.Enabled = cgActive.Checked; + foreach (Control c in tpAdvanced.Controls) + { + if (c.Tag is string && ((string)c.Tag != "KEEPENABLED")) c.Enabled = cgActive.Checked; + else + { + foreach (Control c2 in c.Controls) + { + if (c2.Tag is string && ((string)c.Tag != "KEEPENABLED")) c2.Enabled = cgActive.Checked; + } + } + } if (PluginTools.Tools.KeePassVersion < ColorConfig.KP_2_51) gSyncColorsWithPrintForm.Enabled = false; } } diff --git a/src/PluginTranslation.cs b/src/PluginTranslation.cs index 0c81375..2a44563 100644 --- a/src/PluginTranslation.cs +++ b/src/PluginTranslation.cs @@ -75,6 +75,10 @@ public static class PluginTranslate /// Snychronize font colors /// public static readonly string SyncColors = @"Snychronize font colors"; + /// + /// Don't show asterisks for empty fields if '{0}' is active + /// + public static readonly string DontShowAsterisks = @"Don't show asterisks for empty fields if '{0}' is active"; #endregion #region NO changes in this area diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 5585be5..b27d491 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("rookiestyle")] [assembly: AssemblyProduct("KeePass Plugin")] -[assembly: AssemblyCopyright("Copyright © 2020-2023")] +[assembly: AssemblyCopyright("Copyright © 2020-2024")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.15.4")] -[assembly: AssemblyFileVersion("0.15.4")] +[assembly: AssemblyVersion("0.16")] +[assembly: AssemblyFileVersion("0.16")] diff --git a/src/Util.cs b/src/Util.cs index 3366953..dcfda30 100644 --- a/src/Util.cs +++ b/src/Util.cs @@ -5,6 +5,7 @@ using System.Text; using KeePass.App.Configuration; using KeePass.Plugins; +using KeePassLib; namespace ColoredPassword { @@ -24,6 +25,13 @@ public static bool SyncColorsWithPrintForm get { return m_Config.GetBool("ColoredPassword.SyncColorsWithPrintForm", true); } set { m_Config.SetBool("ColoredPassword.SyncColorsWithPrintForm", value); } } + + public static bool DontShowAsteriskForEmptyFields + { + get { return m_Config.GetBool("ColoredPassword.DontShowAsteriskForEmptyFields", false); } + set { m_Config.SetBool("ColoredPassword.DontShowAsteriskForEmptyFields", value); } + } + public static bool Testmode { get { return m_Testmode; } @@ -274,4 +282,43 @@ internal static Color ContrastColor(Color c) return l < 0.5 ? Color.White : Color.Black; } } + + class CP_ColumnType + { + private AceColumn m_ace = null; + + private string m_sField = null; + + public CP_ColumnType(AceColumn ace) + { + m_ace = ace; + if (m_ace == null) return; + switch (ace.Type) + { + case AceColumnType.Title: m_sField = PwDefs.TitleField; break; + case AceColumnType.UserName: m_sField = PwDefs.UserNameField; break; + case AceColumnType.Password: m_sField = PwDefs.PasswordField; break; + case AceColumnType.Url: m_sField = PwDefs.UrlField; break; + case AceColumnType.Notes: m_sField = PwDefs.NotesField; break; + case AceColumnType.CustomString: m_sField = m_ace.CustomName; break; + case AceColumnType.PluginExt: m_sField = m_ace.CustomName; break; + } + if (!string.IsNullOrEmpty(m_sField)) return; + + PluginTools.PluginDebug.AddWarning("Unsupported column for asterisk check: " + m_ace.Type.ToString() + + (string.IsNullOrEmpty(m_ace.CustomName) ? string.Empty : " - " + m_ace.CustomName), 0); + } + public bool IsEmpty(PwEntry pe) + { + if (m_ace == null) return false; + + if (m_sField == null) return false; + if (pe == null) return false; + + if (m_ace.Type != AceColumnType.PluginExt) return pe.Strings.GetSafe(m_sField).IsEmpty; + + return string.IsNullOrEmpty(KeePass.Program.ColumnProviderPool.GetCellData(m_sField, pe)); + } + } + } diff --git a/version.info b/version.info index a5d91dc..d6e8dfe 100644 --- a/version.info +++ b/version.info @@ -1,6 +1,6 @@ : -ColoredPassword:0.15.4 -ColoredPassword!de:7 +ColoredPassword:0.16 +ColoredPassword!de:8 ColoredPassword!pl:2 ColoredPassword!pt:3 ColoredPassword!ru:3