private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     //newStart = new Start(links.Count(x => x.SelForDload == true).ToString()+" file(s) downloaded successfully, see Log");
     newStart = new Start();
     this.NavigationService.Navigate(newStart);
 }
 void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     wc = null;
     if (e.Cancelled) // if cancelled
     {
         li.Downloaded = false;
         iLink = yts;
         LogFile.VidSavedLoc = "";
         LogFile.WriteToLogFile(LogFile.Operation.cancelled, null);
         MessageBox.Show("Download Cancelled", "YouTube Downloader");
         try
         {
             File.Delete(dwnFile);
         }
         catch (Exception) { }
         links = null;
         yts = null;
         wc = null;
         li = null;
         iLink = null;
         WBlinkinfo.TotalCount = 0;
         lblData.Visibility = Visibility.Hidden;
         btnCancel.Visibility = Visibility.Hidden;
         btnOK.Visibility = Visibility.Visible;
         textBlock1.Visibility = Visibility.Visible;
         textBlock2.Visibility = Visibility.Visible;
         newStart = new Start();
         this.NavigationService.Navigate(newStart);
         return;
     }
     else
     {
         if (OptionsWindow.Audio) // if audio
         {
             try
             {
                 FileInfo f = new FileInfo(dwnFile); // if error
                 if (f.Length < 4)
                 {
                     MessageBox.Show("Error occured during download.", "YouTube Downloader");
                     f = null;
                     try
                     {
                         if (OptionsWindow.Audio) File.Delete(dwnFile);
                     }
                     catch (Exception exc) { LogFile.WriteToLogFile(LogFile.Operation.app_error, null, exc.Message); }
                 }
                 else
                 {
                     f = null;
                     progressBar1.Value = 0;
                     if (OptionsWindow.Audio)
                     {
                         toMp3(dwnFile);
                         dwnFile = dwnFile.Substring(0, dwnFile.Length - 4) + formatText;
                         if (File.Exists(dwnFileConvAud))
                             File.Delete(dwnFileConvAud);
                         File.Copy(dwnFile, dwnFileConvAud);
                         try { File.Delete(dwnFile); }
                         catch (Exception exc) { LogFile.WriteToLogFile(LogFile.Operation.app_error, null, exc.Message); }
                     }
                 }
             }
             catch (Exception exc)
             {
                 MessageBox.Show("Error: " + exc.Message, "YouTubeDownloader");
                 LogFile.WriteToLogFile(LogFile.Operation.app_error, null, exc.Message);
             }
         }             
     }
     int i = li.LinkIndex;
     links[i].Downloaded = true;
     iLink = li;
     LogFile.WriteToLogFile(LogFile.Operation.downloaded, iLink);
     if (links.Any(x => x.Downloaded == false && x.SelForDload == true))     // to download left check
         InitiateDownload(); 
     else                    
     {               
         lblStatus.Content = "Download(s) Completed";
         if (OptionsWindow.ShutdownPC)
             System.Diagnostics.Process.Start("shutdown", "/s /f /t 060 /c " + (char)34 + "YOUR COMPUTER WILL BE TURNED OFF IN 60 seconds" + (char)34);               
         links = null;
         yts = null;
         wc = null;
         li = null;
         iLink = null;
         WBlinkinfo.TotalCount = 0;
         lblData.Visibility = Visibility.Hidden;
         btnCancel.Visibility = Visibility.Hidden;
         btnOK.Visibility = Visibility.Visible;
         textBlock1.Visibility = Visibility.Visible;
         textBlock2.Visibility = Visibility.Visible;
     }            
 }