Ejemplo n.º 1
0
 public static PPCollection LoadCollection(string zipFilename)
 {
     using (Package package = Package.Open(zipFilename, FileMode.Open))
     {
         if (!package.PartExists(URI_PART_COLLECTION))
         {
             throw new FileFormatException("Collection zip file does not include list of projects.");
         }
         string[] projectFileNames = package.GetPart(URI_PART_COLLECTION).GetStream().StreamToByteArray().ByteArrayToText().Where(x => !String.IsNullOrEmpty(x)).ToArray();
         WithoutHaste.Drawing.Colors.ColorPalette colorPalette = null;
         if (package.PartExists(URI_PART_PALETTE))
         {
             string[]  paletteLines = package.GetPart(URI_PART_PALETTE).GetStream().StreamToByteArray().ByteArrayToText();
             FormatGPL gpl          = new FormatGPL(paletteLines);
             colorPalette = gpl.ColorPalette;
         }
         PPConfig config = null;
         if (package.PartExists(URI_PART_CONFIG))
         {
             string[] configLines = package.GetPart(URI_PART_CONFIG).GetStream().StreamToByteArray().ByteArrayToText();
             config = new PPConfig(configLines);
         }
         return(new PPCollection(projectFileNames, config, colorPalette));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true when options or values have changed.
        /// </summary>
        private bool OptionsHaveChanged(PPConfig.PaletteOptions paletteOption, WithoutHaste.Drawing.Colors.ColorPalette colorPalette = null, string paletteFileName = null)
        {
            if (Config.PaletteOption == paletteOption)
            {
                switch (Config.PaletteOption)
                {
                case PPConfig.PaletteOptions.SaveNothing:
                    return(false);

                case PPConfig.PaletteOptions.SaveFile:
                    if (ColorPalette == colorPalette)
                    {
                        return(false);
                    }
                    break;

                case PPConfig.PaletteOptions.SaveFileName:
                    if (Config.PaletteFileName == paletteFileName)
                    {
                        return(false);
                    }
                    break;
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public void SetPaletteOption(PPConfig.PaletteOptions paletteOption, WithoutHaste.Drawing.Colors.ColorPalette colorPalette = null, string paletteFileName = null)
        {
            if (!OptionsHaveChanged(paletteOption, colorPalette, paletteFileName))
            {
                return;
            }

            Config.PaletteOption = paletteOption;
            switch (Config.PaletteOption)
            {
            case PPConfig.PaletteOptions.SaveNothing:
                Config.PaletteFileName = null;
                ColorPalette           = null;
                break;

            case PPConfig.PaletteOptions.SaveFile:
                Config.PaletteFileName = null;
                ColorPalette           = colorPalette;
                break;

            case PPConfig.PaletteOptions.SaveFileName:
                Config.PaletteFileName = paletteFileName;
                ColorPalette           = null;
                break;
            }
            EditedSinceLastSave = true;
        }
Ejemplo n.º 4
0
        public void UpdatePaletteOption(WithoutHaste.Drawing.Colors.ColorPalette colorPalette = null, string paletteFileName = null)
        {
            switch (Config.PaletteOption)
            {
            case PPConfig.PaletteOptions.SaveNothing:
                return;

            case PPConfig.PaletteOptions.SaveFile:
                ColorPalette = colorPalette;
                break;

            case PPConfig.PaletteOptions.SaveFileName:
                Config.PaletteFileName = paletteFileName;
                break;
            }
            EditedSinceLastSave = true;
        }
 /// <summary>Save color palette in standard .gpl format</summary>
 /// <param name="fullFilename">Path + filename + extension.</param>
 public static void Save(string fullFilename, ColorPalette palette)
 {
     string[] fileLines = ToTextFormat(palette);
     File.WriteAllLines(fullFilename, fileLines);
 }