Esempio n. 1
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!commandTag.Equals(Commands.CreatePrefab))
            {
                return;
            }

            string filePath = Util.GetFilePath(m_fileFilter, Globals.ResourceRoot.LocalPath, true);

            if (!string.IsNullOrEmpty(filePath))
            {
                try
                {
                    // save selected gameobject to a new prototype file.
                    Uri     ur     = new Uri(filePath);
                    DomNode prefab = CreatePrefab(SelectedGobs);

                    string   filePathLocal = ur.LocalPath;
                    FileMode fileMode      = File.Exists(filePathLocal) ? FileMode.Truncate : FileMode.OpenOrCreate;
                    using (FileStream stream = new FileStream(filePathLocal, fileMode))
                    {
                        var writer = new CustomDomXmlWriter(Globals.ResourceRoot, m_schemaLoader.TypeCollection);
                        writer.Write(prefab, stream, ur);
                    }
                    m_resourceService.Unload(ur);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
        }
Esempio n. 2
0
        public void Save(Uri uri, SchemaLoader schemaLoader)
        {
            if (Dirty || m_uriChanged)
            {
                string   filePath = uri.LocalPath;
                FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;
                using (FileStream stream = new FileStream(filePath, fileMode))
                {
                    var writer = new CustomDomXmlWriter(Globals.ResourceRoot, schemaLoader.TypeCollection);
                    writer.Write(DomNode, stream, uri);
                }
                m_uriChanged = false;
            }

            // save all the game-references
            foreach (var gameRef in GetChildList <GameReference>(Schema.gameType.gameReferenceChild))
            {
                GameDocument subDoc = Adapters.As <GameDocument>(gameRef.Target);
                if (subDoc == null)
                {
                    continue;
                }
                subDoc.Save(subDoc.Uri, schemaLoader);
            }

            Dirty = false;
        }
Esempio n. 3
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!commandTag.Equals(Commands.CreatePrototype))
                return;

            string filePath = Util.GetFilePath(m_fileFilter,Globals.ResourceRoot.LocalPath,true);
            if (!string.IsNullOrEmpty(filePath))
            {
                try
                {
                    // save selected gameobject to a new prototype file.
                    Uri ur = new Uri(filePath);
                    DomNode prototype = CreatePrototype(SelectedGobs);

                    string filePathLocal = ur.LocalPath;
                    FileMode fileMode = File.Exists(filePathLocal) ? FileMode.Truncate : FileMode.OpenOrCreate;
                    using (FileStream stream = new FileStream(filePathLocal, fileMode))
                    {
                        var writer = new CustomDomXmlWriter(Globals.ResourceRoot, m_schemaLoader.TypeCollection);
                        writer.Write(prototype, stream, ur);
                    }
                    m_resourceService.Unload(ur);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
        }
Esempio n. 4
0
 private static void SaveDomDocument(DomNode node, Uri uri, ISchemaLoader schemaLoader)
 {
     string filePath = uri.LocalPath;
     Directory.CreateDirectory(new FileInfo(filePath).Directory.FullName);
     FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;
     using (FileStream stream = new FileStream(filePath, fileMode))
     {
         var writer = new CustomDomXmlWriter(Globals.ResourceRoot, schemaLoader.TypeCollection);
         writer.Write(node, stream, uri);
     }
 }
Esempio n. 5
0
        private static void SaveDomDocument(DomNode node, Uri uri, ISchemaLoader schemaLoader)
        {
            string filePath = uri.LocalPath;

            Directory.CreateDirectory(new FileInfo(filePath).Directory.FullName);
            FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;

            using (FileStream stream = new FileStream(filePath, fileMode))
            {
                var writer = new CustomDomXmlWriter(uri, schemaLoader.TypeCollection);
                writer.Write(node, stream, uri);
            }
        }
Esempio n. 6
0
        public void Save(Uri uri, SchemaLoader schemaLoader)
        {
            if (Dirty || m_uriChanged)
            {                
                string filePath = uri.LocalPath;
                FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;
                using (FileStream stream = new FileStream(filePath, fileMode))
                {
                    var writer = new CustomDomXmlWriter(Globals.ResourceRoot, schemaLoader.TypeCollection);
                    writer.Write(DomNode, stream, uri);
                }
                m_uriChanged = false;
            }
            
            // save all the game-references
            foreach (var gameRef in GetChildList<GameReference>(Schema.gameType.gameReferenceChild))
            {
                GameDocument subDoc = Adapters.As<GameDocument>(gameRef.Target);
                if(subDoc == null) continue;
                subDoc.Save(subDoc.Uri, schemaLoader);                
            }

            Dirty = false;
        }