private void exportPaletteToolStripMenuItem_Click(object sender, EventArgs e) { if (this.PaletteRects.Count == 0) { return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "pal"; saveFileDialog.Filter = "Microsoft Palette File(*.pal)|*.pal|SCI Local Palette(Extracted from FotoSCIhop)|*.pal|SCI Global Palette(Extracted from Resource)|*.pal|SCI ROOT Palette(999.pal)|*.pal"; saveFileDialog.OverwritePrompt = true; saveFileDialog.Title = "Exporting Palette, please choose a filename."; DialogResult r = saveFileDialog.ShowDialog(); if (r == System.Windows.Forms.DialogResult.Cancel) { return; } try { switch (saveFileDialog.FilterIndex) { case 1: PaletteTools.SaveMicrosoftPalette(saveFileDialog.FileName, this.PaletteRects.Values.ToArray()); break; case 2: PaletteTools.SaveLocalSCIPalette(saveFileDialog.FileName, this.PaletteRects.Values.ToArray()); break; case 3: PaletteTools.SaveGlobalSCIPalette(saveFileDialog.FileName, this.PaletteRects.Values.ToArray()); break; case 4: PaletteTools.SaveRootSCIPalette(saveFileDialog.FileName, this.PaletteRects.Values.ToArray()); break; } } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
/// <summary> /// Saves loaded palette as an SCI palette /// </summary> private void SaveSCIPal() { if (LoadedColors.Length == 0) { return; } // we have a few types of sci pal, sucks SaveFileDialog saveFileDialog = new SaveFileDialog(); /* * saveFileDialog.DefaultExt = "pal"; * saveFileDialog.Filter = "Microsoft Palette File(*.pal)|*.pal"; * saveFileDialog.OverwritePrompt = true; * saveFileDialog.Title = "Save as Microsoft Palette file."; */ // We have 3 different types of SCI *.pal, this lets you choose which to save as. saveFileDialog.DefaultExt = "pal"; saveFileDialog.Filter = "SCI Local Palette(Extracted from FotoSCIhop)|*.pal|SCI Global Palette(Extracted from Resource)|*.pal|SCI ROOT Palette(999.pal)|*.pal"; saveFileDialog.OverwritePrompt = true; saveFileDialog.Title = "Save Palette as SCI."; DialogResult r = saveFileDialog.ShowDialog(); if (r == System.Windows.Forms.DialogResult.Cancel) { return; } switch (saveFileDialog.FilterIndex) { case 1: { try { PaletteTools.SaveLocalSCIPalette(saveFileDialog.FileName, LoadedColors); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; case 2: { try { PaletteTools.SaveGlobalSCIPalette(saveFileDialog.FileName, LoadedColors); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; case 3: try { PaletteTools.SaveRootSCIPalette(saveFileDialog.FileName, LoadedColors); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; } }