internal static void BuildOpenWithMenu(DynamicMenu dm, string strItem, ProtectedBinary pb, bool bReadOnly) { if (dm == null) { Debug.Assert(false); return; } dm.Clear(); if (string.IsNullOrEmpty(strItem)) { Debug.Assert(false); return; } if (pb == null) { Debug.Assert(false); return; } byte[] pbData = pb.ReadData(); if (pbData == null) { Debug.Assert(false); return; } BinaryDataClass bdc = BinaryDataClassifier.Classify(strItem, pbData); BinaryDataOpenOptions oo = new BinaryDataOpenOptions(); oo.Handler = BinaryDataHandler.InternalViewer; dm.AddItem(KPRes.InternalViewer, Properties.Resources.B16x16_View_Detailed, oo); oo = new BinaryDataOpenOptions(); oo.Handler = BinaryDataHandler.InternalEditor; ToolStripMenuItem tsmiIntEditor = dm.AddItem(KPRes.InternalEditor, Properties.Resources.B16x16_View_Detailed, oo); oo = new BinaryDataOpenOptions(); oo.Handler = BinaryDataHandler.ExternalApp; ToolStripMenuItem tsmiExt = dm.AddItem(KPRes.ExternalApp, Properties.Resources.B16x16_Make_KDevelop, oo); if (!DataEditorForm.SupportsDataType(bdc) || bReadOnly) { tsmiIntEditor.Enabled = false; } if (bReadOnly) { tsmiExt.Enabled = false; } }
private void OnEntryContextMenuOpening(object sender, CancelEventArgs e) { ctxEntryShowQRCode.Visible = false; if (!host.Database.IsOpen) { return; } if (host.MainWindow.GetSelectedEntriesCount() != 1) { return; } var pe = host.MainWindow.GetSelectedEntry(true); if (pe == null) { return; } dynQRCodes.Clear(); var items = new List <Tuple <string, string> >(); foreach (var kvp in pe.Strings) { if (kvp.Value.IsEmpty) { continue; } items.Add(Tuple.Create( StrUtil.EncodeMenuText(TryTranslateKey(kvp.Key)), kvp.Key )); } foreach (var kv in items.OrderBy(t => t.Item1)) { dynQRCodes.AddItem( kv.Item1, Properties.Resources.icon, kv.Item2 ); } ctxEntryShowQRCode.Visible = true; }
void EntryContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e) { m_tsmi_set_template_parent.Enabled = m_host.MainWindow.GetSelectedEntriesCount() != 0; m_tsmi_copy_template_string.Visible = show_copy_menu(); if (show_copy_menu()) { m_dynCustomStrings.Clear(); PwEntry pe = m_host.MainWindow.GetSelectedEntry(true); Dictionary <string, string> title_to_field = EntryTemplateManager.get_template_title_to_field_dict(m_host, EntryTemplateManager.get_entry_template_parent_uuid(pe)); foreach (KeyValuePair <string, string> kvp in title_to_field) { m_dynCustomStrings.AddItem(kvp.Key, Resources.Resources.B16x16_KGPG_Info, kvp.Value); } } }
private void OnPwGenClick(object sender, EventArgs e) { m_dynGenProfiles.Clear(); m_dynGenProfiles.AddItem(DeriveFromPrevious, Resources.Resources.B16x16_CompFile); if (Program.Config.PasswordGenerator.UserProfiles.Count > 0) { m_dynGenProfiles.AddSeparator(); } foreach (PwProfile pwgo in Program.Config.PasswordGenerator.UserProfiles) { if (pwgo.Name != DeriveFromPrevious) { m_dynGenProfiles.AddItem(pwgo.Name, Resources.Resources.B16x16_KOrganizer); } } m_ctxPwGen.Show(m_btnGenPw, new Point(0, m_btnGenPw.Height)); }