Provide context title click functionality.
Inheritance: ComponentFactory.Krypton.Toolkit.GlobalId, IMouseController
Example #1
0
        private void SyncChildrenToContexts()
        {
            // Find any filler child
            ViewBase filler = null;

            foreach (ViewBase child in this)
            {
                if (GetDock(child) == ViewDockStyle.Fill)
                {
                    filler = child;
                    break;
                }
            }

            // Remove all child elements
            Clear();

            // Make sure we have enough cached elements
            if (_contextTitlesCache.Count < ViewLayoutRibbonTabs.ContextTabSets.Count)
            {
                for (int i = _contextTitlesCache.Count; i < ViewLayoutRibbonTabs.ContextTabSets.Count; i++)
                {
                    // Create a new view element and an associated button controller
                    ViewDrawRibbonContextTitle viewContextTitle = new ViewDrawRibbonContextTitle(_ribbon, _ribbon.StateContextCheckedNormal.RibbonTab)
                    {
                        MouseController = new ContextTitleController(_ribbon)
                    };
                    _contextTitlesCache.Add(viewContextTitle);
                }
            }

            // Add a view element per context and update with correct reference
            for (int i = 0; i < ViewLayoutRibbonTabs.ContextTabSets.Count; i++)
            {
                ViewDrawRibbonContextTitle viewContext    = _contextTitlesCache[i];
                ContextTitleController     viewController = (ContextTitleController)viewContext.MouseController;
                viewContext.ContextTabSet    = ViewLayoutRibbonTabs.ContextTabSets[i];
                viewController.ContextTabSet = viewContext.ContextTabSet;
                Add(viewContext);
            }

            // Put back any filler
            if (filler != null)
            {
                Add(filler, ViewDockStyle.Fill);
            }
        }