Example #1
0
 /// <summary>
 /// Saved a zipped Perpetual Paint Collection file.
 /// </summary>
 /// <remarks>
 /// Creates or overwrites <paramref name='zipFilename'/>.
 ///
 /// Handles:
 /// - include entire palette
 /// - include filename of palette (in config)
 /// - include no palette information
 /// </remarks>
 public static void ZipCollection(string zipFilename, PPCollection collection)
 {
     byte[] zippedBytes;
     using (MemoryStream zipStream = new MemoryStream())
     {
         using (Package package = Package.Open(zipStream, FileMode.Create))
         {
             PackagePart collectionDocument = package.CreatePart(URI_PART_COLLECTION, "");
             using (MemoryStream dataStream = new MemoryStream(collection.ToTextFormat().ToByteArray()))
             {
                 collectionDocument.GetStream().WriteAll(dataStream);
             }
             if (collection.ColorPalette != null)
             {
                 PackagePart paletteDocument = package.CreatePart(URI_PART_PALETTE, "");
                 using (MemoryStream dataStream = new MemoryStream(FormatGPL.ToTextFormat(collection.ColorPalette).ToByteArray()))
                 {
                     paletteDocument.GetStream().WriteAll(dataStream);
                 }
             }
             if (collection.Config != null)
             {
                 PackagePart configDocument = package.CreatePart(URI_PART_CONFIG, "");
                 using (MemoryStream dataStream = new MemoryStream(collection.Config.ToTextFormat().ToByteArray()))
                 {
                     configDocument.GetStream().WriteAll(dataStream);
                 }
             }
         }
         zippedBytes = zipStream.ToArray();
     }
     File.WriteAllBytes(zipFilename, zippedBytes);
 }
        /// <summary>
        /// Loads collection from file.
        /// </summary>
        public static PPCollection Load(string fullFileName)
        {
            PPCollection collection = IO.LoadCollection(fullFileName);

            collection.EditedSinceLastSave = false;
            return(collection);
        }