Esempio n. 1
0
 public void OpenPalette(string fileName)
 {
     try
     {
         if (fileName.ToLower().EndsWith(".aco"))
         {
             var p = new AcoPalette(File.ReadAllBytes(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         else if (fileName.ToLower().EndsWith(".act"))
         {
             var p = new ActPalette(File.ReadAllBytes(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         else if (fileName.ToLower().EndsWith(".ase"))
         {
             var p = new AsePalette(File.ReadAllBytes(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         else if (fileName.ToLower().EndsWith(".acb"))
         {
             var p = new AcbPalette(File.ReadAllBytes(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         else if (fileName.ToLower().EndsWith(".pal"))
         {
             var p = new MsRiffPalette(File.ReadAllBytes(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         else if (fileName.ToLower().EndsWith(".gpl"))
         {
             var p = new GimpPalette(File.ReadAllLines(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         else if (fileName.ToLower().EndsWith(".psppalette"))
         {
             var p = new PspPalette(File.ReadAllLines(fileName));
             appPal.NewFromPalette(p, fileName);
         }
         // implied to be native palette
         else
         {
             var p = NativePalette.CreateFromFile(File.ReadAllText(fileName));
             appPal.NewFromPalette(p, fileName);
         }
     }
     catch (PaletteException e)
     {
         MessageBox.Show(this, e.Message, "Palette Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Creates a new palette with properties identical to the old one.
        /// </summary>
        /// <remarks>
        /// This is intended for changing the properties of a palette, while
        /// preserving the old version's properties, due to changing the
        /// reference.
        /// </remarks>
        /// <returns>The new palette.</returns>
        public IPalette Clone()
        {
            var p = new NativePalette();

            p.Name       = Name;
            p.BucketSize = BucketSize;
            p.Colors     = new List <PaletteColor>();
            // simply copying the list doesn't make it deep but a fill
            // deep copy would make the colors different; not desirable
            foreach (var pc in Colors)
            {
                p.Colors.Add(pc);
            }
            return(p);
        }