Exemplo n.º 1
0
        public void Execute()
        {
            StageView   stage   = MainForm.CurrentStage;
            Library     lib     = MainForm.CurrentLibrary;
            LibraryView libView = MainForm.CurrentLibraryView;

            List <LibraryTreeNode> remNodes   = new List <LibraryTreeNode>();
            List <string>          remPaths   = new List <string>();
            List <int>             remIndexes = new List <int>();

            selectedNode = libView.GetSelectedNode();

            for (int i = 0; i < libraryIds.Length; i++)
            {
                uint id = libraryIds[i];

                uint[] uis = lib.FindAllUsagesOfDefinition(id);
                removedInstances = stage.RemoveInstancesByIdGlobal(uis);

                LibraryItem li = lib[id];
                if (li != null)
                {
                    TreeNode tn = libView.FindNode(id);

                    if (tn != null && tn is LibraryTreeNode)
                    {
                        LibraryTreeNode liv = (LibraryTreeNode)tn;
                        remNodes.Add(liv);
                        remPaths.Add(liv.FullPath);
                        remIndexes.Add(liv.Index);

                        lib.RemoveLibraryItem(liv.item);
                        tn.Remove();
                    }
                }
            }

            removedTreeNodes = remNodes.ToArray();
            removedPaths     = remPaths.ToArray();
            removedIndexes   = remIndexes.ToArray();
            stage.InvalidateAll();
            libView.RefreshCurrentNode();
        }