public void AddMenuItem(List <char> lAvailKeys) { if (m_tsmi != null) { Debug.Assert(false); return; } string strNameAccel = StrUtil.AddAccelerator( StrUtil.EncodeMenuText(m_strName), lAvailKeys); Debug.Assert(StrUtil.EncodeMenuText(KPRes.OpenWith) == KPRes.OpenWith); string strText = KPRes.OpenWith.Replace(@"{PARAM}", strNameAccel); m_tsmi = m_dynMenu.AddItem(strText, m_imgIcon, this); try { string strTip = m_strPath; if (strTip.StartsWith("cmd://", StrUtil.CaseIgnoreCmp)) { strTip = strTip.Substring(6); } if (strTip.Length != 0) { m_tsmi.ToolTipText = strTip; } } catch (Exception) { Debug.Assert(false); } // Too long? }
private List <ToolStripItem> ConstructMenuItems() { List <ToolStripItem> l = new List <ToolStripItem>(); List <char> lAvailKeys = new List <char>(PwCharSet.MenuAccels); ProtectedString ps = GetPassword(); GFunc <string, Image, EventHandler, object, ToolStripMenuItem> fAdd = delegate(string strText, Image img, EventHandler ehClick, object oTag) { string str = StrUtil.EncodeMenuText(strText ?? string.Empty); str = StrUtil.AddAccelerator(str, lAvailKeys); ToolStripMenuItem tsmi = new ToolStripMenuItem(str); if (img != null) { tsmi.Image = img; } if (ehClick != null) { tsmi.Click += ehClick; } if (oTag != null) { tsmi.Tag = oTag; } l.Add(tsmi); return(tsmi); }; fAdd(KPRes.PwGenOpen, Properties.Resources.B16x16_Key_New, this.OnGenOpen, null); l.Add(new ToolStripSeparator()); ToolStripMenuItem tsmiDerive = fAdd(GenDeriveFromPrevious, Properties.Resources.B16x16_CompFile, this.OnGenDeriveFromPrevious, null); if (IsMultipleValues(ps)) { tsmiDerive.Enabled = false; } fAdd(GenAuto, Properties.Resources.B16x16_FileNew, this.OnGenAuto, null); bool bHideBuiltIn = ((Program.Config.UI.UIFlags & (ulong)AceUIFlags.HideBuiltInPwGenPrfInEntryDlg) != 0); bool bFirst = true; foreach (PwProfile prf in PwGeneratorUtil.GetAllProfiles(true)) { if (prf == null) { Debug.Assert(false); continue; } if (bHideBuiltIn && PwGeneratorUtil.IsBuiltInProfile(prf.Name)) { continue; } if (bFirst) { l.Add(new ToolStripSeparator()); bFirst = false; } fAdd(prf.Name, Properties.Resources.B16x16_KOrganizer, this.OnGenProfile, prf); } return(l); }