public void allDone() { WaitingLoading loadingScreen = new WaitingLoading("Downloading Video Please wait..."); if (URLs.Count != 0) { this.Invoke((MethodInvoker) delegate() { loadingScreen.Owner = this; loadingScreen.Show(); }); } if (URLs.Count == 0) { this.Invoke((MethodInvoker) delegate() { button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; }); } while (true) { if (videoCount != 0) { if (videoCount >= URLs.Count) { URLs.Clear(); this.Invoke((MethodInvoker) delegate() { loadingScreen.Close(); }); MessageBox.Show("All downloads complete, right click on any song to open the downloads folder. You may also download more videos"); videoCount = 0; this.Invoke((MethodInvoker) delegate() { button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; }); break; } } } }
private void button3_Click(object sender, EventArgs e) { WaitingLoading loadingScreen = new WaitingLoading("Loading Video Information. This may take a few seconds..."); string URL = textBox1.Text; if (!URL.Contains("youtube.com")) { MessageBox.Show("Your link must be a valid youtube.com URL, all other links will fail."); } else { loadingScreen.Show(this); textBox1.Text = string.Empty; var proc = new Process { StartInfo = new ProcessStartInfo { WorkingDirectory = Environment.CurrentDirectory,// working directory FileName = @"Title.exe ", Arguments = URL, UseShellExecute = false, RedirectStandardOutput = false, CreateNoWindow = true } }; proc.Start(); proc.WaitForExit(); loadingScreen.Hide(); String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\EYS\"; string line = File.ReadAllText(path + @"\temp"); File.Delete(path + @"\temp"); if (listBox1.Items.Contains(line) || URLs.ContainsKey(line)) { MessageBox.Show("List already contains a video with the same title."); } else { listBox1.Items.Add(line); URLs.Add(URL, line);//URL then title... } } }