Example #1
0
        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);
                }
            }
        }
Example #2
0
        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();
                    }
                }
            }
        }
Example #3
0
        private void UpdateVisible(Control c)
        {
            if (c != null)
            {
                // Start with the visible state of the group element
                bool visible = _ribbonDateTimePicker.Visible;

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

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