private void ResultDLG_ItemSelectionChanged1(ListView.SelectedListViewItemCollection Selection)
        {
            IStep step = parent.GetCurrentStep();

            if (step != null)
            {
                foreach (ListViewItem lvi in Selection)
                {
                    if (step != null)
                    {
                        step.ClearSelection();
                        ((ICMPObject)lvi.Tag).Select(true);
                        step.TurnOffAllLayer();

                        IODBLayer layer = step.GetOutsideODBLayer(((ICMPObject)lvi.Tag).PlacedTop);
                        if (layer != null)
                        {
                            layer.EnableLayer(true);
                        }

                        parent.UpdateSelection();

                        PCBI.MathUtils.RectangleD zoomRect = ((ICMPObject)lvi.Tag).GetBoundsD();
                        if (zoomRect == PCBI.MathUtils.RectangleD.Empty)
                        {
                            parent.ZoomToSelection();
                        }
                        else
                        {
                            zoomRect.Inflate(zoomRect.Width * 0.5, zoomRect.Height * 0.5);
                            parent.ZoomRect(zoomRect);
                        }
                    }
                    else
                    {
                        ((ICMPObject)lvi.Tag).Select(true);
                        parent.UpdateSelection();
                        parent.UpdateView();
                    }
                }
            }
        }
        public void Execute(IPCBIWindow parent)
        {
            IFilter filter = new IFilter(parent);

            IStep curStep = parent.GetCurrentStep();

            if (curStep == null)
            {
                return;
            }

            List <IODBObject> selectedElements = curStep.GetSelectedElements();

            //create list with all selected elements to make a new symbol of it
            List <IObjectSpecificsD> newSymbolSpecs = new List <IObjectSpecificsD>();
            string relLayerName = "";

            PCBI.MathUtils.RectangleD bounds = new PCBI.MathUtils.RectangleD();
            int indexOfLastElement           = 1;

            foreach (IODBObject obj in selectedElements)
            {
                newSymbolSpecs.Add(obj.GetSpecificsD());
                relLayerName = obj.GetParentLayerName();
                if (bounds == RectangleD.Empty)
                {
                    bounds = obj.GetBoundsD();
                }
                else
                {
                    bounds = PCBI.MathUtils.RectangleD.Union(bounds, obj.GetBoundsD());
                }
                indexOfLastElement = obj.GetIndexOnLayer();
            }

            IODBLayer relLayer = (IODBLayer)curStep.GetLayer(relLayerName);

            if (relLayer == null)
            {
                return;
            }

            //create new symbol for pads, the name must be unique. We try it with the index of one of the elements.
            int nr = IFilter.AddToolDefinitionSpecial(relLayer, parent, "testsymbol3" + indexOfLastElement, newSymbolSpecs, -bounds.GetMidPoint().X, -bounds.GetMidPoint().Y);

            if (nr < 0)
            {
                //no new symbol was created, maybe name is already existing
                return;
            }

            //delete old elements
            IAutomation.SuppressUserNotifications = false; //otherwise the delete action will be blocked
            parent.UIAction.Execute(ID_ActionItem.ID_DELETE);

            IODBObject pad = filter.CreatePad(relLayer);

            IPadSpecificsD padSpec = (IPadSpecificsD)pad.GetSpecificsD();

            padSpec.Location = bounds.GetMidPoint();
            pad.SetSpecifics(padSpec, nr);
            pad.SetAttribute("new symbol attribute");

            pad.Select(true);

            parent.UpdateView();
        }