private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string path = tbRef.Text;
            string name = tbName.Text;

            if (path != String.Empty && name != String.Empty)
            {
                file     = new FileDownload(path, name, 100);
                file._id = id;
                ProgressBar bar = new ProgressBar();
                bar.Maximum = file.ContentLength;
                bar.Value   = file.BytesWritten;
                ItemElement it = new ItemElement {
                    Id = id, Title = path, Bar = (int)bar.Value
                };
                if (CheckItems(it.Title))
                {
                    try
                    {
                        file.Start(it, History, Active);
                    }
                    catch (Exception ex)
                    {
                        tbEx.Text = ex.Message;
                        Delete(file, it);
                    }
                    Items.Add(it);
                    Active.Add(it);
                    id++;
                    threads.Add(file);
                    Serialize(threads.ToArray(), "threads.xml");
                    Serialize(Items, "items.xml");
                }
            }
        }
 private void Delete(FileDownload file, ItemElement it)
 {
     Items.Remove(it);
     threads.Remove(file);
     Active.Remove(it);
 }