Exemple #1
0
        public void RemoveSelectedControls()
        {
            using (DesignerTransaction trans = CreateTransaction("Removing selected components")) {
                var selServ = GetService(typeof(ISelectionService)) as ISelectionService;
                if (selServ == null)
                {
                    throw new Exception("Could not get selection service");
                }

                ArrayList selectedItems = new ArrayList(selServ.GetSelectedComponents());

                for (int i = selectedItems.Count - 1; i >= 0; i--)
                {
                    var comp = selectedItems[i] as IComponent;

                    if (RootComponent.Equals(comp))
                    {
                        continue;
                    }

                    designerSerializer.RemoveControlTag(comp.Site.Name);
                    Container.Remove(comp);
                }
                trans.Commit();
            }
        }