//Put Parts and Sites into a list. Generate string of sequences
        private void GeneratePrimers_Click(object sender, RoutedEventArgs e)
        {
            if (pd1 != null)
            {
                sw1.SW_SV.Items.Remove(pd1);
                pd1 = null;
            }

            StackPanel activeTab = PD2_manual;

            if (PD2_buildTabs.SelectedIndex == 1)
            {
                activeTab = PD2_auto;
            }

            int i = 0;

            foreach (UIElement elem in activeTab.Children)
            {
                if (elem.GetType() == typeof(Part))
                {
                    //If list (i.e. L1 module) is full and there are still Parts left
                    //Create new list and increment index
                    if (partList.ElementAt(i).Count == 4)
                    {
                        partList.Add(new List <Part>());
                        i++;
                    }
                    int  elemIndex = activeTab.Children.IndexOf(elem);
                    Part p         = (Part)elem;
                    //p.updateSites(activeTab, elemIndex);
                    p.updateSites(activeTab);
                    Part clone = p.clone();
                    clone.BorderBrush = p.BorderBrush;
                    clone.ElementMenu.Items.Remove(clone.PD);
                    partList.ElementAt(i).Add(clone);
                }
            }


            pd1 = new PrimerDesigner1(partList);
            sw1.SW_SV.Items.Add(pd1);

            #region Old Generate Primers code
            //2D array of each Part and Site sequence, divided into arrays of Parts and flanking sites (i.e. Sites-Parts-Sites)


            //int n = activeTab.Children.Count / 3; //Number of Part-Sites sets, not including the two backbone Sites

            //_partSiteSets = new UIElement[n + 2][];

            //Sites firstFS = ((Sites)VisualTreeHelper.GetChild(activeTab, 0)).clone();
            //Sites lastFS = ((Sites)VisualTreeHelper.GetChild(activeTab, activeTab.Children.Count - 1)).clone();
            //_partSiteSets[0] = new UIElement[] { firstFS };
            //_partSiteSets[n + 1] = new UIElement[] { lastFS };

            //for (int i = 0; i < n; i++)
            //{
            //    int j = 3 * i + 1;
            //    Sites site1 = ((Sites)VisualTreeHelper.GetChild(activeTab, j)).clone();
            //    Part p0 = ((Part)VisualTreeHelper.GetChild(activeTab, j + 1));
            //    Part p = p0.clone();
            //    p.BorderBrush = p0.BorderBrush;
            //    p.ElementMenu.Items.Remove(p.PD);
            //    Sites site2 = ((Sites)VisualTreeHelper.GetChild(activeTab, j + 2)).clone();

            //    UIElement[] subArray = new UIElement[] { site1, p, site2 };
            //    _partSiteSets[i + 1] = subArray;
            //}

            ////Check that Sites are not used twice
            //List<String> sitesList = new List<String>();
            ////Build checklist by taking the left Site in each set besides the first, plus the last Site (technically the left Site of the vector)
            //for (int i = 2; i < _partSiteSets.Length; i++)
            //{
            //    sitesList.Add(((Sites)_partSiteSets[i][0]).Sequence);
            //}
            ////Check sitesList for duplicates
            //bool noDupes = true;
            //bool noEmpty = true;
            ////Start by checking sitesList for the first left-hand Site
            //String checkThis = ((Sites)_partSiteSets[1][0]).Sequence;
            ////Break when sitesList has no items left to compare to checkForThis
            //int count = sitesList.Count;
            //while (sitesList.Count() > 0 /*&& noDupes && noEmpty*/)
            //{
            //    noDupes = !(sitesList.Contains(checkThis));
            //    noEmpty = checkThis != "site";
            //    checkThis = sitesList.ElementAt(0);
            //    sitesList.RemoveAt(0);
            //}
            //if (noDupes && noEmpty)
            //{
            //    pd1 = new PrimerDesigner1(_partSiteSets);
            //    sw1.SW_SV.Items.Add(pd1);
            //}
            //else if (noEmpty && !noDupes)
            //{
            //    MessageBox.Show("Couldn't generate primers. Please check for duplicate fusion sites.");
            //}
            //else if (!noEmpty && noDupes)
            //{
            //    MessageBox.Show("Couldn't generate primers. Please check for empty fusion sites.");
            //}
            //else //Both errors present
            //{
            //    MessageBox.Show("Couldn't generate primers. Please check for duplicate and empty fusion sites.");
            //}
            #endregion
        }