void RibbonTransformer_BarItemAdding(object sender, BarItemAddingEventArgs e) { var transformer = (ClassicToRibbonTransformer)sender; if (e.Action != null) { var findRibbonActionLink = FindRibbonActionLink(e.Action); var modelActionToContainerMapping = ((IModelActionDesignContainerMapping)Application.Model.ActionDesign).ActionToContainerMapping; foreach (IModelActionContainer v in modelActionToContainerMapping) { foreach (IModelActionLink actionLink in v) { if (actionLink.ActionId == e.Action.Id) { findRibbonActionLink = ((IModelActionLinkRibbon)actionLink).Ribbon; } } } var mapping = modelActionToContainerMapping.SelectMany(container => container).OfType<IModelActionLinkRibbon>(); foreach (var map in mapping) { if (map.ActionId == e.Action.Id) findRibbonActionLink = map.Ribbon; } if (findRibbonActionLink != null) { BarItemSetup(findRibbonActionLink, e.Item); RibbonPage page = e.Group.Page; if (!string.IsNullOrEmpty(findRibbonActionLink.TargetRibbonPage)) { page = transformer.FindPageByName(findRibbonActionLink.TargetRibbonPage) ?? AddPage(transformer.Ribbon, findRibbonActionLink.TargetRibbonPage); } RibbonPageGroup pageGroup = e.Group; if (!string.IsNullOrEmpty(findRibbonActionLink.TargetRibbonGroup)) { pageGroup = transformer.FindGroupByName(page, findRibbonActionLink.TargetRibbonGroup) ?? AddPageGroup(page, findRibbonActionLink.TargetRibbonGroup); } e.Group = pageGroup; } } }
void RibbonTransformer_BarItemAdding(object sender, BarItemAddingEventArgs e) { var transformer = (ClassicToRibbonTransformer)sender; if (e.Action != null) { var findRibbonActionLink = FindRibbonActionLink(e.Action); var modelActionToContainerMapping = ((IModelActionDesignContainerMapping)Application.Model.ActionDesign).ActionToContainerMapping; foreach (IModelActionContainer v in modelActionToContainerMapping) { foreach (IModelActionLink actionLink in v) { if (actionLink.ActionId == e.Action.Id) { findRibbonActionLink = ((IModelActionLinkRibbon)actionLink).Ribbon; } } } var mapping = modelActionToContainerMapping.SelectMany(container => container).OfType <IModelActionLinkRibbon>(); foreach (var map in mapping) { if (map.ActionId == e.Action.Id) { findRibbonActionLink = map.Ribbon; } } if (findRibbonActionLink != null) { BarItemSetup(findRibbonActionLink, e.Item); RibbonPage page = e.Group.Page; if (!string.IsNullOrEmpty(findRibbonActionLink.TargetRibbonPage)) { page = transformer.FindPageByName(findRibbonActionLink.TargetRibbonPage) ?? AddPage(transformer.Ribbon, findRibbonActionLink.TargetRibbonPage); } RibbonPageGroup pageGroup = e.Group; if (!string.IsNullOrEmpty(findRibbonActionLink.TargetRibbonGroup)) { pageGroup = page.GetGroupByName(findRibbonActionLink.TargetRibbonGroup) ?? AddPageGroup(page, findRibbonActionLink.TargetRibbonGroup); } e.Group = pageGroup; } } }