private void MainForm_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (IOUtils.IsPathDirectory(file)) { Logger.Log("Setting directory to " + file); Program.currentDir = file; pathTextbox.Text = file; } else { Logger.Log("Previewing " + file + "..."); Program.PreviewImage(file); } } }
public static void ConvertFileList(string[] files, ComboBox qualityCombox, ComboBox qualityMaxCombox, IF selectedFormat, CheckBox delSrcCbox) { int qMin = qualityCombox.GetInt(); int qMax = qMin; if (!string.IsNullOrWhiteSpace(qualityMaxCombox.Text.Trim())) { qMax = qualityMaxCombox.GetInt(); } foreach (string file in files) { Program.Print("\nDropped File: " + Path.GetFileName(file).Truncate(90)); if (!IOUtils.IsPathDirectory(file)) { if (selectedFormat == IF.JPG) { ConvertUtils.ConvertToJpeg(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.PNG) { ConvertUtils.ConvertToPng(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.DDS) { if (Config.GetInt("ddsEnc") == 0) { ConvertUtils.ConvertToDds(file, delSrcCbox.Checked); } if (Config.GetInt("ddsEnc") == 1) { DdsInterface.NvCompress(file, Path.ChangeExtension(file, "dds"), delSrcCbox.Checked); } if (Config.GetInt("ddsEnc") == 2) { DdsInterface.Crunch(file, qMin, qMax, delSrcCbox.Checked); } } if (selectedFormat == IF.TGA) { ConvertUtils.ConvertToTga(file, delSrcCbox.Checked); } if (selectedFormat == IF.WEBP) { ConvertUtils.ConvertToWebp(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.J2K) { ConvertUtils.ConvertToJpeg2000(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.FLIF) { if (Config.GetInt("flifEnc") == 1) { FlifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } else { ConvertUtils.ConvertToFlif(file, qMin, delSrcCbox.Checked); } } if (selectedFormat == IF.BMP) { ConvertUtils.ConvertToBmp(file, delSrcCbox.Checked); } if (selectedFormat == IF.AVIF) { ConvertUtils.ConvertToAvif(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.HEIF) { HeifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } } } }
public static async Task ConvertFileList(string[] files, ComboBox qualityCombox, ComboBox qualityMaxCombox, IF selectedFormat, CheckBox delSrcCbox) { int qMin = qualityCombox.GetInt(); int qMax = qMin; if (!string.IsNullOrWhiteSpace(qualityMaxCombox.Text.Trim())) { qMax = qualityMaxCombox.GetInt(); } foreach (string file in files) { Logger.Log("\nDropped File: " + Path.GetFileName(file).Truncate(90)); if (!IOUtils.IsPathDirectory(file)) { if (selectedFormat == IF.JPG) { await ConvertUtils.ConvertToJpeg(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.PNG) { await ConvertUtils.ConvertToPng(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.DDS) { await ConvertUtils.ConvertToDds(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.TGA) { await ConvertUtils.ConvertToTga(file, delSrcCbox.Checked); } if (selectedFormat == IF.WEBP) { await ConvertUtils.ConvertToWebp(file, qMin, qMax, delSrcCbox.Checked); } if (selectedFormat == IF.J2K) { await ConvertUtils.ConvertToJpeg2000(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.FLIF) { if (await Config.GetInt("flifEnc") == 1) { await FlifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } else { await ConvertUtils.ConvertToFlif(file, qMin, delSrcCbox.Checked); } } if (selectedFormat == IF.BMP) { await ConvertUtils.ConvertToBmp(file, delSrcCbox.Checked); } if (selectedFormat == IF.AVIF) { await ConvertUtils.ConvertToAvif(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.HEIF) { await HeifInterface.EncodeImage(file, qMin, delSrcCbox.Checked); } if (selectedFormat == IF.JXL) { await ConvertUtils.ConvertToJxl(file, qMin, qMax, delSrcCbox.Checked); } } } }