/// <summary> /// Saves loaded image using GUI set format and save path. /// </summary> public void Save() { Status = "Saving..."; string tempformat = SelectedFormat; if (tempformat.Contains("\\")) { tempformat = tempformat.Split('\\')[0]; } if (tempformat.Contains('/')) { tempformat = tempformat.Split('/')[0]; } // KFreon: DDS's if (SelectedFormat.Contains("DXT") || SelectedFormat.Contains("V8U8") || SelectedFormat.Contains("ATI")) { ResIL.Unmanaged.CompressedDataFormat surface = (ResIL.Unmanaged.CompressedDataFormat)Enum.Parse(typeof(ResIL.Unmanaged.CompressedDataFormat), tempformat); img.ConvertAndSave(ResIL.Unmanaged.ImageType.Dds, SavePath, GenerateMips ? ResILImage.MipMapMode.BuildAll : ResILImage.MipMapMode.None, surface); } else // KFreon: Everything else { ResIL.Unmanaged.ImageType type = (ResIL.Unmanaged.ImageType)Enum.Parse(typeof(ResIL.Unmanaged.ImageType), tempformat); img.ConvertAndSave(type, SavePath); } Status = "Saved!"; }
public void DownloadVideo() { string arguments = ""; string output = ""; bool completedDownload = false; string progress = ""; if (!Directory.Exists(Path)) { MessageBox.Show(Localization.Strings.InvalidPath, Localization.Strings.Error); } else { if (SelectedFormat != "default") { switch (SelectedFormat) { case string s when(s == "mp3" || s == "flac"): arguments += "--prefer-ffmpeg --extract-audio --audio-format " + SelectedFormat; break; default: arguments += "-f "; if (SelectedFormat.Contains(" ")) { arguments += SelectedFormat.Substring(0, SelectedFormat.IndexOf(" ")); if (SelectedFormat.Substring(SelectedFormat.Length - 1) == "y") { int spaceIndex = SelectedFormat.IndexOf(" "); arguments += SelectedFormat.Contains("mp4") ? "+bestaudio[ext!=webm]" : "+bestaudio[ext=webm]"; arguments += " --merge-output-format" + SelectedFormat.Substring(spaceIndex, SelectedFormat.Length - spaceIndex - 2); } } else { arguments += SelectedFormat.Substring(0, SelectedFormat.Length - 2); } break; } } arguments += SelectedFormat == "default" ? "-o \"" + Path + Name + "\"" : " -o \"" + Path + Name + "\""; arguments += " -i " + ID; ytbDLInfo.Arguments = arguments; ytbDL = Process.Start(ytbDLInfo); ytbDL.OutputDataReceived += new DataReceivedEventHandler( (s, f) => { output = f.Data ?? "null"; if (output.Contains("[download]") && output.Contains("of")) { if (output.Contains("at") && output.Contains("MiB") && !output.Contains("Destination")) { string downloadSpeed = output.Substring(output.IndexOf("at") + 3, output.IndexOf("ETA") - output.IndexOf("at") - 3); mw.BeginInvoke((Action)(() => { mw.DownloadSpeed.Text = downloadSpeed; })); progress = output.Substring(output.LastIndexOf("[download]") + 11, output.LastIndexOf("%") - 11); progress = progress.Contains(".") ? progress.Substring(0, progress.IndexOf(".")) : progress; } mw.BeginInvoke((Action)(() => { mw.DownloadStatus.Text = Localization.Strings.Downloading; mw.DownloadPercentage.Text = progress + "%"; mw.DownloadProgressBar.Value = progress != "" ? Int16.Parse(progress) : 0; })); completedDownload = true; } else { mw.BeginInvoke((Action)(() => { mw.DownloadStatus.Text = output.Contains("[ffmpeg]") ? Localization.Strings.FFMpeg : Localization.Strings.StartingUp; })); } if (output != "null" && Properties.Settings.Default.VerboseStatus) { mw.BeginInvoke((Action)(() => { mw.VerboseStatus.Text = output; })); } } ); ytbDL.Start(); ytbDL.BeginOutputReadLine(); ytbDL.WaitForExit(); ytbDL.CancelOutputRead(); if (!completedDownload) { MessageBox.Show(Localization.Strings.InvalidFiletype, Localization.Strings.Error); } mw.BeginInvoke((Action)(() => { mw.DownloadSpeed.Text = "0.0 MiB/s"; mw.VerboseStatus.Text = ""; mw.DownloadPercentage.Text = "0%"; mw.ClearCard(); mw.DownloadProgressBar.Value = 0; mw.DownloadStatus.Text = Localization.Strings.NoDownload; })); arguments = ""; } }