private string GetEntryFieldEx(PwEntry pe, int iColumnID, bool bFormatForDisplay, out bool bRequestAsync) { List<AceColumn> l = Program.Config.MainWindow.EntryListColumns; if((iColumnID < 0) || (iColumnID >= l.Count)) { Debug.Assert(false); bRequestAsync = false; return string.Empty; } AceColumn col = l[iColumnID]; if(bFormatForDisplay && col.HideWithAsterisks) { bRequestAsync = false; 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.LastModificationTime: str = TimeUtil.ToDisplayString(pe.LastModificationTime); break; case AceColumnType.LastAccessTime: str = TimeUtil.ToDisplayString(pe.LastAccessTime); 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; case AceColumnType.AttachmentCount: uint uc = pe.Binaries.UCount; str = ((uc > 0) ? uc.ToString() : string.Empty); break; default: Debug.Assert(false); str = string.Empty; break; } if(Program.Config.MainWindow.EntryListShowDerefData) { switch(col.Type) { case AceColumnType.Title: case AceColumnType.UserName: case AceColumnType.Password: case AceColumnType.Url: case AceColumnType.Notes: case AceColumnType.CustomString: bRequestAsync = SprEngine.MightDeref(str); break; default: bRequestAsync = false; break; } if(!Program.Config.MainWindow.EntryListShowDerefDataAsync && bRequestAsync) { PwListItem pli = new PwListItem(pe); str = AsyncPwListUpdate.SprCompileFn(str, pli); bRequestAsync = false; } } else bRequestAsync = false; return str; }
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); }
private void PerformDefaultAction(object sender, EventArgs e, PwEntry pe, int colID) { Debug.Assert(pe != null); if(pe == null) return; if(this.DefaultEntryAction != null) { CancelEntryEventArgs args = new CancelEntryEventArgs(pe, colID); this.DefaultEntryAction(sender, args); if(args.Cancel) return; } bool bCnt = false; AceColumn col = GetAceColumn(colID); AceColumnType colType = col.Type; switch(colType) { case AceColumnType.Title: if(PwDefs.IsTanEntry(pe)) OnEntryCopyPassword(sender, e); else OnEntryEdit(sender, e); break; case AceColumnType.UserName: OnEntryCopyUserName(sender, e); break; case AceColumnType.Password: OnEntryCopyPassword(sender, e); break; case AceColumnType.Url: PerformDefaultUrlAction(null, false); break; case AceColumnType.Notes: bCnt = ClipboardUtil.CopyAndMinimize(pe.Strings.GetSafe( PwDefs.NotesField), true, this, pe, m_docMgr.ActiveDatabase); break; case AceColumnType.CreationTime: bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString( pe.CreationTime), true, this, pe, null); break; case AceColumnType.LastModificationTime: bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString( pe.LastModificationTime), true, this, pe, null); break; case AceColumnType.LastAccessTime: bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString( pe.LastAccessTime), true, this, pe, null); break; case AceColumnType.ExpiryTime: if(pe.Expires) bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayString( pe.ExpiryTime), true, this, pe, null); else bCnt = ClipboardUtil.CopyAndMinimize(m_strNeverExpiresText, true, this, pe, null); break; case AceColumnType.Attachment: case AceColumnType.AttachmentCount: PerformDefaultAttachmentAction(); break; case AceColumnType.Uuid: bCnt = ClipboardUtil.CopyAndMinimize(pe.Uuid.ToHexString(), true, this, pe, null); break; case AceColumnType.CustomString: bCnt = ClipboardUtil.CopyAndMinimize(pe.Strings.ReadSafe( col.CustomName), true, this, pe, m_docMgr.ActiveDatabase); break; case AceColumnType.PluginExt: if(Program.ColumnProviderPool.SupportsCellAction(col.CustomName)) Program.ColumnProviderPool.PerformCellAction(col.CustomName, pe); else bCnt = ClipboardUtil.CopyAndMinimize( Program.ColumnProviderPool.GetCellData(col.CustomName, pe), true, this, pe, m_docMgr.ActiveDatabase); break; case AceColumnType.OverrideUrl: bCnt = ClipboardUtil.CopyAndMinimize(pe.OverrideUrl, true, this, pe, null); break; case AceColumnType.Tags: bCnt = ClipboardUtil.CopyAndMinimize(StrUtil.TagsToString(pe.Tags, true), true, this, pe, null); break; case AceColumnType.ExpiryTimeDateOnly: if(pe.Expires) bCnt = ClipboardUtil.CopyAndMinimize(TimeUtil.ToDisplayStringDateOnly( pe.ExpiryTime), true, this, pe, null); else bCnt = ClipboardUtil.CopyAndMinimize(m_strNeverExpiresText, true, this, pe, null); break; case AceColumnType.Size: bCnt = ClipboardUtil.CopyAndMinimize(StrUtil.FormatDataSizeKB( pe.GetSize()), true, this, pe, null); break; case AceColumnType.HistoryCount: EditSelectedEntry(true); break; default: Debug.Assert(false); break; } if(bCnt) StartClipboardCountdown(); }
private string GetEntryFieldEx(PwEntry pe, int iColumnID, bool bFormatForDisplay) { IList<EntryColumn> columns = configuration.AvailableColumns; if ((iColumnID < 0) || (iColumnID >= columns.Count)) { return string.Empty; } EntryColumn col = columns[iColumnID]; // if (bFormatForDisplay && col.HideWithAsterisks) { //// bRequestAsync = false; // return PwDefs.HiddenPassword; // } string str; switch (col.ColumnType) { case ColumnType.Title: str = pe.Strings.ReadSafe (PwDefs.TitleField); break; case ColumnType.UserName: str = pe.Strings.ReadSafe (PwDefs.UserNameField); break; case ColumnType.Password: str = pe.Strings.ReadSafe (PwDefs.PasswordField); break; case ColumnType.Url: str = pe.Strings.ReadSafe (PwDefs.UrlField); break; case ColumnType.Notes: if (!bFormatForDisplay) str = pe.Strings.ReadSafe (PwDefs.NotesField); else str = StrUtil.MultiToSingleLine (pe.Strings.ReadSafe (PwDefs.NotesField)); break; case ColumnType.CreationTime: str = TimeUtil.ToDisplayString (pe.CreationTime); break; case ColumnType.LastAccessTime: str = TimeUtil.ToDisplayString (pe.LastAccessTime); break; case ColumnType.LastModificationTime: str = TimeUtil.ToDisplayString (pe.LastModificationTime); break; case ColumnType.ExpiryTime: if (pe.Expires) str = TimeUtil.ToDisplayString (pe.ExpiryTime); else str = ""; //m_strNeverExpiresText; break; case ColumnType.Uuid: str = pe.Uuid.ToHexString (); break; case ColumnType.Attachment: str = pe.Binaries.KeysToString (); break; // case ColumnType.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 ColumnType.OverrideUrl: str = pe.OverrideUrl; break; case ColumnType.Tags: str = StrUtil.TagsToString (pe.Tags, true); break; case ColumnType.ExpiryTimeDateOnly: if (pe.Expires) str = TimeUtil.ToDisplayStringDateOnly (pe.ExpiryTime); else str = ""; //m_strNeverExpiresText; break; case ColumnType.Size: str = StrUtil.FormatDataSizeKB (pe.GetSize ()); break; case ColumnType.HistoryCount: str = pe.History.UCount.ToString (); break; default: //Debug.Assert (false); str = string.Empty; break; } return str; }
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; }
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; }
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); }
private string GetEntryFieldEx(PwEntry pe, int iColumnID, bool bFormatForDisplay) { IList <EntryColumn> columns = configuration.AvailableColumns; if ((iColumnID < 0) || (iColumnID >= columns.Count)) { return(string.Empty); } EntryColumn col = columns[iColumnID]; // if (bFormatForDisplay && col.HideWithAsterisks) { //// bRequestAsync = false; // return PwDefs.HiddenPassword; // } string str; switch (col.ColumnType) { case ColumnType.Title: str = pe.Strings.ReadSafe(PwDefs.TitleField); break; case ColumnType.UserName: str = pe.Strings.ReadSafe(PwDefs.UserNameField); break; case ColumnType.Password: str = pe.Strings.ReadSafe(PwDefs.PasswordField); break; case ColumnType.Url: str = pe.Strings.ReadSafe(PwDefs.UrlField); break; case ColumnType.Notes: if (!bFormatForDisplay) { str = pe.Strings.ReadSafe(PwDefs.NotesField); } else { str = StrUtil.MultiToSingleLine(pe.Strings.ReadSafe(PwDefs.NotesField)); } break; case ColumnType.CreationTime: str = TimeUtil.ToDisplayString(pe.CreationTime); break; case ColumnType.LastAccessTime: str = TimeUtil.ToDisplayString(pe.LastAccessTime); break; case ColumnType.LastModificationTime: str = TimeUtil.ToDisplayString(pe.LastModificationTime); break; case ColumnType.ExpiryTime: if (pe.Expires) { str = TimeUtil.ToDisplayString(pe.ExpiryTime); } else { str = ""; //m_strNeverExpiresText; } break; case ColumnType.Uuid: str = pe.Uuid.ToHexString(); break; case ColumnType.Attachment: str = pe.Binaries.KeysToString(); break; // case ColumnType.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 ColumnType.OverrideUrl: str = pe.OverrideUrl; break; case ColumnType.Tags: str = StrUtil.TagsToString(pe.Tags, true); break; case ColumnType.ExpiryTimeDateOnly: if (pe.Expires) { str = TimeUtil.ToDisplayStringDateOnly(pe.ExpiryTime); } else { str = ""; //m_strNeverExpiresText; } break; case ColumnType.Size: str = StrUtil.FormatDataSizeKB(pe.GetSize()); break; case ColumnType.HistoryCount: str = pe.History.UCount.ToString(); break; default: //Debug.Assert (false); str = string.Empty; break; } return(str); }