public void CloseDatabase(PwDatabase pwDatabase) { int iFoundPos = -1; for (int i = 0; i < m_vDocs.Count; ++i) { if (m_vDocs[i].Database == pwDatabase) { iFoundPos = i; m_vDocs.RemoveAt(i); break; } } if (iFoundPos != -1) { if (m_vDocs.Count == 0) { m_vDocs.Add(new DocumentStateEx()); } if (iFoundPos == m_vDocs.Count) { --iFoundPos; } m_dsActive = m_vDocs[iFoundPos]; this.NotifyActiveDocumentSelected(); } else { Debug.Assert(false); } }
public DocumentStateEx CreateNewDocument(bool bMakeActive) { DocumentStateEx ds = new DocumentStateEx(); if ((m_vDocs.Count == 1) && (!m_vDocs[0].Database.IsOpen) && (m_vDocs[0].LockedIoc.Path.Length == 0)) { m_vDocs.RemoveAt(0); m_dsActive = ds; } m_vDocs.Add(ds); if (bMakeActive) { m_dsActive = ds; } this.NotifyActiveDocumentSelected(); return(ds); }
public DocumentManagerEx() { m_dsActive = new DocumentStateEx(); m_vDocs.Add(m_dsActive); }
public DocumentStateEx CreateNewDocument(bool bMakeActive) { DocumentStateEx ds = new DocumentStateEx(); if((m_vDocs.Count == 1) && (!m_vDocs[0].Database.IsOpen) && (m_vDocs[0].LockedIoc.Path.Length == 0)) { m_vDocs.RemoveAt(0); m_dsActive = ds; } m_vDocs.Add(ds); if(bMakeActive) m_dsActive = ds; this.NotifyActiveDocumentSelected(); return ds; }
public void CloseDatabase(PwDatabase pwDatabase) { int iFoundPos = -1; for(int i = 0; i < m_vDocs.Count; ++i) { if(m_vDocs[i].Database == pwDatabase) { iFoundPos = i; m_vDocs.RemoveAt(i); break; } } if(iFoundPos != -1) { if(m_vDocs.Count == 0) m_vDocs.Add(new DocumentStateEx()); if(iFoundPos == m_vDocs.Count) --iFoundPos; m_dsActive = m_vDocs[iFoundPos]; this.NotifyActiveDocumentSelected(); } else { Debug.Assert(false); } }
private static void MenuAddEntry(DocumentStateEx ds, ToolStripMenuItem tsmiContainer, PwEntry pe) { ToolStripMenuItem tsmiEntry = new ToolStripMenuItem(); string strTitle = pe.Strings.ReadSafe(PwDefs.TitleField); string strUser = pe.Strings.ReadSafe(PwDefs.UserNameField); string strText = string.Empty; if((strTitle.Length > 0) && (strUser.Length > 0)) strText = strTitle + ": " + strUser; else if(strTitle.Length > 0) strText = strTitle; else if(strUser.Length > 0) strText = strUser; tsmiEntry.Text = strText; tsmiEntry.ImageIndex = MenuGetImageIndex(ds, pe.IconId, pe.CustomIconUuid); tsmiContainer.DropDownItems.Add(tsmiEntry); ToolStripMenuItem tsmi; tsmi = new ToolStripMenuItem(KPRes.AutoType); tsmi.ImageIndex = (int)PwIcon.Run; tsmi.Tag = pe; tsmi.Click += OnAutoType; tsmi.Enabled = pe.AutoType.Enabled; tsmiEntry.DropDownItems.Add(tsmi); tsmiEntry.DropDownItems.Add(new ToolStripSeparator()); tsmi = new ToolStripMenuItem(KPRes.Copy + " " + KPRes.UserName); tsmi.ImageIndex = (int)PwIcon.UserKey; tsmi.Tag = pe; tsmi.Click += OnCopyUserName; tsmiEntry.DropDownItems.Add(tsmi); tsmi = new ToolStripMenuItem(KPRes.Copy + " " + KPRes.Password); tsmi.ImageIndex = (int)PwIcon.Key; tsmi.Tag = pe; tsmi.Click += OnCopyPassword; tsmiEntry.DropDownItems.Add(tsmi); }
private static void MenuProcessGroup(DocumentStateEx ds, ToolStripMenuItem tsmiContainer, PwGroup pgSource) { if((pgSource.Groups.UCount == 0) && (pgSource.Entries.UCount == 0)) return; foreach(PwGroup pg in pgSource.Groups) { ToolStripMenuItem tsmi = MenuCreateGroup(ds, pg); tsmiContainer.DropDownItems.Add(tsmi); MenuProcessGroup(ds, tsmi, pg); } foreach(PwEntry pe in pgSource.Entries) MenuAddEntry(ds, tsmiContainer, pe); }
private static int MenuGetImageIndex(DocumentStateEx ds, PwIcon pwID, PwUuid pwCustomID) { if((pwCustomID != PwUuid.Zero) && (ds == Program.MainForm.DocumentManager.ActiveDocument)) { return (int)PwIcon.Count + Program.MainForm.DocumentManager.ActiveDatabase.GetCustomIconIndex( pwCustomID); } if((int)pwID < (int)PwIcon.Count) return (int)pwID; return (int)PwIcon.Key; }
private static ToolStripMenuItem MenuCreateGroup(DocumentStateEx ds, PwGroup pg) { ToolStripMenuItem tsmi = new ToolStripMenuItem(); tsmi.Text = pg.Name; tsmi.ImageIndex = MenuGetImageIndex(ds, pg.IconId, pg.CustomIconUuid); return tsmi; }
public void UpdateUI(bool bRecreateTabBar, DocumentStateEx dsSelect, bool bUpdateGroupList, PwGroup pgSelect, bool bUpdateEntryList, PwGroup pgEntrySource, bool bSetModified) { if(bRecreateTabBar) RecreateUITabs(); if(dsSelect != null) m_docMgr.ActiveDocument = dsSelect; SelectUITab(); UpdateImageLists(); if(bUpdateGroupList) UpdateGroupList(pgSelect); if(bUpdateEntryList) UpdateEntryList(pgEntrySource, false); UpdateUIState(bSetModified); }
public bool IsFileLocked(DocumentStateEx ds) { if(ds == null) ds = m_docMgr.ActiveDocument; return (ds.LockedIoc.Path.Length != 0); }
private void MakeDocumentActive(DocumentStateEx ds) { if(ds == null) { Debug.Assert(false); return; } ds.Database.UINeedsIconUpdate = true; UpdateUI(false, ds, true, null, true, null, false); RestoreWindowState(ds.Database); UpdateUIState(false); }
private void GetTabText(DocumentStateEx dsInfo, out string strName, out string strTip) { if(IsFileLocked(dsInfo) == false) // Not locked { strTip = dsInfo.Database.IOConnectionInfo.Path; strName = UrlUtil.GetFileName(strTip); if(dsInfo.Database.Modified) strName += "*"; if(dsInfo.Database.IsOpen) { if(dsInfo.Database.Name.Length > 0) strTip += "\r\n" + dsInfo.Database.Name; } } else // Locked { strTip = dsInfo.LockedIoc.Path; strName = UrlUtil.GetFileName(strTip); strName += " [" + KPRes.Locked + "]"; } }