private void ButtonLib_Click(object sender, RoutedEventArgs e)
 {
     if (!activeDownloads)
     {
         //Close();
     }
     if (libWin == null)
     {
         this.Dispatcher.Invoke(new Action(() =>
         {
             libWin = new LibWindow();
             libWin.Show();
             libWin.Closed += new EventHandler(LibWin_Closed);
         }));
     }
     else
     {
         libWin.Activate();
     }
 }
 private void LibWin_Closed(object sender, EventArgs e)
 {
     libWin = null;
 }