Exemplo n.º 1
0
        /// <summary>
        /// Change the RibbonSize for every IRibbonControl inside this group.
        /// </summary>
        private void ChangeControlSizes()
        {
            int  level     = ReductionLevel;
            int  maxLevels = GetMaxLevel();
            bool minimized = level >= maxLevels;

            IsMinimized = minimized;
            if (minimized)
            {
                level = 0;
            }

            for (int i = 0; i < Controls.Count; i++)
            {
                UIElement      e       = Controls[i];
                IRibbonGallery gallery = e as IRibbonGallery;
                if (gallery != null)
                {
                    int columns = GetGalleryColumns(e, level, maxLevels);
                    gallery.Columns     = columns;
                    gallery.IsCollapsed = columns == 0;
                    gallery.SetDropDownColumns(GetGalleryColumns(e, 0, maxLevels));
                }
                else
                {
                    if (e is IRibbonControl)
                    {
                        RibbonSize size = GetControlSize(e, level, i);
                        RibbonBar.SetSize(e, size);
                    }
                }
            }
            InvalidateMeasure();
            UpdateLayout();
        }
Exemplo n.º 2
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            IRibbonButton b = element as IRibbonButton;

            if (b != null)
            {
                RibbonBar.SetSize(element, RibbonSize.Small);
            }
        }
Exemplo n.º 3
0
        protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint)
        {
            itemsHost.Children.Clear();
            if (overflowHost != null)
            {
                overflowHost.Children.Clear();
            }
            CreateMenuItems();
            foreach (UIElement e in GetToolbarItems())
            {
                RibbonBar.SetSize(e, RibbonSize.Small);
                itemsHost.Children.Add(e);
            }
            HasOverflowItems = false;
            Size maxSize = base.MeasureOverride(new Size(double.PositiveInfinity, constraint.Height));

            while (maxSize.Width > constraint.Width)
            {
                int n = itemsHost.Children.Count;
                if (n == 0)
                {
                    break;
                }
                UIElement e = itemsHost.Children[n - 1];
                InvalidateAncestorMeasure(e);
                itemsHost.Children.RemoveAt(n - 1);
                if (overflowHost != null)
                {
                    overflowHost.Children.Insert(0, e);
                    HasOverflowItems = true;
                }
                maxSize = base.MeasureOverride(new Size(double.PositiveInfinity, constraint.Height));
            }
            Size size = base.MeasureOverride(constraint);

            return(size);
        }