private void SyncChildrenToRibbonGroupItems()
        {
            // Remove all child elements
            Clear();

            ContainerToView regenerate = new ContainerToView();

            // Add a view element for each group item
            foreach (KryptonRibbonGroupContainer container in _ribbonGroup.Items)
            {
                ViewBase containerView;

                // Do we already have a view for this container definition
                if (_containerToView.ContainsKey(container))
                {
                    containerView = _containerToView[container];
                }
                else
                {
                    // Ask the container definition to return an appropriate view
                    containerView = container.CreateView(_ribbon, _needPaint);
                }

                // Update the visible state of the item
                containerView.Visible = (container.Visible || _ribbon.InDesignHelperMode);

                // We need to keep this association
                regenerate.Add(container, containerView);

                Add(containerView);
            }

            // When in design time help mode
            if (_ribbon.InDesignHelperMode)
            {
                // Create the design time 'Add Container' first time it is needed
                if (_viewAddContainer == null)
                {
                    _viewAddContainer = new ViewDrawRibbonDesignGroupContainer(_ribbon, _ribbonGroup, _needPaint);
                }

                // Always add at end of the list of tabs
                Add(_viewAddContainer);
            }

            // Use the latest hashtable
            _containerToView = regenerate;
        }
Beispiel #2
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonGroupContent class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon control instance.</param>
        /// <param name="ribbonGroup">The ribbon group this layout is used to display.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewLayoutRibbonGroupContent(KryptonRibbon ribbon,
                                            KryptonRibbonGroup ribbonGroup,
                                            NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonGroup != null);
            Debug.Assert(needPaint != null);

            // Cache references
            _ribbon      = ribbon;
            _ribbonGroup = ribbonGroup;
            _needPaint   = needPaint;

            // Use hashtable to store relationships
            _containerToView = new ContainerToView();
        }