Exemplo n.º 1
0
        private void MoveItems(RadListBox left,
                               RadItemCollection leftCollection,
                               RadListBox right,
                               RadItemCollection rigthCollection,
                               int countItemsToMove)
        {
            if (left.Items.Count == 0)
            {
                return;
            }

            if (left.SelectedItems.Count == 0)
            {
                for (int i = 0; i < countItemsToMove; ++i)
                {
                    RadItem itemToRemove = left.Items[0];
                    left.Items.Remove(itemToRemove);
                    right.Items.Add(itemToRemove);

                    itemToRemove = (RadItem)itemToRemove.Tag;
                    leftCollection.Remove(itemToRemove);
                    if (!rigthCollection.Contains(itemToRemove))
                    {
                        rigthCollection.Add(itemToRemove);
                    }
                }
            }
            else
            {
                for (int i = 0; i < left.SelectedItems.Count; ++i)
                {
                    RadItem itemToRemove = left.SelectedItems[i];
                    left.Items.Remove(itemToRemove);
                    right.Items.Add(itemToRemove);

                    itemToRemove = (RadItem)itemToRemove.Tag;
                    leftCollection.Remove(itemToRemove);
                    if (!rigthCollection.Contains(itemToRemove))
                    {
                        rigthCollection.Add(itemToRemove);
                    }
                }
            }
        }
 private void MoveItems(
     RadListControl left,
     RadItemCollection leftCollection,
     RadListControl right,
     RadItemCollection rigthCollection,
     int countItemsToMove)
 {
     if (left.Items.Count == 0)
     {
         return;
     }
     if (left.SelectedItems.Count == 0)
     {
         for (int index = 0; index < countItemsToMove; ++index)
         {
             RadListDataItem radListDataItem = left.Items[0];
             left.Items.Remove(radListDataItem);
             right.Items.Add(radListDataItem);
             RadItem tag = (RadItem)radListDataItem.Tag;
             leftCollection.Remove(tag);
             if (!rigthCollection.Contains(tag))
             {
                 rigthCollection.Add(tag);
             }
         }
     }
     else
     {
         for (int index = 0; index < left.SelectedItems.Count; ++index)
         {
             RadListDataItem selectedItem = left.SelectedItems[index];
             left.Items.Remove(selectedItem);
             right.Items.Add(selectedItem);
             RadItem tag = (RadItem)selectedItem.Tag;
             leftCollection.Remove(tag);
             if (!rigthCollection.Contains(tag))
             {
                 rigthCollection.Add(tag);
             }
         }
     }
 }
        private void radBtnRemoveTabs_Click(object sender, EventArgs e)
        {
            int indexOfSelectedItem = this.radListBoxTabItems.SelectedIndex;

            RadListBoxItem[] itemsToRemove = new RadListBoxItem[this.radListBoxTabItems.SelectedItems.Count];

            for (int index = 0; index < this.radListBoxTabItems.SelectedItems.Count; index++)
            {
                itemsToRemove[index] = this.radListBoxTabItems.SelectedItems[index] as RadListBoxItem;
            }

            for (int i = 0; i < itemsToRemove.Length; i++)
            {
                RadListBoxItem currentItem = itemsToRemove[i] as RadListBoxItem;

                RibbonTab tabToRemove = currentItem.Tag as RibbonTab;

                IComponentChangeService componentChangeService = this.host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

                if (componentChangeService != null)
                {
                    componentChangeService.OnComponentChanging(this.host.RootComponent, TypeDescriptor.GetProperties(this.host.RootComponent)["CommandTabs"]);

                    this.collection.Remove(tabToRemove);

                    if (tabToRemove.ContextualTabGroup != null)
                    {
                        ContextualTabGroup tabGroup = tabToRemove.ContextualTabGroup;
                        tabGroup.TabItems.Remove(tabToRemove);
                    }

                    componentChangeService.OnComponentChanged(this.host.RootComponent, TypeDescriptor.GetProperties(this.host.RootComponent)["CommandTabs"], null, null);

                    if (newlyAddedItems.Contains(tabToRemove))
                    {
                        this.newlyAddedItems.Remove(tabToRemove);
                    }

                    this.radListBoxTabItems.Items.Remove(currentItem);
                    this.host.DestroyComponent(tabToRemove);
                }
            }


            if (indexOfSelectedItem >= 0 && indexOfSelectedItem <= this.radListBoxTabItems.Items.Count)
            {
                if (indexOfSelectedItem == this.radListBoxTabItems.Items.Count)
                {
                    this.radListBoxTabItems.SelectedIndex = indexOfSelectedItem - 1;
                }
                else
                {
                    this.radListBoxTabItems.SelectedIndex = indexOfSelectedItem;
                }
            }

            if (this.radListBoxTabItems.Items.Count == 0)
            {
                this.propGridTabProperties.SelectedObject = null;
            }
        }