コード例 #1
0
		private void ExecuteBinaryOpen(PwEntry pe, string strBinName)
		{
			EntryBinaryDataContext ctx = new EntryBinaryDataContext();
			ctx.Entry = pe;
			ctx.Name = strBinName;

			DynamicMenuEventArgs args = new DynamicMenuEventArgs(strBinName, ctx);
			OnEntryBinaryOpen(null, args);
		}
コード例 #2
0
ファイル: MainForm.cs プロジェクト: rdealexb/keepass
        private void OnCtxPwListOpening(object sender, CancelEventArgs e)
        {
            MainAppState s = UpdateUIEntryCtxState(null);

            m_dynCustomStrings.Clear();
            m_dynCustomBinaries.Clear();

            if(s.EntriesSelected != 1)
            {
                m_ctxEntryCopyString.Visible = false;
                m_ctxEntryAttachments.Visible = false;
                return;
            }

            PwEntry pe = s.SelectedEntry;
            if(pe == null) { Debug.Assert(false); return; }

            uint uStrItems = 0;
            List<char> lAvailKeys = new List<char>(PwCharSet.MenuAccels);
            foreach(KeyValuePair<string, ProtectedString> kvp in pe.Strings)
            {
                string strKey = kvp.Key;
                if(PwDefs.IsStandardField(strKey)) continue;

                strKey = StrUtil.EncodeMenuText(strKey);
                strKey = StrUtil.AddAccelerator(strKey, lAvailKeys);

                m_dynCustomStrings.AddItem(strKey,
                    Properties.Resources.B16x16_KGPG_Info, kvp.Key);
                ++uStrItems;
            }
            m_ctxEntryCopyString.Visible = (uStrItems > 0);

            uint uBinItems = 0;
            lAvailKeys = new List<char>(PwCharSet.MenuAccels);
            foreach(KeyValuePair<string, ProtectedBinary> kvp in pe.Binaries)
            {
                Image imgIcon;
                // Try a fast classification
                BinaryDataClass bdc = BinaryDataClassifier.ClassifyUrl(kvp.Key);
                if((bdc == BinaryDataClass.Text) || (bdc == BinaryDataClass.RichText))
                    imgIcon = Properties.Resources.B16x16_ASCII;
                else if(bdc == BinaryDataClass.Image)
                    imgIcon = Properties.Resources.B16x16_Spreadsheet;
                else if(bdc == BinaryDataClass.WebDocument)
                    imgIcon = Properties.Resources.B16x16_HTML;
                else imgIcon = Properties.Resources.B16x16_Binary;

                EntryBinaryDataContext ctxBin = new EntryBinaryDataContext();
                ctxBin.Entry = pe;
                ctxBin.Name = kvp.Key;

                string strKey = StrUtil.EncodeMenuText(kvp.Key);
                strKey = StrUtil.AddAccelerator(strKey, lAvailKeys);

                m_dynCustomBinaries.AddItem(strKey, imgIcon, ctxBin);
                ++uBinItems;
            }
            m_ctxEntryAttachments.Visible = (uBinItems > 0);
        }