private void PCADialog_Load(object sender, EventArgs e) { //Create input control group for new password m_icgNewPassword.Attach(tbPasswordNew, cbToggleNewPassword, m_lblPasswordRepeat, tbPasswordNewRepeat, m_lblQuality, pbNewPasswordQuality, lNewPasswordQualityInfo, toolTip1, this, cbToggleNewPassword.Checked, false); m_icgNewPassword.ContextDatabase = Program.MainForm.DocumentManager.SafeFindContainerOf(PasswordChangeAssistantExt.SelectedEntry); m_icgNewPassword.ContextEntry = PasswordChangeAssistantExt.SelectedEntry; bool bForceHide = !AppPolicy.Current.UnhidePasswords; AceColumn colPw = Program.Config.MainWindow.FindColumn(AceColumnType.Password); bool bShowPassword = (colPw != null) ? !colPw.HideWithAsterisks : false; bShowPassword &= !bForceHide; if (Program.Config.UI.Hiding.SeparateHidingSettings) { cbToggleNewPassword.Checked = (Program.Config.UI.Hiding.HideInEntryWindow || bForceHide); } else { cbToggleNewPassword.Checked = !bShowPassword; } cbToggleOldPassword.Checked = cbToggleNewPassword.Checked; tbPasswordOld.EnableProtection(cbToggleOldPassword.Checked); cbToggleOldPassword.Image = cbToggleNewPassword.Image; cbToggleOldPassword.Text = string.Empty; tbPasswordOld.ReadOnly = true; }
private void Lv_DrawItem(object sender, DrawListViewItemEventArgs e) { AceColumn colPw = KeePass.Program.Config.MainWindow.FindColumn(AceColumnType.Password); string m = string.Empty; if (((colPw == null) || colPw.HideWithAsterisks) && !SinglePwDisplay.PasswordShown(e.Item)) { //Let the OS draw in case no other handlers exist //If other handlers exist, we pass their value for DrawDefault e.DrawDefault = true; if (colPw == null) { m = "Password column not found"; } else { m = "Password column found, password hidden"; } List <string> lCol = new List <string>(); foreach (var c in KeePass.Program.Config.MainWindow.EntryListColumns) { lCol.Add(c.GetDisplayName()); } PluginDebug.AddInfo(m, 0, lCol.ToArray()); return; } e.DrawDefault = false; m = "Password column found, password shown"; PluginDebug.AddSuccess(m, 0); if ((e.State & ListViewItemStates.Selected) != 0) { e.DrawFocusRectangle(); } }
private void UpdateColumnPropInfo() { ListView.SelectedListViewItemCollection lvsic = m_lvColumns.SelectedItems; if ((lvsic == null) || (lvsic.Count != 1) || (lvsic[0] == null)) { m_grpColumn.Text = KPRes.SelectedColumn + ": (" + KPRes.None + ")"; m_cbHide.Checked = false; m_cbHide.Enabled = false; } else { ListViewItem lvi = lvsic[0]; AceColumn c = (lvi.Tag as AceColumn); if (c == null) { Debug.Assert(false); return; } m_grpColumn.Text = KPRes.SelectedColumn + ": " + c.GetDisplayName(); m_cbHide.Enabled = true; m_bIgnoreHideCheckEvent = true; UIUtil.SetChecked(m_cbHide, c.HideWithAsterisks); m_bIgnoreHideCheckEvent = false; } }
private void OnBtnOK(object sender, EventArgs e) { AceMainWindow mw = Program.Config.MainWindow; List <AceColumn> l = mw.EntryListColumns; List <AceColumn> lOld = new List <AceColumn>(l); l.Clear(); foreach (ListViewItem lvi in m_lvColumns.Items) { if (!lvi.Checked) { continue; } AceColumn c = (lvi.Tag as AceColumn); if (c == null) { Debug.Assert(false); continue; } l.Add(c); } mw.EntryListColumnDisplayOrder = ComputeNewDisplayOrder(l, lOld, mw.EntryListColumnDisplayOrder); }
private void OnHideCheckedChanged(object sender, EventArgs e) { if (m_bIgnoreHideCheckEvent) { return; } bool bChecked = m_cbHide.Checked; foreach (ListViewItem lvi in m_lvColumns.SelectedItems) { AceColumn c = (lvi.Tag as AceColumn); if (c == null) { Debug.Assert(false); continue; } if ((c.Type == AceColumnType.Password) && c.HideWithAsterisks && !AppPolicy.Try(AppPolicyId.UnhidePasswords)) { // Do not change c.HideWithAsterisks } else { c.HideWithAsterisks = bChecked; } } UpdateListEx(false); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_psWord != null); if (m_psWord == null) { throw new InvalidOperationException(); } m_bFormLoaded = false; GlobalWindowManager.AddWindow(this); m_nFormHeight = this.Height; // Before restoring the position/size string strRect = Program.Config.UI.CharPickerRect; if (strRect.Length > 0) { UIUtil.SetWindowScreenRect(this, strRect); } m_strInitialFormRect = UIUtil.GetWindowScreenRect(this); m_fontChars = FontUtil.CreateFont("Tahoma", 8.25f, FontStyle.Bold); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.PickCharacters + " - " + PwDefs.ShortProductName; m_secWord.Attach(m_tbSelected, OnSelectedTextChangedEx, true); PwInputControlGroup.ConfigureHideButton(m_cbHideChars, null); AceColumn colPw = Program.Config.MainWindow.FindColumn(AceColumnType.Password); bool bHide = ((colPw != null) ? colPw.HideWithAsterisks : true); if (m_bInitHide.HasValue) { bHide = m_bInitHide.Value; } bHide |= !AppPolicy.Current.UnhidePasswords; m_cbHideChars.Checked = bHide; RecreateResizableWindowControls(); if (m_uCharCount > 0) { m_btnOK.Enabled = false; // m_btnOK.Visible = false; } if (m_bSetForeground) { this.BringToFront(); this.Activate(); } UIUtil.SetFocus(m_tbSelected, this); m_bFormLoaded = true; }
private void OnFormLoad(object sender, EventArgs e) { if (m_psWord == null) { Debug.Assert(false); throw new InvalidOperationException(); } // The password text box should not be focused by default // in order to avoid a Caps Lock warning tooltip bug; // https://sourceforge.net/p/keepass/bugs/1807/ Debug.Assert((m_pnlBottom.TabIndex == 0) && !m_tbSelected.Focused); m_bFormLoaded = false; GlobalWindowManager.AddWindow(this); m_nFormHeight = this.Height; // Before restoring the position/size m_strInitialFormRect = UIUtil.SetWindowScreenRectEx(this, Program.Config.UI.CharPickerRect); m_fontChars = FontUtil.CreateFont("Tahoma", 8.25f, FontStyle.Bold); this.Icon = AppIcons.Default; this.Text = KPRes.PickCharacters + " - " + PwDefs.ShortProductName; // Must be set manually due to possible object override m_tbSelected.TextChanged += this.OnSelectedTextChangedEx; PwInputControlGroup.ConfigureHideButton(m_cbHideChars, null); AceColumn colPw = Program.Config.MainWindow.FindColumn(AceColumnType.Password); bool bHide = ((colPw != null) ? colPw.HideWithAsterisks : true); if (m_bInitHide.HasValue) { bHide = m_bInitHide.Value; } bHide |= !AppPolicy.Current.UnhidePasswords; m_cbHideChars.Checked = bHide; RecreateResizableWindowControls(); if (m_uCharCount > 0) { m_btnOK.Enabled = false; // m_btnOK.Visible = false; } if (m_bSetForeground) { this.BringToFront(); this.Activate(); } m_bFormLoaded = true; }
private static int GetPwColumnIndex() { AceColumn c = KeePass.Program.Config.MainWindow.FindColumn(AceColumnType.Password); if (c == null || !c.HideWithAsterisks) { return(-1); } return(KeePass.Program.Config.MainWindow.EntryListColumns.IndexOf(c)); }
private static void OnTimerTick(object sender, EventArgs e) { if (!Enabled) { return; } AceColumn c = KeePass.Program.Config.MainWindow.FindColumn(AceColumnType.Password); bool bAll = (c == null || c.Type != AceColumnType.Password || !c.HideWithAsterisks); Clear(bAll); }
private void AddColumn(List <AceColumn> lColumns, AceColumnType ColType, bool hide) { AceColumn c = KeePass.Program.Config.MainWindow.EntryListColumns.Find(x => x.Type == ColType); if (c == null) { c = new AceColumn(ColType); c.HideWithAsterisks = hide; } else { c = new AceColumn(c.Type, c.CustomName, c.HideWithAsterisks, c.SafeGetWidth(1)); } lColumns.Add(c); }
private void UpdateListEx(bool bGuiToInternal) { if (bGuiToInternal) { } else // Internal to GUI { foreach (ListViewItem lvi in m_lvColumns.Items) { AceColumn c = (lvi.Tag as AceColumn); if (c == null) { Debug.Assert(false); continue; } string str = (c.HideWithAsterisks ? KPRes.Yes : KPRes.No); lvi.SubItems[1].Text = str; } } }
private void OnShowListviewForm(object sender, EventArgs e) { if (Config.PasswordDisplay == Config.PasswordDisplayMode.Always) { return; } if (Config.PasswordDisplay == Config.PasswordDisplayMode.EntryviewBased) { AceColumn c = KeePass.Program.Config.MainWindow.EntryListColumns.Where(x => x.Type == AceColumnType.Password).FirstOrDefault(); if (c != null && !c.HideWithAsterisks) { return; } } var lv = (sender as Form).Controls.OfType <ListView>().ToList().FirstOrDefault(); if (lv == null) { return; } ColumnHeader h = null; foreach (ColumnHeader x in lv.Columns) { if (x.Text == KPRes.Password) { h = x; break; } } if (h == null) { return; } foreach (ListViewItem x in lv.Items) { x.SubItems[h.Index].Text = PwDefs.HiddenPassword; } }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_psWord != null); if (m_psWord == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); m_nFormHeight = this.Height; m_fontChars = new Font("Tahoma", 8.25f, FontStyle.Bold); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.PickCharacters; m_secWord.Attach(m_tbSelected, OnSelectedTextChangedEx, true); AceColumn colPw = Program.Config.MainWindow.FindColumn(AceColumnType.Password); bool bHide = ((colPw != null) ? colPw.HideWithAsterisks : true); bHide |= !AppPolicy.Current.UnhidePasswords; m_cbHideChars.Checked = bHide; RecreateResizableWindowControls(); if (m_uCharCount > 0) { m_btnOK.Enabled = false; // m_btnOK.Visible = false; } if (m_bSetForeground) { this.BringToFront(); this.Activate(); } }
private void OnBtnOK(object sender, EventArgs e) { List <AceColumn> l = Program.Config.MainWindow.EntryListColumns; l.Clear(); foreach (ListViewItem lvi in m_lvColumns.Items) { if (!lvi.Checked) { continue; } AceColumn c = (lvi.Tag as AceColumn); if (c == null) { Debug.Assert(false); continue; } l.Add(c); } }
private void OnBtnAsterisks(object sender, EventArgs e) { foreach (ListViewItem lvi in m_lvColumns.SelectedItems) { AceColumn c = (lvi.Tag as AceColumn); if (c == null) { Debug.Assert(false); continue; } if ((c.Type == AceColumnType.Password) && c.HideWithAsterisks && !AppPolicy.Try(AppPolicyId.UnhidePasswords)) { } else { c.HideWithAsterisks = !c.HideWithAsterisks; } } UpdateListEx(false); }
private void AddAceColumnTh(AceColumn c) { string strLvgName = KPRes.StandardFields; if (c.Type == AceColumnType.CustomString) { strLvgName = KPRes.CustomFields; } else if (c.Type == AceColumnType.PluginExt) { strLvgName = KPRes.PluginProvided; } else if ((int)c.Type > (int)AceColumnType.PluginExt) { strLvgName = KPRes.More; } ListViewGroup lvgContainer = null; foreach (ListViewGroup lvg in m_lvColumns.Groups) { if (lvg.Header == strLvgName) { lvgContainer = lvg; break; } } if (lvgContainer == null) { lvgContainer = new ListViewGroup(strLvgName); m_lvColumns.Groups.Add(lvgContainer); } ListViewItem lvi = new ListViewItem(c.GetDisplayName()); lvi.Tag = c; lvi.SubItems.Add(c.HideWithAsterisks ? KPRes.Yes : KPRes.No); if (c.Type == AceColumnType.Password) { lvi.SubItems.Add(KPRes.KeyboardKeyCtrl + "+H"); } else if (c.Type == AceColumnType.UserName) { lvi.SubItems.Add(KPRes.KeyboardKeyCtrl + "+J"); } else { lvi.SubItems.Add(string.Empty); } bool bChecked = false; List <AceColumn> lCur = Program.Config.MainWindow.EntryListColumns; foreach (AceColumn cCur in lCur) { if (cCur.Type != c.Type) { continue; } if ((c.Type != AceColumnType.CustomString) && (c.Type != AceColumnType.PluginExt)) { bChecked = true; break; } else if ((c.Type == AceColumnType.CustomString) && (cCur.CustomName == c.CustomName)) { bChecked = true; break; } else if ((c.Type == AceColumnType.PluginExt) && (cCur.CustomName == c.CustomName)) { bChecked = true; break; } } lvi.Checked = bChecked; lvi.Group = lvgContainer; m_lvColumns.Items.Add(lvi); }
public AceColumnWithTag(AceColumn c, long lTag) { this.Column = c; this.TypeNameEx = c.GetTypeNameEx(); this.Tag = lTag; }
private void FillColumnsList(object state) { List <AceColumn> l = new List <AceColumn>(); AddStdAceColumn(l, AceColumnType.Title); AddStdAceColumn(l, AceColumnType.UserName); AddStdAceColumn(l, AceColumnType.Password); AddStdAceColumn(l, AceColumnType.Url); AddStdAceColumn(l, AceColumnType.Notes); AddStdAceColumn(l, AceColumnType.CreationTime); if ((Program.Config.UI.UIFlags & (ulong)AceUIFlags.ShowLastAccessTime) != 0) { AddStdAceColumn(l, AceColumnType.LastAccessTime); } AddStdAceColumn(l, AceColumnType.LastModificationTime); AddStdAceColumn(l, AceColumnType.ExpiryTime); AddStdAceColumn(l, AceColumnType.Uuid); AddStdAceColumn(l, AceColumnType.Attachment); SortedDictionary <string, AceColumn> d = new SortedDictionary <string, AceColumn>(StrUtil.CaseIgnoreComparer); List <AceColumn> lCur = Program.Config.MainWindow.EntryListColumns; foreach (AceColumn cCur in lCur) { if ((cCur.Type == AceColumnType.CustomString) && !d.ContainsKey(cCur.CustomName)) { d[cCur.CustomName] = new AceColumn(AceColumnType.CustomString, cCur.CustomName, cCur.HideWithAsterisks, cCur.Width); } } foreach (PwDocument pwDoc in Program.MainForm.DocumentManager.Documents) { if (string.IsNullOrEmpty(pwDoc.LockedIoc.Path) && pwDoc.Database.IsOpen) { EntryHandler eh = delegate(PwEntry pe) { foreach (KeyValuePair <string, ProtectedString> kvp in pe.Strings) { if (PwDefs.IsStandardField(kvp.Key)) { continue; } if (d.ContainsKey(kvp.Key)) { continue; } d[kvp.Key] = new AceColumn(AceColumnType.CustomString, kvp.Key, kvp.Value.IsProtected, -1); } return(true); }; pwDoc.Database.RootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh); } } foreach (KeyValuePair <string, AceColumn> kvpCustom in d) { AddAceColumn(l, kvpCustom.Value); } AddStdAceColumn(l, AceColumnType.Size); AddStdAceColumn(l, AceColumnType.AttachmentCount); AddStdAceColumn(l, AceColumnType.HistoryCount); AddStdAceColumn(l, AceColumnType.OverrideUrl); AddStdAceColumn(l, AceColumnType.Tags); AddStdAceColumn(l, AceColumnType.ExpiryTimeDateOnly); AddStdAceColumn(l, AceColumnType.LastPasswordModTime); d.Clear(); // Add active plugin columns (including those of uninstalled plugins) foreach (AceColumn cCur in lCur) { if (cCur.Type != AceColumnType.PluginExt) { continue; } if (d.ContainsKey(cCur.CustomName)) { Debug.Assert(false); continue; } d[cCur.CustomName] = new AceColumn(AceColumnType.PluginExt, cCur.CustomName, cCur.HideWithAsterisks, cCur.Width); } // Add unused plugin columns string[] vPlgExtNames = Program.ColumnProviderPool.GetColumnNames(); foreach (string strPlgName in vPlgExtNames) { if (d.ContainsKey(strPlgName)) { continue; // Do not overwrite } d[strPlgName] = new AceColumn(AceColumnType.PluginExt, strPlgName, false, -1); } foreach (KeyValuePair <string, AceColumn> kvpExt in d) { AddAceColumn(l, kvpExt.Value); } // m_lvColumns.Invoke(new UpdateUIDelegate(UpdateListEx), false); }
private void AddAceColumn(List <AceColumn> lContainer, AceColumn c) { m_lvColumns.Invoke(new AceColumnDelegate(AddAceColumnTh), c); lContainer.Add(c); }
private string GetEntryFieldEx(PwEntry pe, int iColumnID, bool bAsterisksIfHidden) { List <AceColumn> l = Program.Config.MainWindow.EntryListColumns; if ((iColumnID < 0) || (iColumnID >= l.Count)) { Debug.Assert(false); return(string.Empty); } AceColumn col = l[iColumnID]; if (bAsterisksIfHidden && col.HideWithAsterisks) { return(PwDefs.HiddenPassword); } string str = string.Empty; switch (col.Type) { case AceColumnType.Title: str = pe.Strings.ReadSafe(PwDefs.TitleField); break; case AceColumnType.UserName: str = pe.Strings.ReadSafe(PwDefs.UserNameField); break; case AceColumnType.Password: str = pe.Strings.ReadSafe(PwDefs.PasswordField); break; case AceColumnType.Url: str = pe.Strings.ReadSafe(PwDefs.UrlField); break; case AceColumnType.Notes: str = pe.Strings.ReadSafe(PwDefs.NotesField); break; case AceColumnType.CreationTime: str = TimeUtil.ToDisplayString(pe.CreationTime); break; case AceColumnType.LastAccessTime: str = TimeUtil.ToDisplayString(pe.LastAccessTime); break; case AceColumnType.LastModificationTime: str = TimeUtil.ToDisplayString(pe.LastModificationTime); break; case AceColumnType.ExpiryTime: if (pe.Expires) { str = TimeUtil.ToDisplayString(pe.ExpiryTime); } else { str = KPRes.NeverExpires; } break; case AceColumnType.Uuid: str = pe.Uuid.ToHexString(); break; case AceColumnType.Attachment: str = pe.Binaries.KeysToString(); break; case AceColumnType.CustomString: str = pe.Strings.ReadSafe(col.CustomName); break; case AceColumnType.PluginExt: str = Program.ColumnProviderPool.GetCellData(col.CustomName, pe); break; case AceColumnType.OverrideUrl: str = pe.OverrideUrl; break; case AceColumnType.Tags: str = StrUtil.TagsToString(pe.Tags, true); break; case AceColumnType.ExpiryTimeDateOnly: if (pe.Expires) { str = TimeUtil.ToDisplayStringDateOnly(pe.ExpiryTime); } else { str = KPRes.NeverExpires; } break; case AceColumnType.Size: str = StrUtil.FormatDataSizeKB(pe.GetSize()); break; case AceColumnType.HistoryCount: str = pe.History.UCount.ToString(); break; default: Debug.Assert(false); break; } return(str); }
/// <summary> /// Begin in-place editing of given cell /// </summary> /// <param name="c">Control used as cell editor</param> /// <param name="Item">ListViewItem to edit</param> /// <param name="SubItem">SubItem index to edit</param> private void StartEditing(PwEntry pe, ListViewItem Item, int SubItem, bool ContinueEdit) { mutEdit.WaitOne(); if (Item.Index == -1) { mutEdit.ReleaseMutex(); return; } //if (_editingControl != null) //{ // mutEdit.ReleaseMutex(); // return; //} m_host.MainWindow.EnsureVisibleEntry(pe.Uuid); Util.SelectEntry(pe, true, true); int colID = SubItem; AceColumn col = Util.GetAceColumn(colID); AceColumnType colType = col.Type; PaddedTextBox c = m_textBoxComment; // Only Title is the editable //TODO: status selection? if (colType != AceColumnType.Title) { mutEdit.ReleaseMutex(); return; } // Set Multiline property switch (colType) { case AceColumnType.Notes: case AceColumnType.CustomString: c.Multiline = true; break; case AceColumnType.PluginExt: //TODO c.Multiline = false; break; default: c.Multiline = false; break; } // Set editing allowed switch (colType) { case AceColumnType.CreationTime: case AceColumnType.LastAccessTime: case AceColumnType.LastModificationTime: case AceColumnType.ExpiryTime: case AceColumnType.Uuid: case AceColumnType.Attachment: case AceColumnType.ExpiryTimeDateOnly: case AceColumnType.Size: case AceColumnType.HistoryCount: // No editing allowed c.ReadOnly = true; break; case AceColumnType.PluginExt: //TODO No editing allowed c.ReadOnly = true; break; default: // Editing allowed c.ReadOnly = false; break; } // Read SubItem text and set textbox property // Read entry c.Text = Util.GetEntryFieldEx(pe, SubItem, false); // Set control location, bounding, padding SetEditBox(c, GetSubItemBounds(Item, SubItem), SubItem); //c.ScrollToTop(); c.SelectAll(); _editingControl = c; _editItem = Item; _editSubItem = SubItem; if (ContinueEdit == false) { //c.Invalidate(); c.Visible = true; c.BringToFront(); c.Select(); c.Focus(); m_host.MainWindow.EnsureVisibleEntry(pe.Uuid); } // Should be in the textbox c.Leave += new EventHandler(_editControl_Leave); c.LostFocus += new EventHandler(_editControl_LostFocus); c.KeyPress += new KeyPressEventHandler(_editControl_KeyPress); mutEdit.ReleaseMutex(); }
private void AddAceColumn(List <AceColumn> lContainer, AceColumn c) { m_lvColumns.Invoke(new GAction <AceColumn>(AddAceColumnTh), c); lContainer.Add(c); }
internal static string GetEntryFieldEx(PwEntry pe, int iColumnID, bool bFormatForDisplay) { // Adapted variables string m_strNeverExpiresText = KPRes.NeverExpires; List <AceColumn> l = Program.Config.MainWindow.EntryListColumns; if ((iColumnID < 0) || (iColumnID >= l.Count)) { Debug.Assert(false); return(string.Empty); } AceColumn col = l[iColumnID]; // TODO Optionally PasswordChar *** during editing for protected strings if (bFormatForDisplay && col.HideWithAsterisks) { return(PwDefs.HiddenPassword); } string str; switch (col.Type) { case AceColumnType.Title: str = pe.Strings.ReadSafe(PwDefs.TitleField); break; case AceColumnType.UserName: str = pe.Strings.ReadSafe(PwDefs.UserNameField); break; case AceColumnType.Password: str = pe.Strings.ReadSafe(PwDefs.PasswordField); break; case AceColumnType.Url: str = pe.Strings.ReadSafe(PwDefs.UrlField); break; case AceColumnType.Notes: if (!bFormatForDisplay) { str = pe.Strings.ReadSafe(PwDefs.NotesField); } else { str = StrUtil.MultiToSingleLine(pe.Strings.ReadSafe(PwDefs.NotesField)); } break; case AceColumnType.CreationTime: str = TimeUtil.ToDisplayString(pe.CreationTime); break; case AceColumnType.LastAccessTime: str = TimeUtil.ToDisplayString(pe.LastAccessTime); break; case AceColumnType.LastModificationTime: str = TimeUtil.ToDisplayString(pe.LastModificationTime); break; case AceColumnType.ExpiryTime: if (pe.Expires) { str = TimeUtil.ToDisplayString(pe.ExpiryTime); } else { str = m_strNeverExpiresText; } break; case AceColumnType.Uuid: str = pe.Uuid.ToHexString(); break; case AceColumnType.Attachment: str = pe.Binaries.KeysToString(); break; case AceColumnType.CustomString: if (!bFormatForDisplay) { str = pe.Strings.ReadSafe(col.CustomName); } else { str = StrUtil.MultiToSingleLine(pe.Strings.ReadSafe(col.CustomName)); } break; case AceColumnType.PluginExt: if (!bFormatForDisplay) { str = Program.ColumnProviderPool.GetCellData(col.CustomName, pe); } else { str = StrUtil.MultiToSingleLine(Program.ColumnProviderPool.GetCellData(col.CustomName, pe)); } break; case AceColumnType.OverrideUrl: str = pe.OverrideUrl; break; case AceColumnType.Tags: str = StrUtil.TagsToString(pe.Tags, true); break; case AceColumnType.ExpiryTimeDateOnly: if (pe.Expires) { str = TimeUtil.ToDisplayStringDateOnly(pe.ExpiryTime); } else { str = m_strNeverExpiresText; } break; case AceColumnType.Size: str = StrUtil.FormatDataSizeKB(pe.GetSize()); break; case AceColumnType.HistoryCount: str = pe.History.UCount.ToString(); break; default: Debug.Assert(false); str = string.Empty; break; } return(str); }
/* * // Get all user defined strings * internal static Dictionary<string, string> GetDictEntriesUserStrings(PwGroup pwg) * { * Dictionary<string, string> strd = new Dictionary<string, string>(); * //SortedDictionary<string, string> strd = new SortedDictionary<string, string>(); * * // Add all known pwentry strings * foreach (PwEntry pe in pwg.GetEntries(true)) * { * foreach (KeyValuePair<string, ProtectedString> pstr in pe.Strings) * { * if (!strd.ContainsKey(pstr.Key)) * { * if (!PwDefs.IsStandardField(pstr.Key)) * { * strd.Add(pstr.Key, pstr.Value.ReadString()); * } * } * } * } * * return strd; * }*/ // Ported from KeePass Entry Dialog SaveEntry() and UpdateEntryStrings(...) internal static bool SaveEntry(PwDatabase pwStorage, ListViewItem Item, int SubItem, string Text) { PwListItem pli = (((ListViewItem)Item).Tag as PwListItem); if (pli == null) { Debug.Assert(false); return(false); } PwEntry pe = pli.Entry; pe = pwStorage.RootGroup.FindEntry(pe.Uuid, true); PwEntry peInit = pe.CloneDeep(); pe.CreateBackup(null); pe.Touch(true, false); // Touch *after* backup int colID = SubItem; AceColumn col = GetAceColumn(colID); AceColumnType colType = col.Type; switch (colType) { case AceColumnType.Title: //if(PwDefs.IsTanEntry(pe)) //TODO tan list TanTitle ??? pe.Strings.Set(PwDefs.TanTitle, new ProtectedString(false, Text)); //else pe.Strings.Set(PwDefs.TitleField, new ProtectedString(pwStorage.MemoryProtection.ProtectTitle, Text)); break; case AceColumnType.UserName: pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(pwStorage.MemoryProtection.ProtectUserName, Text)); break; case AceColumnType.Password: //byte[] pb = Text.ToUtf8(); //pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(pwStorage.MemoryProtection.ProtectPassword, pb)); //MemUtil.ZeroByteArray(pb); pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(pwStorage.MemoryProtection.ProtectPassword, Text)); break; case AceColumnType.Url: pe.Strings.Set(PwDefs.UrlField, new ProtectedString(pwStorage.MemoryProtection.ProtectUrl, Text)); break; case AceColumnType.Notes: pe.Strings.Set(PwDefs.NotesField, new ProtectedString(pwStorage.MemoryProtection.ProtectNotes, Text)); break; case AceColumnType.OverrideUrl: pe.OverrideUrl = Text; break; case AceColumnType.Tags: List <string> vNewTags = StrUtil.StringToTags(Text); pe.Tags.Clear(); foreach (string strTag in vNewTags) { pe.AddTag(strTag); } break; case AceColumnType.CustomString: pe.Strings.Set(col.CustomName, new ProtectedString(pe.Strings.GetSafe(col.CustomName).IsProtected, Text)); break; default: // Nothing todo break; } PwCompareOptions cmpOpt = (PwCompareOptions.IgnoreLastMod | PwCompareOptions.IgnoreLastAccess | PwCompareOptions.IgnoreLastBackup); if (pe.EqualsEntry(peInit, cmpOpt, MemProtCmpMode.None)) { pe.LastModificationTime = peInit.LastModificationTime; pe.History.Remove(pe.History.GetAt(pe.History.UCount - 1)); // Undo backup return(false); } else { return(true); } }