예제 #1
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 PspPalette();

            foreach (var pc in Colors)
            {
                p.Colors.Add(pc);
            }
            return(p);
        }
예제 #2
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);
     }
 }