Inheritance: KryptonRibbonGroupItem, IRibbonGroupContainer
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our group is being removed
            if (e.Component == _ribbonGroup)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // We need to remove all containers from the group
                for (int j = _ribbonGroup.Items.Count - 1; j >= 0; j--)
                {
                    KryptonRibbonGroupContainer item = _ribbonGroup.Items[j] as KryptonRibbonGroupContainer;
                    _ribbonGroup.Items.Remove(item);
                    host.DestroyComponent(item);
                }
            }
        }
        private void OnClearItems(object sender, EventArgs e)
        {
            if ((_ribbonGroup != null) &&
                (_ribbonGroup.Ribbon != null) &&
                _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup))
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroup ClearItems");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonGroup)["Items"];

                    RaiseComponentChanging(propertyItems);

                    // Need access to host in order to delete a component
                    IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                    // We need to remove all the items from the tab
                    for (int i = _ribbonGroup.Items.Count - 1; i >= 0; i--)
                    {
                        KryptonRibbonGroupContainer item = _ribbonGroup.Items[i];
                        _ribbonGroup.Items.Remove(item);
                        host.DestroyComponent(item);
                    }

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
Esempio n. 3
0
        private void UpdateVisible(Control c)
        {
            if (c != null)
            {
                // Start with the visible state of the group element
                bool visible = _ribbonTextBox.Visible;

                // If we have an associated designer setup...
                if (!_ribbon.InDesignHelperMode && (_ribbonTextBox.TextBoxDesigner != null))
                {
                    // And we are not using the design helpers, then use the design specified value
                    visible = _ribbonTextBox.TextBoxDesigner.DesignVisible;
                }

                if (visible)
                {
                    // Only visible if on the currently selected page
                    if ((_ribbonTextBox.RibbonTab == null) ||
                        (_ribbon.SelectedTab != _ribbonTextBox.RibbonTab))
                    {
                        visible = false;
                    }
                    else
                    {
                        // Check the owning group is visible
                        if ((_ribbonTextBox.RibbonContainer != null) &&
                            (_ribbonTextBox.RibbonContainer.RibbonGroup != null) &&
                            !_ribbonTextBox.RibbonContainer.RibbonGroup.Visible &&
                            !_ribbon.InDesignMode)
                        {
                            visible = false;
                        }
                        else
                        {
                            // Check that the group is not collapsed
                            if ((_ribbonTextBox.RibbonContainer.RibbonGroup.IsCollapsed) &&
                                ((_ribbon.GetControllerControl(_ribbonTextBox.TextBox) is KryptonRibbon) ||
                                 (_ribbon.GetControllerControl(_ribbonTextBox.TextBox) is VisualPopupMinimized)))
                            {
                                visible = false;
                            }
                            else
                            {
                                // Check that the hierarchy of containers are all visible
                                KryptonRibbonGroupContainer container = _ribbonTextBox.RibbonContainer;

                                // Keep going until we have searched the entire parent chain of containers
                                while (container != null)
                                {
                                    // If any parent container is not visible, then we are not visible
                                    if (!container.Visible)
                                    {
                                        visible = false;
                                        break;
                                    }

                                    // Move up a level
                                    container = container.RibbonContainer;
                                }
                            }
                        }
                    }
                }

                c.Visible = visible;
            }
        }