예제 #1
0
        public void UnExecute()
        {
            StageView   stage = MainForm.CurrentStage;
            LibraryView currentLibraryView = MainForm.CurrentLibraryView;

            if (addToStage)
            {
                for (int i = 0; i < addInstanceCommands.Count; i++)
                {
                    addInstanceCommands[i].UnExecute();
                }
                addInstanceCommands.Clear();
                stage.InvalidateAll();
            }

            for (int i = 0; i < libraryItems.Length; i++)
            {
                currentLibraryView.RemoveItemFromLibrary(libraryItems[i].DefinitionId);
            }
            libraryItems = null;

            if (currentLibraryView.GetSelectedNode() == null && libraryItems.Length > 0)
            {
                currentLibraryView.SelectNode(libraryItems[0].DefinitionId);
            }
            else
            {
                currentLibraryView.RefreshCurrentNode();
            }


            stage.HasSaveableChanges = true;
            currentLibraryView.Invalidate();
        }
예제 #2
0
        public static List <LibraryItem> ImportFile(string filename)
        {
            List <LibraryItem> result = new List <LibraryItem>();
            string             ext    = Path.GetExtension(filename).ToUpperInvariant();

            if (ext == ".SWF")
            {
                LibraryItem[] items = currentLibraryView.AddSwf(filename);
                result.AddRange(items);
            }
            else if (ext == ".BMP" || ext == ".JPG" || ext == ".GIF" || ext == ".PNG")
            {
                LibraryItem item = currentLibraryView.AddImage(filename);
                result.Add(item);
            }

            if (currentLibraryView.GetSelectedNode() == null && result.Count > 0)
            {
                currentLibraryView.SelectNode(result[0].DefinitionId);
            }
            else
            {
                currentLibraryView.RefreshCurrentNode();
            }

            currentStage.HasSaveableChanges = true;

            currentStage.InvalidateAll();
            currentLibraryView.Invalidate();
            return(result);
        }
예제 #3
0
        public void Execute()
        {
            StageView   stage = MainForm.CurrentStage;
            LibraryView currentLibraryView = MainForm.CurrentLibraryView;

            string ext = Path.GetExtension(filename).ToUpperInvariant();

            if (ext == ".SWF")
            {
                libraryItems = currentLibraryView.AddSwf(filename);
            }
            else if (ext == ".BMP" || ext == ".JPG" || ext == ".GIF" || ext == ".PNG")
            {
                libraryItems = new LibraryItem[] { currentLibraryView.AddImage(filename) };
            }

            if (currentLibraryView.GetSelectedNode() == null && libraryItems.Length > 0)
            {
                currentLibraryView.SelectNode(libraryItems[0].DefinitionId);
            }
            else
            {
                currentLibraryView.RefreshCurrentNode();
            }

            if (addToStage)
            {
                uint[]      itemIds = new uint[libraryItems.Length];
                Vex.Point[] locs    = new Vex.Point[libraryItems.Length];

                for (int i = 0; i < libraryItems.Length; i++)
                {
                    itemIds[i] = libraryItems[i].Definition.Id;
                    Vex.Point centerOffset = libraryItems[i].Definition.StrokeBounds.Center.Negate();
                    locs[i] = location.Translate(centerOffset);
                }
                AddInstancesCommand aic = new AddInstancesCommand(itemIds, locs);
                aic.Execute();
                addInstanceCommands.Add(aic);
                stage.InvalidateAll();
            }

            stage.HasSaveableChanges = true;
            currentLibraryView.Invalidate();
        }
예제 #4
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();
        }