/// <summary>
 /// Creates a new instance
 /// </summary>
 public RibbonControlSizeDefinition(RibbonControlSize large, RibbonControlSize middle, RibbonControlSize small)
     : this()
 {
     this.Large = large;
     this.Middle = middle;
     this.Small = small;
 }
        /// <summary>
        /// Handles size property changing
        /// </summary>
        /// <param name="previous">Previous value</param>
        /// <param name="current">Current value</param>
        public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
        {
            foreach (var frameworkElement in this.actualChildren)
            {
                RibbonProperties.SetSize(frameworkElement, current);
            }

            this.rebuildVisualAndLogicalChildren = true;
            this.InvalidateMeasure();
        }
 public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
 {
     this.Invalidate("Size");
 }
 /// <summary>
 /// Handles size property changing
 /// </summary>
 /// <param name="previous">Previous value</param>
 /// <param name="current">Current value</param>
 public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
 {
     if (this.CanCollapseToButton)
     {
         if (current == RibbonControlSize.Large
             && this.galleryPanel.MinItemsInRow > this.MinItemsInRow)
         {
             this.IsCollapsed = false;
         }
         else
         {
             this.IsCollapsed = true;
         }
     }
     else
     {
         this.IsCollapsed = false;
     }
 }
        /// <summary>
        /// Gets value of the attached property SizeDefinition of the given element
        /// </summary>
        /// <param name="element">The given element</param>
        public static RibbonControlSize[] GetThreeRibbonSizeDefinition(DependencyObject element)
        {
            var sizeDefinition = GetRibbonSizeDefinition(element);

            if (string.IsNullOrEmpty(sizeDefinition))
            {
                return new[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large };
            }

            var splitted = sizeDefinition.Split(new[] { ' ', ',', ';', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);

            var count = Math.Min(splitted.Length, 3);
            if (count == 0)
            {
                return new[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large };
            }

            var sizes = new RibbonControlSize[3];
            for (var i = 0; i < count; i++)
            {
                switch (splitted[i])
                {
                    case "Large":
                        sizes[i] = RibbonControlSize.Large;
                        break;

                    case "Middle":
                        sizes[i] = RibbonControlSize.Middle;
                        break;

                    case "Small":
                        sizes[i] = RibbonControlSize.Small;
                        break;

                    default:
                        sizes[i] = RibbonControlSize.Large;
                        break;
                }
            }

            for (var i = count; i < 3; i++)
            {
                sizes[i] = sizes[count - 1];
            }

            return sizes;
        }
 /// <summary>
 /// Sets SizeDefinition for element
 /// </summary>
 public static void SetRibbonSize(DependencyObject element, RibbonControlSize value)
 {
     element.SetValue(RibbonSizeProperty, value);
 }
 /// <summary>
 /// Handles size property changing
 /// </summary>
 /// <param name="previous">Previous value</param>
 /// <param name="current">Current value</param>
 protected virtual void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
 {
 }
        /// <summary>
        /// Gets value of the attached property SizeDefinition of the given element
        /// </summary>
        /// <param name="element">The given element</param>
        public static RibbonControlSize[] GetThreeSizeDefinition(UIElement element)
        {
            string[] splitted = ((element as IRibbonControl).SizeDefinition).Split(new char[] { ' ', ',', ';', '-', '>' }, StringSplitOptions.RemoveEmptyEntries);

            int count = Math.Min(splitted.Length, 3);
            if (count == 0) return new RibbonControlSize[] { RibbonControlSize.Large, RibbonControlSize.Large, RibbonControlSize.Large };

            RibbonControlSize[] sizes = new RibbonControlSize[3];
            for (int i = 0; i < count; i++)
            {
                switch (splitted[i])
                {
                    case "Large": sizes[i] = RibbonControlSize.Large; break;
                    case "Middle": sizes[i] = RibbonControlSize.Middle; break;
                    case "Small": sizes[i] = RibbonControlSize.Small; break;
                    default: sizes[i] = RibbonControlSize.Large; break;
                }
            }
            for (int i = count; i < 3; i++)
            {
                sizes[i] = sizes[count - 1];
            }
            return sizes;
        }
 /// <summary>
 /// Handles size property changing
 /// </summary>
 /// <param name="previous">Previous value</param>
 /// <param name="current">Current value</param>
 public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
 {
     if (CanCollapseToButton)
     {
         if ((current == RibbonControlSize.Large)
             && (galleryPanel.MinItemsInRow > MinItemsInRow))
         {
             IsCollapsed = false;
         }
         else
         {
             IsCollapsed = true;
         }
     }
     else
     {
         IsCollapsed = false;
     }
 }
 /// <summary>
 /// Handles size property changing
 /// </summary>
 /// <param name="previous">Previous value</param>
 /// <param name="current">Current value</param>
 protected override void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
 {
     rebuildVisualAndLogicalChildren = true;
     InvalidateMeasure();
 }
 /// <summary>
 /// Handles size property changing
 /// </summary>
 /// <param name="previous">Previous value</param>
 /// <param name="current">Current value</param>
 protected override void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
 {
     if (CanCollapseToButton)
     {
         if ((current == RibbonControlSize.Large) && ((CurrentItemsInRow > MinItemsInRow))) IsCollapsed = false;
         else IsCollapsed = true;
     }
     else IsCollapsed = false;
     base.OnSizePropertyChanged(previous, current);
 }