Ejemplo n.º 1
0
        public static void ImportElementFromFile(string fileName, bool moveToSelectedTreeNode, string subDirectory = null)
        {
            string unpackDirectory;

            List <string> filesToAddToContent;
            List <string> codeFiles;

            Zipper.UnzipScreenOrEntityImport(fileName, out unpackDirectory, out filesToAddToContent, out codeFiles);

            string elementName = FileManager.RemovePath(FileManager.RemoveExtension(fileName));

            if (!string.IsNullOrEmpty(subDirectory))
            {
                elementName = subDirectory + elementName;
                elementName = elementName.Replace("/", "\\");
            }

            #region Get XML extension

            string extension = "";
            if (FileManager.GetExtension(fileName) == "entz")
            {
                extension = "entx";
            }
            else
            {
                extension = "scrx";
            }

            #endregion

            string   desiredNamespace = "";
            string   targetCs;
            IElement newElement = null;

            if (extension == "entx")
            {
                targetCs = ImportEntity(unpackDirectory, filesToAddToContent, codeFiles, elementName, extension, moveToSelectedTreeNode, ref desiredNamespace, ref newElement);
            }
            else
            {
                targetCs = ImportScreen(unpackDirectory, filesToAddToContent, codeFiles, elementName, extension, moveToSelectedTreeNode, ref desiredNamespace, ref newElement);
            }

            ResolveElementReferences(newElement);



            #region Refresh and save everything

            ElementViewWindow.SelectedNode = GlueState.Self.Find.ElementTreeNode(newElement);

            GlueCommands.Self.RefreshCommands.RefreshUiForSelectedElement();
            GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode();
            ProjectManager.SaveProjects();
            GluxCommands.Self.SaveGlux();

            #endregion
        }