private ToolStripButton CreateToolBar(ToolStrip toolbar, BarConfig btnconfig) { ToolStripButton toolbarbtn = new ToolStripButton(); var text = MultilingualUtility.GetString(btnconfig.Title); toolbarbtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText; toolbarbtn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; toolbarbtn.Name = btnconfig.Title.ToString(); toolbarbtn.Text = text.Replace('_', '&'); toolbarbtn.ToolTipText = text.Replace("_", String.Empty); toolbarbtn.TextAlign = System.Drawing.ContentAlignment.MiddleRight; toolbarbtn.Tag = btnconfig; toolbarbtn.Click += ToolBarBtn_Clicked; toolbarbtn.Image = LoadMenuImage(btnconfig, toolbar); return toolbarbtn; }
private Image LoadMenuImage(BarConfig config, ToolStrip toolbar) { if (!string.IsNullOrEmpty(config.ImageUrl) && toolbar.ImageList.Images.ContainsKey(config.ImageUrl)) { return toolbar.ImageList.Images[config.ImageUrl]; } return null; }