示例#1
0
        public ILuaEditDocumentFolder CreateNewFolder()
        {
            ILuaEditDocumentFolder newFolder = null;
            DirectoryInfo          dirInfo   = DocumentsManager.Instance.CreateDirectory(Path.GetDirectoryName(this.FileName));

            if (dirInfo != null)
            {
                newFolder = new DocumentFolder(dirInfo);
                AddDocument(newFolder);
            }

            return(newFolder);
        }
示例#2
0
        internal void FromXml(XmlLuaGroupDocumentBase objectToDeserialize)
        {
            // Deserialize sub-documents
            if (objectToDeserialize.Documents != null)
            {
                foreach (DocumentRef refDoc in objectToDeserialize.Documents)
                {
                    refDoc.FileName = Win32Utils.GetAbsolutePath(refDoc.FileName, _fileName);
                    ILuaEditDocument doc = DocumentsManager.Instance.BaseOpenDocument(refDoc);

                    if (doc != null)
                    {
                        this.AddDocument(doc);
                    }
                }
            }

            // Deserialize sub-folders
            if (objectToDeserialize.DocumentFolders != null)
            {
                foreach (XmlDocumentFolder xmlFolder in objectToDeserialize.DocumentFolders)
                {
                    DocumentFolder folderDoc = new DocumentFolder();
                    folderDoc.ParentDocument = this;
                    folderDoc.FromXml(xmlFolder);

                    if (folderDoc != null)
                    {
                        this.AddDocument(folderDoc as ILuaEditDocumentFolder);
                    }
                }
            }

            // Deserialize sub-group documents
            if (objectToDeserialize.DocumentGroups != null)
            {
                foreach (DocumentRef refDoc in objectToDeserialize.DocumentGroups)
                {
                    refDoc.FileName = Win32Utils.GetAbsolutePath(refDoc.FileName, _fileName);
                    ILuaEditDocumentGroup docGrp = DocumentsManager.Instance.BaseOpenDocument(refDoc) as ILuaEditDocumentGroup;

                    if (docGrp != null)
                    {
                        this.AddDocument(docGrp);
                    }
                }
            }
        }
示例#3
0
        internal XmlLuaGroupDocumentBase ToXml(XmlLuaGroupDocumentBase objectToSerialize)
        {
            if (objectToSerialize == null)
            {
                objectToSerialize = new XmlLuaGroupDocumentBase();
            }

            // Serialize sub-documents
            int fileCount = 0;

            Array.Resize <LuaEdit.Documents.DocumentRef>(ref objectToSerialize.Documents, _documents.Count);
            foreach (ILuaEditDocument doc in _documents)
            {
                objectToSerialize.Documents[fileCount] = new DocumentRef(Win32Utils.GetRelativePath(doc.FileName, _fileName));
                ++fileCount;
            }

            // Serialize sub-folders
            int folderCount = 0;

            Array.Resize <XmlDocumentFolder>(ref objectToSerialize.DocumentFolders, _documentFolders.Count);
            foreach (ILuaEditDocumentFolder docFolder in _documentFolders)
            {
                DocumentFolder folder = docFolder as DocumentFolder;
                if (folder != null)
                {
                    objectToSerialize.DocumentFolders[folderCount] = folder.ToXml(null);
                    ++folderCount;
                }
            }

            // Serialize sub-group documents
            int grpCount = 0;

            Array.Resize <LuaEdit.Documents.DocumentRef>(ref objectToSerialize.DocumentGroups, _documentGroups.Count);
            foreach (ILuaEditDocumentGroup docGrp in _documentGroups)
            {
                objectToSerialize.DocumentGroups[grpCount] = new DocumentRef(Win32Utils.GetRelativePath(docGrp.FileName, _fileName));
                ++grpCount;
            }

            return(objectToSerialize);
        }