private Color CheckForContextColor() { // We need an associated ribbon tab // Does the ribbon tab have a context setting? KryptonRibbonTab selectedTab = _ribbon?.SelectedTab; if (!string.IsNullOrEmpty(selectedTab?.ContextName)) { // Find the context definition for this context KryptonRibbonContext ribbonContext = _ribbon.RibbonContexts[selectedTab.ContextName]; // Should always work, but you never know! if (ribbonContext != null) { return(ribbonContext.ContextColor); } } return(Color.Empty); }
/// <summary> /// Function to unmerge the contexts for a source ribbon from a target ribbon. /// </summary> /// <param name="sourceRibbon">The ribbon to unmerge.</param> /// <param name="targetRibbon">The ribbon to be unmerged from.</param> private void UnmergeContexts(KryptonRibbon sourceRibbon, KryptonRibbon targetRibbon) { IEnumerable <KryptonRibbonContext> contexts = targetRibbon.RibbonContexts.ToArray(); foreach (KryptonRibbonContext context in contexts) { if (!_mergedItems.Contains(context)) { continue; } KryptonRibbonContext existing = sourceRibbon.RibbonContexts.FirstOrDefault(item => string.Equals(item.ContextTitle, context.ContextTitle, StringComparison.CurrentCulture)); // The tab doesn't exist, so just add it if ((existing != null) || (sourceRibbon.RibbonContexts.Contains(context))) { continue; } _mergedItems.Remove(context); targetRibbon.RibbonContexts.Remove(context); sourceRibbon.RibbonContexts.Add(context); } }