예제 #1
0
        int GetGalleryColumns(DependencyObject control, int level, int maxLevels)
        {
            RibbonGalleryColumns columns = RibbonGallery.GetReductionColumns(control);

            if (columns != null && columns.Count > 0)
            {
                level = Math.Max(0, Math.Min(level, columns.Count - 1));
                return(columns[level]);
            }

            if (level == maxLevels)
            {
                return(0);
            }

            if (maxLevels > 4)
            {
                level = Math.Max(level, 8);
                return(3 + (4 - level / 2));
            }
            else
            {
                return(3 + (2 - level) * 2);
            }
        }
예제 #2
0
        static void ReductionColumnsPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            RibbonGallery g = o as RibbonGallery;

            if (g != null)
            {
                RibbonGalleryColumns columns = e.NewValue as RibbonGalleryColumns;
                if (columns != null && columns.Count > 0)
                {
                    g.Columns = columns[0];
                }
            }
        }
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string str = value as string;
            if (str == null)
            {
                return base.ConvertFrom(context, culture, value);
            }
            str = str.Trim();
            if (str.Length == 0) return null;

            string[] names = str.Split(',');
            RibbonGalleryColumns collection = new RibbonGalleryColumns();
            foreach (string name in names)
            {
                collection.Add(int.Parse(name));
            }
            return collection;
        }
예제 #4
0
        //Gets the maximum possible ReductionLevel that would change any of the controls.
        private int GetMaxLevel()
        {
            int max = 1;

            foreach (UIElement e in Controls)
            {
                if (e is IRibbonControl)
                {
                    RibbonSizeCollection reduction = RibbonBar.GetReduction(e);
                    int m = reduction != null ? reduction.Count : 3;
                    max = Math.Max(max, m);
                }
                if (e is IRibbonGallery)
                {
                    RibbonGalleryColumns columns = RibbonGallery.GetReductionColumns(e);
                    int m = columns != null ? columns.Count : 3;
                    max = Math.Max(max, m);
                }
            }
            return(max);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string str = value as string;

            if (str == null)
            {
                return(base.ConvertFrom(context, culture, value));
            }
            str = str.Trim();
            if (str.Length == 0)
            {
                return(null);
            }

            string[]             names      = str.Split(',');
            RibbonGalleryColumns collection = new RibbonGalleryColumns();

            foreach (string name in names)
            {
                collection.Add(int.Parse(name));
            }
            return(collection);
        }
예제 #6
0
		public static void SetReductionColumns(DependencyObject obj, RibbonGalleryColumns value)
		{
			obj.SetValue(ReductionColumnsProperty, value);
		}
예제 #7
0
 public static void SetReductionColumns(DependencyObject obj, RibbonGalleryColumns value)
 {
     obj.SetValue(ReductionColumnsProperty, value);
 }