Exemple #1
0
        private RadItem GetRibbonBarGroupChildren(RadItem item, ref int count, int index)
        {
            RadRibbonBarButtonGroup buttonGroup = item as RadRibbonBarButtonGroup;

            if (buttonGroup == null)
            {
                if (count == index)
                {
                    return(item);
                }
                else
                {
                    return(null);
                }
            }

            for (int i = 0; i < buttonGroup.Items.Count; i++)
            {
                count++;
                RadItem currentItem = this.GetRibbonBarGroupChildren(buttonGroup.Items[i], ref count, index);

                if (currentItem != null)
                {
                    return(currentItem);
                }
            }

            return(null);
        }
        private int GetRibbonBarGroupChildrenCount(RadItem item)
        {
            RadRibbonBarButtonGroup ribbonBarButtonGroup = item as RadRibbonBarButtonGroup;

            if (ribbonBarButtonGroup == null)
            {
                return(1);
            }
            int num = 0;

            for (int index = 0; index < ribbonBarButtonGroup.Items.Count; ++index)
            {
                num += this.GetRibbonBarGroupChildrenCount(ribbonBarButtonGroup.Items[index]);
            }
            return(num);
        }
Exemple #3
0
        private int GetRibbonBarGroupChildrenCount(RadItem item)
        {
            RadRibbonBarButtonGroup buttonGroup = item as RadRibbonBarButtonGroup;

            if (buttonGroup == null)
            {
                return(1);
            }

            int count = 0;

            for (int i = 0; i < buttonGroup.Items.Count; ++i)
            {
                count += this.GetRibbonBarGroupChildrenCount(buttonGroup.Items[i]);
            }

            return(count);
        }
        public RadItem GetButtonGroupSelectedItem(RadItem item)
        {
            RadRibbonBarButtonGroup ribbonBarButtonGroup = item as RadRibbonBarButtonGroup;

            if (ribbonBarButtonGroup != null)
            {
                foreach (RadItem radItem in (RadItemCollection)ribbonBarButtonGroup.Items)
                {
                    RadItem groupSelectedItem = this.GetButtonGroupSelectedItem(radItem);
                    if (groupSelectedItem != null)
                    {
                        return(groupSelectedItem);
                    }
                }
            }
            else if (item.IsMouseOver)
            {
                return(item);
            }
            return((RadItem)null);
        }
        private RadItem GetRibbonBarGroupChildren(RadItem item, ref int count, int index)
        {
            RadRibbonBarButtonGroup ribbonBarButtonGroup = item as RadRibbonBarButtonGroup;

            if (ribbonBarButtonGroup != null)
            {
                for (int index1 = 0; index1 < ribbonBarButtonGroup.Items.Count; ++index1)
                {
                    RadItem barGroupChildren = this.GetRibbonBarGroupChildren(ribbonBarButtonGroup.Items[index1], ref count, index);
                    if (barGroupChildren != null)
                    {
                        return(barGroupChildren);
                    }
                }
                return((RadItem)null);
            }
            if (count == index)
            {
                return(item);
            }
            ++count;
            return((RadItem)null);
        }
        private void ItemChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
        {
            this.invalidateCollapsableChildrenCollection = true;

            if (operation != ItemsChangeOperation.Inserted &&
                operation != ItemsChangeOperation.Set)
            {
                return;
            }

            if (target.GetType() == typeof(RadButtonElement))
            {
                RadButtonElement buttonElement = target as RadButtonElement;

                if (string.IsNullOrEmpty(buttonElement.Class))
                {
                    buttonElement.Class = "RibbonBarButtonElement";
                }

                buttonElement.ButtonFillElement.Class = "ButtonInRibbonFill";
                buttonElement.BorderElement.Class     = "ButtonInRibbonBorder";
            }
            else if (target is RadRibbonBarButtonGroup)
            {
                RadRibbonBarButtonGroup buttonGroup = (RadRibbonBarButtonGroup)target;
                buttonGroup.MinSize = new Size(22, 22);
            }
            else if (target is RadComboBoxElement || target is RadDropDownListElement)
            {
                target.MinSize           = new Size(140, 0);
                target.StretchVertically = false;
                target.AutoSizeMode      = RadAutoSizeMode.WrapAroundChildren;
            }
            else if (target.GetType() == typeof(RadRadioButtonElement))
            {
                target.MinSize           = new Size(20, 0);
                target.StretchVertically = false;
                target.AutoSizeMode      = RadAutoSizeMode.WrapAroundChildren;
            }
            else if (target is RadTextBoxElement)
            {
                target.MinSize      = new Size(140, 0);
                target.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;

                // The border size is more correct in without horizontal padding
                Padding temp = target.Padding;
                temp.Left      = 0;
                temp.Right     = 0;
                target.Padding = temp;
            }
            else if (target is RadGalleryElement)
            {
                target.Padding = new Padding(2, 2, 0, 0);
            }
            else if (target.GetType() == typeof(RadCheckBoxElement))
            {
                target.StretchVertically = false;
            }
            //Georgi: TODO: Why SplitButton needs special attention and DropDownButton no???
            //else if (target is RadSplitButtonElement)
            //{
            //    target.StretchHorizontally = false;
            //    target.StretchVertically = false;
            //    target.Children[0].Visibility = ElementVisibility.Hidden;
            //}

            target.NotifyParentOnMouseInput = true;
        }
        /// <summary>
        /// Fires ItemChanged event.
        ///</summary>
        public void ItemChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
        {
            if (operation == ItemsChangeOperation.Inserted || operation == ItemsChangeOperation.Removed)
            {
                this.ResetItemsIsAtUnevenIndexProperty();
            }

            this.invalidateCollapsableChildrenCollection = true;
            if (operation == ItemsChangeOperation.Inserted ||
                operation == ItemsChangeOperation.Set)
            {
                target.NotifyParentOnMouseInput = true;
                if (target.GetType() == typeof(RadButtonElement))
                {
                    RadButtonElement buttonElement = target as RadButtonElement;
                    buttonElement.ButtonFillElement.Class = "ButtonInRibbonFill";
                    buttonElement.ThemeRole = "ButtonInRibbonButtonGroup";
                    SynchShowBorder(buttonElement);
                }

                if (target.GetType() == typeof(RibbonBarGroupSeparator))
                {
                    target.SetDefaultValueOverride(RibbonBarGroupSeparator.OrientationProperty, this.Orientation);
                }

                if (target is RadRibbonBarButtonGroup)
                {
                    RadRibbonBarButtonGroup buttonGroup = (RadRibbonBarButtonGroup)target;
                    buttonGroup.SetDefaultValueOverride(RadElement.MinSizeProperty, new Size(22, 22));
                }
                if (target is RadComboBoxElement || target is RadDropDownListElement)
                {
                    target.SetDefaultValueOverride(RadElement.MinSizeProperty, new Size(140, 0));
                    target.SetDefaultValueOverride(RadElement.AutoSizeModeProperty, RadAutoSizeMode.WrapAroundChildren);
                }
                if (target is RadTextBoxElement)
                {
                    RadTextBoxElement textBoxElement = (RadTextBoxElement)target;
                    target.SetDefaultValueOverride(RadElement.MinSizeProperty, new Size(140, 0));
                    target.SetDefaultValueOverride(RadElement.AutoSizeModeProperty, RadAutoSizeMode.WrapAroundChildren);
                    //// The border size is more correct in without horizontal padding
                    Padding temp = textBoxElement.Padding;
                    temp.Left              = 0;
                    temp.Right             = 0;
                    textBoxElement.Padding = temp;
                    textBoxElement.SetDefaultValueOverride(RadElement.PaddingProperty, temp);
                }
                if (target is RadGalleryElement)
                {
                    target.SetDefaultValueOverride(RadElement.PaddingProperty, new Padding(2, 2, 0, 0));
                }
                if (target is RadSplitButtonElement)
                {
                    target.SetDefaultValueOverride(RadElement.StretchHorizontallyProperty, false);
                    target.Children[0].SetDefaultValueOverride(RadElement.VisibilityProperty, ElementVisibility.Hidden);
                }
                if (target is RadCheckBoxElement)
                {
                    target.SetDefaultValueOverride(RadElement.StretchVerticallyProperty, false);
                }
                if (target is RadRadioButtonElement)
                {
                    target.SetDefaultValueOverride(RadElement.StretchVerticallyProperty, false);
                    target.SetDefaultValueOverride(RadElement.AutoSizeModeProperty, RadAutoSizeMode.WrapAroundChildren);
                }
            }
        }