/// <summary>
        /// Initialize SitesAdded array to proper size based on Part/L1Module/L2Module to accommodate all possible fusion sites.
        /// Actual fusion site requirement checking done in Sites.xaml.cs during hit test
        /// </summary>
        /// @T.Feng
        //private void initializeFusionSiteChecker()
        //{
        //    switch (_moduleNum)
        //    {
        //        case 0: SitesAdded = new Sites[2]; break;//Part has 2 fusion sites
        //        case 1: SitesAdded = new Sites[5]; break;//L1Module has 5 fusion sites
        //        case 2: SitesAdded = new Sites[_l2Modulel1Count * 4 + 1]; break; //L2Module has L1ModuleNum*4 + 1 fusion sites
        //        default: Console.WriteLine("No fusion site-added storage constructed, no info on object that launched Primer Designer. PrimerDesigner2.xaml.cs Ln 250"); break;
        //    }
        //}


        #endregion

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            DataContext        = this;
            _fusionSiteLibrary = new List <Sites>();
            //_fusionSiteLibrary.Add(new Sites("Site A", "acaa", new SolidColorBrush(Colors.Gold)));
            //_fusionSiteLibrary.Add(new Sites("Site B", "atgc", new SolidColorBrush(Colors.GreenYellow)));
            //Sites tester = new Sites("Site C", "atgg", new SolidColorBrush(Colors.LimeGreen));
            //_fusionSiteLibrary.Add(tester);
            //_fusionSiteLibrary.Add(new Sites("Site D", "gtca", new SolidColorBrush(Colors.Orchid)));
            //_fusionSiteLibrary.Add(new Sites("Site E", "cctg", new SolidColorBrush(Colors.PaleVioletRed)));
            //_fusionSiteLibrary.Add(new Sites("Site F", "aatg", new SolidColorBrush(Colors.Peru)));
            //_fusionSiteLibrary.Add(new Sites("Site G", "ggta", new SolidColorBrush(Colors.RosyBrown)));
            //_fusionSiteLibrary.Add(new Sites("Site H", "catt", new SolidColorBrush(Colors.Thistle)));
            //_fusionSiteLibrary.Add(new Sites("Site I", "gact", new SolidColorBrush(Colors.DeepSkyBlue)));

            _fusionSiteLibrary.Add(new Sites("acaa"));
            _fusionSiteLibrary.Add(new Sites("atgc"));
            _fusionSiteLibrary.Add(new Sites("atgg"));
            _fusionSiteLibrary.Add(new Sites("gtca"));
            _fusionSiteLibrary.Add(new Sites("cctg"));
            _fusionSiteLibrary.Add(new Sites("ggta"));
            _fusionSiteLibrary.Add(new Sites("catt"));
            _fusionSiteLibrary.Add(new Sites("gact"));

            foreach (Sites s in _fusionSiteLibrary)
            {
                PD2_siteLibrary.Items.Add(s);
                s.Center = SurfaceWindow1.SetPosition(s);
            }
        }
        //Adds an L1Module template to Manual
        public void addL1Module()
        {
            L1Module l1 = new L1Module();

            l1.Template.Visibility = System.Windows.Visibility.Visible;
            L1_manTab.Items.Add(l1);
            l1.Center = SurfaceWindow1.SetPosition(l1);
            l1.IsManipulationEnabled = false;
        }
        //Adds an editable fusion site template to the library
        private void siteAdder_Click(object sender, RoutedEventArgs e)
        {
            Sites template = new Sites();

            template.CircleText.IsReadOnly = false;
            template.Height = 50;
            template.Width  = 50;
            PD2_siteLibrary.Items.Add(template);
            template.Center = SurfaceWindow1.SetPosition(template);
        }
        //Testing out global variable checking with addition of new Parts
        private void partAdder_Click(object sender, RoutedEventArgs e)
        {
            Part part = new Part();
            ImageSourceConverter icon = new ImageSourceConverter();

            part.partName.Text     = "BBa##)@)#";
            part.partCategory.Text = "no filter";
            L0_resultsSV.Items.Add(part);
            part.Center = SurfaceWindow1.SetPosition(part);
        }
        //Stored separate from searchByFilter so it can be called by _progressBarWrapper as the long operation
        //Returns a string to keep _progressBarWrapper happy
        //private String searchByFilter_longOp(int filterIndex)
        //{
        //    //Get list to populate from
        //    List<List<String>> sourceList;
        //    if (_partTypeSelected == "prom")
        //    {
        //        sourceList = promotersList;
        //    }
        //    else if (_partTypeSelected == "rbs")
        //    {
        //        sourceList = rbsList;
        //    }
        //    else if (_partTypeSelected == "cds")
        //    {
        //        sourceList = cdsList;
        //    }
        //    else //"term"
        //    {
        //        sourceList = terminatorsList;
        //    }

        //    //Find indexes to start and stop populating from in partsList[0]
        //    List<String> sourceIndexes = sourceList.ElementAt(0);

        //    int firstIndex = Convert.ToInt32(sourceIndexes.ElementAt(filterIndex));
        //    int lastIndex;
        //    //If filterIndex refers to the last index stored in sourceIndexes, i.e. the start of the last category
        //    if (filterIndex == sourceIndexes.Count - 1)
        //    {   //lastIndex is the index of the last part stored in sourceList
        //        lastIndex = sourceList.Count - 1;
        //    }
        //    else
        //    {   //Otherwise, lastIndex is the index of the last part before the start index of the next category
        //        lastIndex = Convert.ToInt32(sourceIndexes.ElementAt(filterIndex + 1)) - 1;
        //    }

        //    populate_Results(sourceList, firstIndex, lastIndex);

        //    return "I'm only here because threading wants a return type";
        //}

        //Populate L0_resultsSV with parts from partsList between given indexes
        private void populate_Results(List <List <String> > partsList, int first, int last)
        {
            for (int i = first; i <= last; i++)
            {
                Part p = new Part();
                p.Type              = _partTypeSelected;
                p.partName.Text     = (partsList.ElementAt(i)).ElementAt(0);
                p.partCategory.Text = (partsList.ElementAt(i)).ElementAt(1);
                this.L0_resultsSV.Items.Add(p);
                p.Center = SurfaceWindow1.SetPosition(p);
            }
        }
        //Creates a new Part based on RegDataSheet and category; do not add duplicates
        private void partFromRegDS(RegDataSheet regDS, String cat)
        {
            String currentPartsList = listCurrentPartsInResults();

            if (!currentPartsList.Contains(regDS.Name))
            {
                Part p = new Part(convertType_RDSToMCP(regDS.Type));
                p.myRegDS           = regDS;
                p.partName.Text     = p.myRegDS.Name;
                p.partCategory.Text = p.myRegDS.BasicInfo.DescriptionName;
                L0_resultsSV.Items.Add(p);
                p.Center = SurfaceWindow1.SetPosition(p);
            }
        }
