/// <summary>
        /// This method reorders the TabStrip items so that they are positioned under the
        /// ContextualTabGroup they are associated with. All tab items that are
        /// associated with a tab groups should be positioned on the right side of the tab strip.
        /// This algorithm begins iterating from the first to the last contextual tab group as they
        /// appear in the collection of the ribbon bar. The associated tab items are always inserted
        /// at the end of the tab strip. In this way the effect of positioning the last associated
        /// tab item at the end of the corresponding contextual group is achieved.
        /// </summary>
        private void ResetAssociatedTabItems()
        {
            RibbonTab selectedTab = this.tabStripElement.SelectedItem as RibbonTab;

            List <RadItem> scheduledItemsForDeletion = new List <RadItem>();

            for (int i = 0; i < this.contextualTabGroups.Count; i++)
            {
                ContextualTabGroup currentGroup = this.contextualTabGroups[i] as ContextualTabGroup;

                for (int k = 0; k < currentGroup.TabItems.Count; k++)
                {
                    RadPageViewItem currentItem = currentGroup.TabItems[k] as RadPageViewItem;

                    for (int j = 0; j < this.tabStripElement.Items.Count; ++j)
                    {
                        if (((RibbonTab)this.tabStripElement.Items[j]).obsoleteTab == currentItem)
                        {
                            currentItem = (RibbonTab)this.tabStripElement.Items[j];
                            currentGroup.TabItems[k] = currentItem;
                        }
                    }

                    if (this.tabStripElement.Items.Contains(currentItem) &&
                        !(bool)currentItem.GetValue(RadItem.IsAddNewItemProperty) &&
                        currentItem.Parent != null)
                    {
                        this.tabStripElement.RemoveItem(currentItem);

                        if (this.IsDesignMode)
                        {
                            if (this.tabStripElement.Items.Count == 0)
                            {
                                this.tabStripElement.InsertItem(this.tabStripElement.Items.Count, currentItem);
                            }
                            else
                            {
                                this.tabStripElement.InsertItem(this.tabStripElement.Items.Count - 1, currentItem);
                            }
                        }
                        else
                        {
                            this.tabStripElement.InsertItem(this.tabStripElement.Items.Count, currentItem);
                        }
                    }
                }
            }

            this.tabStripElement.SelectedItem = selectedTab;
        }
 private void FillAvaibleTabs(RadRibbonBar parentRibbon)
 {
     this.ribbonBarTabs = new RadItemCollection();
     foreach (RadItem radItem in (IEnumerable <RadPageViewItem>)parentRibbon.RibbonBarElement.TabStripElement.Items)
     {
         RibbonTab ribbonTab = radItem as RibbonTab;
         if (ribbonTab != null && ribbonTab.CanBeAddedToContextualGroup)
         {
             this.ribbonBarTabs.Add(radItem);
         }
     }
     for (int index = 0; index < this.ribbonBarTabs.Count; ++index)
     {
         RadPageViewItem ribbonBarTab = (RadPageViewItem)this.ribbonBarTabs[index];
         if (this.ContextualGroupsNotContainsThisTab(parentRibbon, ribbonBarTab) && !(bool)ribbonBarTab.GetValue(RadItem.IsAddNewItemProperty))
         {
             this.radListBoxAvaibleTabs.Items.Add(new RadListDataItem(ribbonBarTab.Text)
             {
                 Tag = (object)ribbonBarTab
             });
         }
     }
 }
Esempio n. 3
0
        private void ResetAssociatedTabItems()
        {
            RibbonTab      selectedItem = this.RibbonBarElement.TabStripElement.SelectedItem as RibbonTab;
            List <RadItem> radItemList  = new List <RadItem>();

            this.ResetTabPositions();
            for (int index1 = 0; index1 < this.RibbonBarElement.ContextualTabGroups.Count; ++index1)
            {
                ContextualTabGroup contextualTabGroup = this.RibbonBarElement.ContextualTabGroups[index1] as ContextualTabGroup;
                for (int index2 = 0; index2 < contextualTabGroup.TabItems.Count; ++index2)
                {
                    RadPageViewItem tabItem = contextualTabGroup.TabItems[index2] as RadPageViewItem;
                    for (int index3 = 0; index3 < this.RibbonBarElement.TabStripElement.Items.Count; ++index3)
                    {
                        if (((RibbonTab)this.RibbonBarElement.TabStripElement.Items[index3]).obsoleteTab == tabItem)
                        {
                            tabItem = this.RibbonBarElement.TabStripElement.Items[index3];
                            contextualTabGroup.TabItems[index2] = (RadItem)tabItem;
                        }
                    }
                    if (this.RibbonBarElement.TabStripElement.Items.Contains(tabItem) && !(bool)tabItem.GetValue(RadItem.IsAddNewItemProperty) && tabItem.Parent != null)
                    {
                        this.RibbonBarElement.TabStripElement.RemoveItem(tabItem);
                        if (this.IsDesignMode)
                        {
                            if (this.RibbonBarElement.TabStripElement.Items.Count == 0)
                            {
                                this.RibbonBarElement.TabStripElement.InsertItem(this.RibbonBarElement.TabStripElement.Items.Count, tabItem);
                            }
                            else
                            {
                                this.RibbonBarElement.TabStripElement.InsertItem(this.RibbonBarElement.TabStripElement.Items.Count - 1, tabItem);
                            }
                        }
                        else
                        {
                            this.RibbonBarElement.TabStripElement.InsertItem(this.RibbonBarElement.TabStripElement.Items.Count, tabItem);
                        }
                    }
                }
            }
            this.RibbonBarElement.TabStripElement.SelectedItem = (RadPageViewItem)selectedItem;
        }