/// ------------------------------------------------------------------------------------ public PatternBuilderBar() { InitializeComponent(); BackColor = Properties.Settings.Default.GradientPanelTopColor; m_menuStrip.BackColor = Properties.Settings.Default.GradientPanelTopColor; m_menuStrip.ForeColor = Properties.Settings.Default.GradientPanelTextColor; m_menuStrip.Renderer.RenderItemText += ((s, e) => { if (e.Item.OwnerItem == null && e.Item is ToolStripMenuItem && (e.Item.Selected || ((ToolStripMenuItem)e.Item).DropDown.Visible)) { TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont, e.TextRectangle, Color.Black, e.TextFormat); } }); ((ToolStripDropDownMenu)m_mnuSpecial.DropDown).ShowImageMargin = false; ((ToolStripDropDownMenu)m_mnuSpecial.DropDown).ShowCheckMargin = false; foreach (ToolStripItem mnu in m_mnuSpecial.DropDownItems) { mnu.Font = SystemFonts.MenuFont; } m_mnuPhones.DropDown = PatternBuilderPhoneDropDown.Create(() => Width, text => { m_mnuPhones.DropDown.Close(); ItemSelectedHandler(text); }); }
/// ------------------------------------------------------------------------------------ public static CustomDropDown Create(Func <int> getWidthHandler, Action <string> itemSelectedHandler) { var phoneDropDown = new PatternBuilderPhoneDropDown(); phoneDropDown.m_getWidthHandler = getWidthHandler; phoneDropDown.m_itemSelectedHandler = itemSelectedHandler; var hostingDropDown = new CustomDropDown(); hostingDropDown.AddControl(phoneDropDown); hostingDropDown.Opening += phoneDropDown.LoadControls; hostingDropDown.Opened += delegate { phoneDropDown.Focus(); }; return(hostingDropDown); }