public static HorizontalAlignment GetTextAlign(AceColumnType t) { if((t == AceColumnType.Size) || (t == AceColumnType.HistoryCount) || (t == AceColumnType.AttachmentCount)) return HorizontalAlignment.Right; return HorizontalAlignment.Left; }
public AceColumn(AceColumnType t, string strCustomName, bool bHide, int nWidth) { m_type = t; m_strCustomName = strCustomName; m_bHide = bHide; m_nWidth = nWidth; }
public static HorizontalAlignment GetTextAlign(AceColumnType t) { if ((t == AceColumnType.Size) || (t == AceColumnType.HistoryCount)) { return(HorizontalAlignment.Right); } return(HorizontalAlignment.Left); }
public bool IsColumnHidden(AceColumnType t, bool bDefault) { foreach(AceColumn c in m_aceColumns) { if(c.Type == t) return c.HideWithAsterisks; } return bDefault; }
public AceColumn FindColumn(AceColumnType t) { foreach(AceColumn c in m_aceColumns) { if(c.Type == t) return c; } return null; }
internal List<AceColumn> FindColumns(AceColumnType t) { List<AceColumn> l = new List<AceColumn>(); foreach(AceColumn c in m_aceColumns) { if(c.Type == t) l.Add(c); } return l; }
public bool IsColumnHidden(AceColumnType t, bool bDefault) { foreach (AceColumn c in m_lColumns) { if (c.Type == t) { return(c.HideWithAsterisks); } } return(bDefault); }
public AceColumn FindColumn(AceColumnType t) { foreach (AceColumn c in m_aceColumns) { if (c.Type == t) { return(c); } } return(null); }
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 AddStdAceColumn(List <AceColumn> lContainer, AceColumnType colType) { bool bHide = (colType == AceColumnType.Password); // Passwords hidden by default int nWidth = -1; List <AceColumn> lCur = Program.Config.MainWindow.EntryListColumns; foreach (AceColumn cCur in lCur) { if (cCur.Type == colType) { bHide = cCur.HideWithAsterisks; nWidth = cCur.Width; break; } } AddAceColumn(lContainer, new AceColumn(colType, string.Empty, bHide, nWidth)); }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pgDataSource != null); if (m_pgDataSource == null) { throw new ArgumentException(); } GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; CreateDialogBanner(); List <Image> lTabImg = new List <Image>(); lTabImg.Add(Properties.Resources.B16x16_XMag); lTabImg.Add(Properties.Resources.B16x16_Configure); m_ilTabIcons = UIUtil.BuildImageListUnscaled(lTabImg, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16)); m_tabMain.ImageList = m_ilTabIcons; m_tabPreview.ImageIndex = 0; m_tabDataLayout.ImageIndex = 1; UIUtil.SetButtonImage(m_btnConfigPrinter, Properties.Resources.B16x16_EditCopy, true); UIUtil.SetButtonImage(m_btnPrintPreview, Properties.Resources.B16x16_FileQuickPrint, true); FontUtil.AssignDefaultBold(m_rbTabular); FontUtil.AssignDefaultBold(m_rbDetails); if (!m_bPrintMode) { m_btnOK.Text = KPRes.Export; } m_bBlockPreviewRefresh = true; m_rbTabular.Checked = true; m_cmbSortEntries.Items.Add("(" + KPRes.None + ")"); m_cmbSortEntries.Items.Add(KPRes.Title); m_cmbSortEntries.Items.Add(KPRes.UserName); m_cmbSortEntries.Items.Add(KPRes.Password); m_cmbSortEntries.Items.Add(KPRes.Url); m_cmbSortEntries.Items.Add(KPRes.Notes); AceColumnType colType = AceColumnType.Count; List <AceColumn> vCols = Program.Config.MainWindow.EntryListColumns; if ((m_nDefaultSortColumn >= 0) && (m_nDefaultSortColumn < vCols.Count)) { colType = vCols[m_nDefaultSortColumn].Type; } int nSortSel = 0; if (colType == AceColumnType.Title) { nSortSel = 1; } else if (colType == AceColumnType.UserName) { nSortSel = 2; } else if (colType == AceColumnType.Password) { nSortSel = 3; } else if (colType == AceColumnType.Url) { nSortSel = 4; } else if (colType == AceColumnType.Notes) { nSortSel = 5; } m_cmbSortEntries.SelectedIndex = nSortSel; m_bBlockPreviewRefresh = false; if (!m_bPrintMode) // Export to HTML { m_btnConfigPrinter.Visible = m_btnPrintPreview.Visible = false; m_lblPreviewHint.Visible = false; } if (!NativeLib.IsUnix()) { // MSHTML may create and forget temporary files under // C:\\Users\\USER\\AppData\\Local\\Temp\\*.htm // (e.g. when printing fails); we delete these later Program.TempFilesPool.AddContent("*.htm", false); } UpdateHtmlDocument(); UpdateUIState(); }
public bool IsColumnHidden(AceColumnType t) { return(IsColumnHidden(t, (t == AceColumnType.Password))); }
private static void EntryListAddColumn(AceColumnType t, int nWidth, bool bHide) { AceColumn c = new AceColumn(t, string.Empty, bHide, nWidth); Program.Config.MainWindow.EntryListColumns.Add(c); }
private void ToggleFieldAsterisks(AceColumnType colType) { List<AceColumn> l = Program.Config.MainWindow.EntryListColumns; foreach(AceColumn c in l) { if(c.Type == colType) { if((colType == AceColumnType.Password) && c.HideWithAsterisks && !AppPolicy.Try(AppPolicyId.UnhidePasswords)) return; c.HideWithAsterisks = !c.HideWithAsterisks; } } RefreshEntriesList(); UpdateUIState(false); // Update entry view }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_pgDataSource != null); if (m_pgDataSource == null) { throw new ArgumentException(); } GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; CreateDialogBanner(); UIUtil.SetButtonImage(m_btnConfigPrinter, Properties.Resources.B16x16_EditCopy, true); UIUtil.SetButtonImage(m_btnPrintPreview, Properties.Resources.B16x16_FileQuickPrint, true); FontUtil.AssignDefaultBold(m_rbTabular); FontUtil.AssignDefaultBold(m_rbDetails); if (!m_bPrintMode) { m_btnOK.Text = KPRes.Export; } m_bBlockPreviewRefresh = true; m_rbTabular.Checked = true; m_cmbSortEntries.Items.Add("(" + KPRes.None + ")"); m_cmbSortEntries.Items.Add(KPRes.Title); m_cmbSortEntries.Items.Add(KPRes.UserName); m_cmbSortEntries.Items.Add(KPRes.Password); m_cmbSortEntries.Items.Add(KPRes.Url); m_cmbSortEntries.Items.Add(KPRes.Notes); AceColumnType colType = AceColumnType.Count; List <AceColumn> vCols = Program.Config.MainWindow.EntryListColumns; if ((m_nDefaultSortColumn >= 0) && (m_nDefaultSortColumn < vCols.Count)) { colType = vCols[m_nDefaultSortColumn].Type; } int nSortSel = 0; if (colType == AceColumnType.Title) { nSortSel = 1; } else if (colType == AceColumnType.UserName) { nSortSel = 2; } else if (colType == AceColumnType.Password) { nSortSel = 3; } else if (colType == AceColumnType.Url) { nSortSel = 4; } else if (colType == AceColumnType.Notes) { nSortSel = 5; } m_cmbSortEntries.SelectedIndex = nSortSel; m_bBlockPreviewRefresh = false; if (!m_bPrintMode) // Export to HTML { m_btnConfigPrinter.Visible = m_btnPrintPreview.Visible = false; m_lblPreviewHint.Visible = false; } UpdateHtmlDocument(); UpdateUIState(); }
public AceColumn(AceColumnType t) { m_type = t; }
private void AddStdAceColumn(List<AceColumn> lContainer, AceColumnType colType) { bool bHide = (colType == AceColumnType.Password); // Passwords hidden by default int nWidth = -1; List<AceColumn> lCur = Program.Config.MainWindow.EntryListColumns; foreach(AceColumn cCur in lCur) { if(cCur.Type == colType) { bHide = cCur.HideWithAsterisks; nWidth = cCur.Width; break; } } AddAceColumn(lContainer, new AceColumn(colType, string.Empty, bHide, nWidth)); }
public static HorizontalAlignment GetTextAlign(AceColumnType t) { if((t == AceColumnType.Size) || (t == AceColumnType.HistoryCount)) return HorizontalAlignment.Right; return HorizontalAlignment.Left; }
public static bool IsTimeColumn(AceColumnType t) { return ((t == AceColumnType.CreationTime) || (t == AceColumnType.LastAccessTime) || (t == AceColumnType.LastModificationTime) || (t == AceColumnType.ExpiryTime) || (t == AceColumnType.ExpiryTimeDateOnly)); }
/// <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 static bool IsColumnHidden(AceColumnType t) { List<AceColumn> l = Program.Config.MainWindow.EntryListColumns; bool bHidden = (t == AceColumnType.Password); foreach(AceColumn c in l) { if(c.Type == t) { bHidden = c.HideWithAsterisks; break; } } return bHidden; }
private void OnFormLoad(object sender, EventArgs e) { if (m_pgDataSource == null) { Debug.Assert(false); throw new InvalidOperationException(); } ++m_iBlockPreviewRefresh; GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; CreateDialogBanner(); List <Image> lTabImg = new List <Image>(); lTabImg.Add(Properties.Resources.B16x16_XMag); lTabImg.Add(Properties.Resources.B16x16_Configure); m_ilTabIcons = UIUtil.BuildImageListUnscaled(lTabImg, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16)); m_tabMain.ImageList = m_ilTabIcons; m_tabPreview.ImageIndex = 0; m_tabDataLayout.ImageIndex = 1; UIUtil.SetButtonImage(m_btnConfigPrinter, Properties.Resources.B16x16_EditCopy, true); UIUtil.SetButtonImage(m_btnPrintPreview, Properties.Resources.B16x16_FileQuickPrint, true); FontUtil.AssignDefaultBold(m_rbTabular); FontUtil.AssignDefaultBold(m_rbDetails); Debug.Assert(!m_cmbSpr.Sorted); m_cmbSpr.Items.Add(KPRes.ReplaceNo); m_cmbSpr.Items.Add(KPRes.Replace + " (" + KPRes.Slow + ")"); m_cmbSpr.Items.Add(KPRes.BothForms + " (" + KPRes.Slow + ")"); m_cmbSpr.SelectedIndex = 0; if (!m_bPrintMode) { m_btnOK.Text = KPRes.Export; } m_rbTabular.Checked = true; m_cmbSortEntries.Items.Add("(" + KPRes.None + ")"); m_cmbSortEntries.Items.Add(KPRes.Title); m_cmbSortEntries.Items.Add(KPRes.UserName); m_cmbSortEntries.Items.Add(KPRes.Password); m_cmbSortEntries.Items.Add(KPRes.Url); m_cmbSortEntries.Items.Add(KPRes.Notes); AceColumnType colType = AceColumnType.Count; List <AceColumn> vCols = Program.Config.MainWindow.EntryListColumns; if ((m_nDefaultSortColumn >= 0) && (m_nDefaultSortColumn < vCols.Count)) { colType = vCols[m_nDefaultSortColumn].Type; } int nSortSel = 0; if (colType == AceColumnType.Title) { nSortSel = 1; } else if (colType == AceColumnType.UserName) { nSortSel = 2; } else if (colType == AceColumnType.Password) { nSortSel = 3; } else if (colType == AceColumnType.Url) { nSortSel = 4; } else if (colType == AceColumnType.Notes) { nSortSel = 5; } m_cmbSortEntries.SelectedIndex = nSortSel; if (!m_bPrintMode) // Export to HTML { m_btnConfigPrinter.Visible = m_btnPrintPreview.Visible = false; m_lblPreviewHint.Visible = false; } Program.TempFilesPool.AddWebBrowserPrintContent(); --m_iBlockPreviewRefresh; UpdateWebBrowser(true); UpdateUIState(); }
public bool IsColumnHidden(AceColumnType t) { return IsColumnHidden(t, (t == AceColumnType.Password)); }
public static bool IsTimeColumn(AceColumnType t) { return((t == AceColumnType.CreationTime) || (t == AceColumnType.LastAccessTime) || (t == AceColumnType.LastModificationTime) || (t == AceColumnType.ExpiryTime) || (t == AceColumnType.ExpiryTimeDateOnly)); }
/* * // 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); } }