/// <summary> /// Adds the MenuItem to the MenuProvider. /// </summary> /// <param name="menuItem">Added MenuItem.</param> /// <param name="provider">The MenuProvider to which the MenuItem is added.</param> /// <param name="imageList">Collection of images available to the MenuItem.</param> /// <param name="imageIndex">A zero-based index, which represents the image position in an ImageList.</param> public static void AddMenuProviderToMenuItem(MenuItem menuItem, StiMenuProvider provider, ImageList imageList, int imageIndex) { if (!(menuItem.Parent is MainMenu)) { menuItem.OwnerDraw = true; menuItem.DrawItem += provider.diEventHandler; menuItem.MeasureItem += provider.miEventHandler; provider.SetImageList(menuItem, imageList); provider.SetImageIndex(menuItem, imageIndex); } }
/// <summary> /// Adds the Menu to the MenuProvider. /// </summary> /// <param name="menu">Added Menu.</param> /// <param name="provider">The MenuProvider to which the MenuItem is added.</param> public static void AddMenuProviderToMenu(Menu menu, StiMenuProvider provider) { foreach (MenuItem menuItem in menu.MenuItems) { if (!(menuItem.Parent is MainMenu)) { menuItem.OwnerDraw = true; menuItem.DrawItem += new DrawItemEventHandler(provider.DrawItem); menuItem.MeasureItem += new MeasureItemEventHandler(provider.MeasureItem); } } }
/// <summary> /// Adds the MenuItem to the MenuProvider. /// </summary> /// <param name="menuItem">Added MenuItem.</param> /// <param name="provider">The MenuProvider to which the MenuItem is added.</param> public static void AddMenuProviderToMenuItem(MenuItem menuItem, StiMenuProvider provider) { AddMenuProviderToMenuItem(menuItem, provider, null, -1); }