Exemplo n.º 7
0
        //Places clone of dragged part into L1 if below threshold
        private void PartInL0()
        {
            try
            {
                double yL1        = sw1.L1.Center.Y;
                double yThreshold = yL1 - sw1.L1.Height / 2 - 180;

                //Check if user is dropping or dumping
                if (Center.Y > yThreshold)
                { //Create clone, check Part type, and place in appropriate L1 partsbox
                    Part L1clone = clone();

                    if (_type == "prom")
                    {
                        sw1.L1.L1_prom.Items.Add(L1clone);
                    }
                    else if (_type == "rbs")
                    {
                        sw1.L1.L1_rbs.Items.Add(L1clone);
                    }
                    else if (_type == "cds")
                    {
                        sw1.L1.L1_cds.Items.Add(L1clone);
                    }
                    else if (_type == "term")
                    {
                        sw1.L1.L1_term.Items.Add(L1clone);
                    }

                    L1clone.Center = SurfaceWindow1.SetPosition(L1clone);
                    Console.WriteLine("Part was added to L1");
                }
                else
                {
                    myClone.IsManipulationEnabled = true;
                    myClone.Opacity = 1;
                }
            }
            catch (Exception exc) { Console.WriteLine("PartInL0 \n" + exc); }
        }
Exemplo n.º 8
0
        //L1 behavior handler: drops L1Modules into L2
        //Checks center against threshold value, below which drop occurs
        //Currently handles Permutations functions of Level 2 (consider moving to L1ModuleInL2())
        private void L1ModuleInL1()
        {
            ScatterView parent = Parent as ScatterView;
            //Places item in L2 if user wants to drop it in
            double yL1        = sw1.L1.Center.Y;
            double yL2        = sw1.L2.Center.Y;
            double yThreshold = yL2 - yL1 - 100; //For a 50 margin and 50 more because the center is relative to L1_SV

            //Check if user is dropping or dumping
            Point transformedCenter = SurfaceWindow1.transformCoords(this, sw1.L1.L1_SV);

            if (transformedCenter.Y > yThreshold) //0 is the top relative to L1_xTabs; adjust accordingly. Need to fix this to a relative height.
            {
                L1Module cloneToL2 = clone();
                sw1.L2.L2_L1ModulesSV.Items.Add(cloneToL2);
                cloneToL2.Center = SurfaceWindow1.SetPosition(cloneToL2);
            }
            else
            { //Dumped; restore function to clone
                myClone.IsManipulationEnabled = true;
                myClone.Opacity = 1;
            }
        }
        //Reads in Part Registry ID and type from text file
        private void populate_ResultsPage(string FilePath)
        {
            StreamReader reader = new StreamReader(FilePath);

            while (reader.EndOfStream != true)
            {
                //Read in data
                string   ThisLine        = reader.ReadLine();
                string[] SplitLine       = ThisLine.Split(',');
                string   CategorySplit   = SplitLine[1].Trim();
                string   CommonNameSplit = (SplitLine[2].Trim()).Replace("&amp;", "");

                //Filter data, add Parts
                if (CategorySplit == filterText)
                {
                    Part p = new Part();
                    p.Type              = _partTypeSelected;
                    p.partName.Text     = SplitLine[0];
                    p.partCategory.Text = CommonNameSplit;
                    this.L0_resultsSV.Items.Add(p);
                    p.Center = SurfaceWindow1.SetPosition(p);
                }
            }
        }
