コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
            }
        }