예제 #1
0
        public void Save(MetadataPackage package, string path, ProjectType projectType)
        {
            string projectFolder = Path.GetDirectoryName(path);

            if (!Directory.Exists(projectFolder))
            {
                Directory.CreateDirectory(projectFolder);
            }

            _settings = new CfProjectSettings()
            {
                Type               = projectType,
                Version            = package.GetType().Assembly.GetName().Version.ToString(),
                MdInternalsVersion = this.GetType().Assembly.GetName().Version.ToString(),
                PackageType        = package.GetType().FullName
            };

            package.MetadataObjects.AsParallel().ForAll(m =>
            {
                string relativePath = GetRelativePath(m, projectType);
                FileInfo fileInfo   = null;
                if (m.ImageRow.BodyType == ImageRowTypes.CompressedImage)
                {
                    fileInfo = UnloadImage(projectFolder, relativePath, m, projectType);
                }
                else
                {
                    fileInfo = UnloadElement(projectFolder, relativePath, m, projectType);
                }

                lock (this._settings)
                {
                    this._settings.Files.Add(fileInfo);
                }
            });

            var settings = new XmlWriterSettings()
            {
                Indent = true
            };

            using (XmlWriter xmlWriter = XmlWriter.Create(path, settings))
            {
                System.Windows.Markup.XamlWriter.Save(_settings, xmlWriter);
            }
        }
예제 #2
0
        public void Save(MetadataPackage package, string folder, ProjectType projectType)
        {
            _settings = new CfProjectSettings()
            {
                Type = projectType
            };
            package.MetadataObjects.AsParallel().ForAll(m => UnloadObject(folder, m as ImageRowElement, projectType));

            var settings = new XmlWriterSettings()
            {
                Indent = true
            };

            using (XmlWriter xmlWriter = XmlWriter.Create(folder + "/" + package.PackagePart.GeneralProperties.Name + ".cfproj", settings))
            {
                System.Windows.Markup.XamlWriter.Save(_settings, xmlWriter);
            }
        }
예제 #3
0
        public Image LoadImage(string path)
        {
            using (XmlReader xmlReader = XmlReader.Create(path))
            {
                _settings = System.Windows.Markup.XamlReader.Load(xmlReader) as CfProjectSettings;
            }

            Image image = new Image();

            string folder = Path.GetDirectoryName(path);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            image.Rows = CreateImageRows(folder);

            return(image);
        }