Exemplo n.º 10
0
        //Generates permutations of L1 modules using selected Parts
        private void permMaker_Click(object sender, RoutedEventArgs e)
        {
            permMaker.IsEnabled = false;

            List <Part> selectedPromList = new List <Part>();
            List <Part> selectedRBSList  = new List <Part>();
            List <Part> selectedCDSList  = new List <Part>();
            List <Part> selectedTermList = new List <Part>();

            //if the background is a different color than the border, then part is selected and should be added to selected part list
            foreach (Part p in sw1.L1.L1_prom.Items)
            {
                if (p.BorderBrush == selected)
                {
                    selectedPromList.Add(p);
                }
            }
            foreach (Part r in sw1.L1.L1_rbs.Items)
            {
                if (r.BorderBrush == selected)
                {
                    selectedRBSList.Add(r);
                }
            }
            foreach (Part c in sw1.L1.L1_cds.Items)
            {
                if (c.BorderBrush == selected)
                {
                    selectedCDSList.Add(c);
                }
            }
            foreach (Part t in sw1.L1.L1_term.Items)
            {
                if (t.BorderBrush == selected)
                {
                    selectedTermList.Add(t);
                }
            }

            if (selectedPromList.Count != 0 && selectedRBSList.Count != 0 && selectedCDSList.Count != 0 && selectedTermList.Count != 0)
            {
                //permutations are cleared and regenerated everytime
                sw1.L1.L1_permTab.Items.Clear();

                foreach (Part p in selectedPromList)
                {
                    foreach (Part r in selectedRBSList)
                    {
                        foreach (Part c in selectedCDSList)
                        {
                            foreach (Part t in selectedTermList)
                            {
                                //L1Module L = new L1Module(p, r, c, t);//////////////////////////////////////////////////
                                L1Module L = new L1Module();
                                L.L1Prom.copyPartInfoFrom(p);
                                L.L1RBS.copyPartInfoFrom(r);
                                L.L1CDS.copyPartInfoFrom(c);
                                L.L1Term.copyPartInfoFrom(t);

                                sw1.L1.L1_permTab.Items.Add(L);
                                L.Center = SurfaceWindow1.SetPosition(L);
                                //generate Level1 modules and then add to the list called Level1module List.
                            }
                        }
                    }
                }
            }


            permMaker.IsEnabled = true;
        }