/// <summary> /// Creates a <see cref="RibbonDropDownItem"/> for the given emoticon. /// </summary> /// <param name="emoticon">The emoticon info.</param> /// <returns>An instance of <see cref="RibbonDropDownItem"/> representing the emoticon.</returns> private RibbonDropDownItem CreateEmoticonDropDownItem(Emoticon emoticon) { var dropDownItem = this.Factory.CreateRibbonDropDownItem(); dropDownItem.Image = Image.FromFile(emoticon.Filename); dropDownItem.Tag = emoticon; return dropDownItem; }
/// <summary> /// Creates a <see cref="RibbonButton"/> for the given emoticon. /// </summary> /// <param name="emoticon">The emoticon info.</param> /// <returns>An instance of <see cref="RibbonButton"/> representing the emoticon.</returns> private RibbonButton CreateEmoticonButton(Emoticon emoticon) { var button = this.Factory.CreateRibbonButton(); button.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeRegular; button.ShowImage = true; button.ShowLabel = false; button.Image = Image.FromFile(emoticon.Filename); button.Click += (sender, e) => { // Check if the reference to the inspector is valid var inspector = this.Context as Inspector; if (inspector == null) return; // Add the emoticon at the current selection start var editor = inspector.WordEditor as Document; editor.Application.Selection.Range.InlineShapes.AddPicture(emoticon.Filename); }; return button; }