public void AddContextVerb(object sender, EventArgs e) { Ribbon r = Control as Ribbon; if (r != null) { IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (host == null) { return; } RibbonContext context = host.CreateComponent(typeof(RibbonContext)) as RibbonContext; if (context == null) { return; } context.Text = context.Site.Name; Random rnd1 = new Random(); context.GlowColor = Color.FromArgb(rnd1.Next(155, 255), rnd1.Next(155, 255), rnd1.Next(155, 255)); Ribbon.Contexts.Add(context); r.Refresh(); } }
public void AddTabVerb(object sender, EventArgs e) { Ribbon r = Control as Ribbon; if (r != null) { IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (host == null) { return; } RibbonTab tab = host.CreateComponent(typeof(RibbonTab)) as RibbonTab; if (tab == null) { return; } tab.Text = tab.Site.Name; Ribbon.Tabs.Add(tab); r.Refresh(); } }
/// <summary> /// set the ribbon item image /// </summary> /// <param name="expressRibbon">express Ribbon</param> /// <param name="expressRibbonTabText">express Ribbon Tab Text</param> /// <param name="expressRibbonItemName">express Ribbon Item Name</param> /// <param name="expressRibbonItemImage">express Ribbon Item Image</param> public static void SetRibbonButtonImage(Ribbon ribbon, string ribbonTabText, string ribbonItemName, Image image) { RibbonItem item = FindRibbonItem(ribbon, ribbonTabText, ribbonItemName); if (item == null) { return; } item.Image = image; item.RedrawItem(); ribbon.Refresh(); }