private void select_Sequence(object sender, RoutedEventArgs e)
        {
            String s = "";

            foreach (UIElement l1 in this.Children)
            {
                if (l1.GetType() == typeof(L1Module))
                {
                    foreach (UIElement p in ((L1Module)l1).L1Grid.Children)
                    {
                        if (p.GetType() == typeof(Part))
                        {
                            s = s + ((Part)p).myRegDS.BasicInfo.Sequence + "\n";
                        }
                    }
                }
            }
            TextBlock sequence = new TextBlock();

            sequence.Text = s;
            ScatterViewItem svi = new ScatterViewItem();

            svi.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(seq_ContainerManipulationCompleted);
            svi.Content = sequence;
            SurfaceWindow1.addData(sender, svi);
        }
        /// <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);
            }
        }
Exemplo n.º 3
0
        //Method for generating the Sequence scatterview item from the element menu
        private void select_Sequence(object sender, RoutedEventArgs e)
        {
            _thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

            seq           = new ScatterViewItem();
            seq.CanRotate = false;
            seq.CanScale  = false;
            TextBlock seqtext = new TextBlock();     //Creates a textblock to be inserted into the scatterview

            seqtext.Margin     = new Thickness(10);
            seq.Background     = Brushes.SteelBlue;
            seqtext.Background = Brushes.White;

            seq.Width         = 800;
            seq.MinHeight     = 600;
            seqtext.Width     = 790;
            seqtext.MinHeight = 590;


            seqtext.Text = "Parts Registry ID: " + _thisRegDS.Name + "\n" + "\n" + "Sequence:" + "\n" + "\n" + _thisRegDS.BasicInfo.Sequence;
            seq.Content  = seqtext;

            SurfaceWindow1.addData(sender, seq);
            seq.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(onSeqManipulationCompleted);     //Event handler that allows trashing when swiped to the right
            seq.Orientation = 0;

            //Overwrites center calculated in addData(); consider checking out later
            Point PartCenter     = this.Center;
            Point OriginalCenter = seq.Center;

            OriginalCenter.X = (PartCenter.X);
            OriginalCenter.Y = (PartCenter.Y + 370);

            seq.Center = OriginalCenter;
        }
Exemplo n.º 4
0
        //Removes from current parent and adds to destination parent at same location
        private void changeParents_SV(ScatterView parentSV, ScatterView destination)
        {
            //Point newPoint = this.transformCoords(destination);
            Point newPoint = SurfaceWindow1.transformCoords(this, destination);

            parentSV.Items.Remove(this);
            destination.Items.Add(this);
            this.Center = newPoint;
        }
        //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;
        }
        //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);
        }
        //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);
        }
Exemplo n.º 8
0
        //Moves objects from parent to parent while maintaining a consistent center
        private void changeParents_SV(ScatterView parentSV, ScatterView destinationSV)
        {
            try
            {
                Point newPoint = SurfaceWindow1.transformCoords(this, destinationSV);

                parentSV.Items.Remove(this);
                destinationSV.Items.Add(this);
                this.Center = newPoint;
            }
            catch (Exception exc) { Console.WriteLine("changeParents_SV \n" + exc); }
        }
        //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);
            }
        }
        public BasicImageReceiver(SurfaceWindow1 surface)
        {
            IPAddress ipAdress = IPAddress.Parse(SurfaceWindow1.SURFACE);
            //this.tcpListener = new TcpListener(IPAddress.Any, port);
            this.tcpListener = new TcpListener(ipAdress, port);
            Console.WriteLine("Server started; available at local IP: " + ipAdress);
            this.surfaceWin = surface;

            this.listenThread = new Thread(new ThreadStart(ListenForClients));
            //this.listenThread.SetApartmentState(ApartmentState.MTA);
            this.listenThread.Start();
            //this.listenThread.Join();
        }
Exemplo n.º 11
0
        //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.º 12
0
        //Constructor for searches unbounded by part types
        public Part(String partType)
        {
            InitializeComponent();
            Orientation = 0;
            CanScale    = false;
            CanRotate   = false;

            _sitesList = new List <Sites> {
                new Sites(), new Sites()
            };

            //if (sw1 != null)
            //{
            _type = partType;
            if (_type == "prom")
            {
                imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_prom2);
                //Background = Brushes.Orange;
            }
            else if (_type == "rbs")
            {
                imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_rbs2);
                //Background = Brushes.DodgerBlue;
            }
            else if (_type == "cds")
            {
                imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_cds2);
                _sitesList.ElementAt(0).copySitesInfoFrom(new Sites("aatg"));
                //Background = Brushes.Green;
            }
            else     //type == "term"
            {
                imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_term2);
                //Background = Brushes.Red;
            }
            //}
            //else
            //{
            //    imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_prom);
            //    this.Background = Brushes.Orange;
            //}

            _myRegDS = new RegDataSheet();

            _progressBarWrapper         = new ProgressBarWrapper(new Action(showProgressBar), new Action(hideProgressBar));
            _myRegDS.BasicInfo.Sequence = "atgcatgctagcatccattacgatccgtcag";
        }
Exemplo n.º 13
0
 //When manipulation completed, check location for drop and transfer data to placeholder; then delete
 private void Sites_ContainerManipulationCompleted(object sender, ContainerManipulationCompletedEventArgs e)
 {
     try
     {
         Sites s = sender as Sites;
         if (myClone != null)
         {
             Point pt = SurfaceWindow1.transformCoords(this, pd2.PD2_manual);
             if (pd2.PD2_buildTabs.SelectedIndex == 0) //If Manual is selected
             {
                 VisualTreeHelper.HitTest(pd2.PD2_manual, null, new HitTestResultCallback(sitesCallback), new PointHitTestParameters(pt));
             }
             ScatterView parent = (ScatterView)s.Parent;
             parent.Items.Remove(s);
         }
     }
     catch (Exception exc) { Console.WriteLine(exc); }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Empty placeholder part
 /// </summary>
 public L1Module()
 {
     InitializeComponent();
     L1Prom.imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_prom);
     L1RBS.imgType.Source  = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_rbs);
     L1CDS.imgType.Source  = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_cds);
     L1Term.imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_term);
     foreach (UIElement p in L1Grid.Children)
     {
         if (p.GetType() == typeof(Part))
         {
             ((Part)p).Opacity = 0.5;
             //p.IsEnabled = false;
             ((Part)p).ShowsActivationEffects = false;
             ((Part)p).IsTopmostOnActivation  = false;
             ((Part)p).ElementMenu.IsEnabled  = false;
             ((Part)p).ElementMenu.Visibility = Visibility.Collapsed;
         }
     }
 }
Exemplo n.º 15
0
        private void Sites_ContainerManipulationDelta(object sender, ContainerManipulationDeltaEventArgs e)
        {
            try
            {
                myClone        = clone();
                myClone.Center = originalCenter;

                int   i        = pd2.FusionSiteLibrary.IndexOf(this);
                Point newPoint = SurfaceWindow1.transformCoords(this, pd2.PD2_SV);
                //pd2.SourceItems.Insert(i, copy);
                //pd2.SourceItems.Remove(this);

                pd2.PD2_siteLibrary.Items.Remove(this);
                pd2.PD2_siteLibrary.Items.Add(myClone);
                pd2.PD2_SV.Items.Add(this);
                this.Center = newPoint;

                this.ContainerManipulationDelta -= Sites_ContainerManipulationDelta;
            }
            catch (Exception exc) { Console.WriteLine(exc); }
        }
Exemplo n.º 16
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.º 17
0
        /// <summary>
        /// Populated part: used in L1 & L2
        /// NOT ACTUALLY USED. Copying over of Part information displays properly
        /// only when copyPartInfoFram is called during the adding of permuted L1Modules to the permTabs.
        /// </summary>
        public L1Module(Part p, Part r, Part c, Part t)
        {
            InitializeComponent();
            L1Prom.imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_prom);
            L1RBS.imgType.Source  = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_rbs);
            L1CDS.imgType.Source  = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_cds);
            L1Term.imgType.Source = SurfaceWindow1.BitmapToImageSource(Resource1.sbol_term);

            L1Prom = p;
            L1Prom.partName.Text     = p.myRegDS.Name;
            L1Prom.partCategory.Text = p.partCategory.Text;
            //L1Prom.copyPartInfoFrom(p);
            L1RBS = r;
            L1RBS.partName.Text = r.myRegDS.Name;
            //L1RBS.copyPartInfoFrom(r);
            L1CDS = c;
            //L1CDS.partName.Text = c.myRegDS.Name;
            //L1RBS.copyPartInfoFrom(c);
            L1Term = t;
            //L1Term.partName.Text = t.myRegDS.Name;
            //L1Term.copyPartInfoFrom(t);
        }
Exemplo n.º 18
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;
            }
        }
Exemplo n.º 19
0
        //L2 behavior handler: drops L1Modules into L2Modules
        //Detects L2Modules via hittesting, using the center of the L1module as the initial value
        private void L1ModuleInL2()
        {
            Point pt = SurfaceWindow1.transformCoords(this, sw1.L2.L2_manTab);

            VisualTreeHelper.HitTest(sw1.L2.L2_manTab, null, new HitTestResultCallback(TargetL2MCallback), new PointHitTestParameters(pt));

            if (targetL2Module != null)
            { //Dropped
                L1Module manTabClone = clone();
                manTabClone.IsManipulationEnabled = false;
                manTabClone.targetL2Module        = targetL2Module;
                manTabClone.Background            = sw1.L2.L1MColors.ElementAt(targetL2Module.Children.Count - 1);
                manTabClone.BorderBrush           = manTabClone.Background;
                //If targetL2M only contains an element menu, add margin to left
                //This leaves space so L2M can be interacted with and element menu can be accessed; this isn't the way to do it. When switching order, margin moves too.
                //if (targetL2Module.Children.Count == 1) manTabClone.Margin = new Thickness(30,0,0,0);
                targetL2Module.Children.Add(manTabClone);
            }
            else
            { //Dumped; check if delete from palette
                //Console.WriteLine("Missed!");
                sw1.swipeToDelete(this);
            }
        }
Exemplo n.º 20
0
        //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.º 21
0
        private void select_DataSheet(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

            ds = new MenuDataSheet();
            ds.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(onDSManipulationCompleted);

            if (_myRegDS.Name != "test") //Already got data from registry, so just populate from it
            {
                #region Populating the data sheet's datasheet
                //Specifies the Length of the Sequence on the Sequence tab of the data sheet
                int       Length      = _myRegDS.BasicInfo.Length;
                TextBlock LengthBlock = new TextBlock();
                //ds.SeqTab.Children.Add(LengthBlock);
                LengthBlock.VerticalAlignment = VerticalAlignment.Top;
                LengthBlock.Text = "Length: " + Length.ToString();

                //This is all pulling information from the Reg Data Sheet associated with the part and inserting it in the data sheet
                ds.PopulateDataSheet(_myRegDS.Name, 0, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.DescriptionName, 1, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Type, 2, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Promoter.getReg(), 3, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Availability, 4, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Usefulness, 5, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Description.assembCompString(), 6, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Description.chassisString(), 7, 1, ds.DataSheet, "datasheet");



                //Specific to sequence tab
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Sequence, 1, 1, ds.SeqTab, "seq");
                ds.PopulateDataSheet(Length.ToString(), 0, 1, ds.SeqTab, "length");

                //Specific to AuthorInfo Tab
                ds.PopulateDataSheet(_myRegDS.Reference.Author, 0, 1, ds.AuthorInfo, "author");
                ds.PopulateDataSheet(_myRegDS.Reference.Group, 1, 1, ds.AuthorInfo, "author");
                ds.PopulateDataSheet(_myRegDS.Reference.Date, 2, 1, ds.AuthorInfo, "author");

                if (_myRegDS.Type == "rbs")
                {
                    RowDefinition rowDef1 = new RowDefinition();
                    ds.DataSheet.RowDefinitions.Add(rowDef1);
                    ds.PopulateDataSheet(_myRegDS.Rbs.FamilyName, 8, 1, ds.DataSheet);
                    TextBlock RBSFam = new TextBlock();
                    RBSFam.Text = "Family";
                    ds.DataSheet.Children.Add(RBSFam);
                    Grid.SetRow(RBSFam, 8);
                }
                else if (_myRegDS.Type == "terminator")
                {
                    RowDefinition rowDef1 = new RowDefinition();
                    RowDefinition rowDef2 = new RowDefinition();
                    RowDefinition rowDef3 = new RowDefinition();
                    RowDefinition rowDef4 = new RowDefinition();

                    ds.DataSheet.RowDefinitions.Add(rowDef1);
                    ds.DataSheet.RowDefinitions.Add(rowDef2);
                    ds.DataSheet.RowDefinitions.Add(rowDef3);
                    ds.DataSheet.RowDefinitions.Add(rowDef4);

                    TextBlock Direction = new TextBlock();
                    Direction.Text     = "Direction";
                    Direction.FontSize = 18;
                    ds.DataSheet.Children.Add(Direction);
                    Grid.SetRow(Direction, 8);

                    ds.PopulateDataSheet(_myRegDS.Terminators.Direction, 8, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ForwardEff, 9, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ReversedEff, 10, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ReversedVers, 11, 1, ds.DataSheet);
                }

                #endregion

                #region Populating Publications
                Func <String, PubList> _GetPublications =
                    delegate(String id) { return(new PubList(id)); };
                Action <PubList> callback = delegate(PubList result)
                {
                    //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

                    int m = 0;

                    if (result.Titles.Count == 0)
                    {
                        int Count = result.Titles.Count;
                        SurfaceListBoxItem NoResults = new SurfaceListBoxItem();
                        TextBlock          Content   = new TextBlock();
                        Content.Text      = "No Results Found";
                        NoResults.Content = Content;
                        ds.Publictions.Items.Add(NoResults);
                    }

                    if (result.Titles.Count > 0)
                    {
                        int TotalArticles = result.Titles.Count;
                        SurfaceListBoxItem ArticleCount = new SurfaceListBoxItem();
                        TextBlock          CountContent = new TextBlock();
                        CountContent.Text    = "Results Found: " + TotalArticles as string;
                        ArticleCount.Content = CountContent;
                        ds.Publictions.Items.Add(ArticleCount);
                    }

                    foreach (String Titles in result.Titles)
                    {
                        //To Test if titles are actually adding
                        SurfaceListBoxItem item      = new SurfaceListBoxItem();
                        TextBlock          PubTitles = new TextBlock();
                        item.Selected += new RoutedEventHandler(item_Selected);
                        item.Content   = Titles;
                        PubTitles.Tag  = result.Links.ElementAt(m);
                        //item.Tag = result.Authors.ElementAt(m);
                        ds.Publictions.Items.Add(item);
                        RowDefinition rowDef1 = new RowDefinition();
                        RowDefinition rowDef2 = new RowDefinition();
                        RowDefinition rowDef3 = new RowDefinition();
                        RowDefinition rowDef4 = new RowDefinition();

                        abs = new PubAbstract(PubTitles.Tag as string, result.getAuthors());

                        item.Tag = "Title:  " + item.Content as string + "\r\n" + "\r\n" + "\r\n"

                                   + "Authors:   " + result.Authors.ElementAt(m) as string + "\r\n" + "\r\n"

                                   + "Abstract:" + "\r\n" + "\r\n"

                                   + abs.getAbstract() as string;

                        m += 1;
                        Console.WriteLine(m);

                        if (m > 20)
                        {
                            break;
                        }
                    }

                    /*foreach (String Titles in result.Titles)
                     * {
                     *  TextBlock Middle = new TextBlock();
                     *  Middle.Text = Titles;
                     *  //ds.Publications.Children.Add(Middle);
                     *  Grid.SetRow(Middle, m);
                     *  m += 1;
                     #endregion
                     * //publications location maybe
                     * //Creates a list of PubMed source related to the query
                     *
                     * }*/
                };
                _Publist = _progressBarWrapper.execute <String, PubList>(_GetPublications, _myRegDS.BasicInfo.DescriptionName, callback);
                #endregion
                SurfaceWindow1.addData(sender, ds);
            }
            else
            {
                Func <String, RegDataSheet> _getRegDataSheet =
                    delegate(String pName) { return(new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + pName)); };
                Action <RegDataSheet> _getRegDataSheetCallback = delegate(RegDataSheet _regDS)
                {
                    _myRegDS = _regDS;
                    #region Populating the data sheet's datasheet
                    //Specifies the Length of the Sequence on the Sequence tab of the data sheet
                    int       Length      = _myRegDS.BasicInfo.Length;
                    TextBlock LengthBlock = new TextBlock();
                    //ds.SeqTab.Children.Add(LengthBlock);
                    LengthBlock.VerticalAlignment = VerticalAlignment.Top;
                    LengthBlock.Text = "Length: " + Length.ToString();

                    //This is all pulling information from the Reg Data Sheet associated with the part and inserting it in the data sheet
                    ds.PopulateDataSheet(_myRegDS.Name, 0, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.DescriptionName, 1, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Type, 2, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Promoter.getReg(), 3, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Availability, 4, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Usefulness, 5, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Description.assembCompString(), 6, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Description.chassisString(), 7, 1, ds.DataSheet, "datasheet");

                    //Specific to sequence tab
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Sequence, 1, 1, ds.SeqTab, "seq");
                    ds.PopulateDataSheet(Length.ToString(), 0, 1, ds.SeqTab, "length");

                    //Specific to AuthorInfo Tab
                    ds.PopulateDataSheet(_myRegDS.Reference.Author, 0, 1, ds.AuthorInfo, "author");
                    ds.PopulateDataSheet(_myRegDS.Reference.Group, 1, 1, ds.AuthorInfo, "author");
                    ds.PopulateDataSheet(_myRegDS.Reference.Date, 2, 1, ds.AuthorInfo, "author");

                    if (_myRegDS.Type == "rbs")
                    {
                        RowDefinition rowDef1 = new RowDefinition();
                        ds.DataSheet.RowDefinitions.Add(rowDef1);
                        ds.PopulateDataSheet(_myRegDS.Rbs.FamilyName, 8, 1, ds.DataSheet);
                        TextBlock RBSFam = new TextBlock();
                        RBSFam.Text              = "Family";
                        RBSFam.FontSize          = 14;
                        RBSFam.FontWeight        = FontWeights.Bold;
                        RBSFam.VerticalAlignment = VerticalAlignment.Top;
                        // COME BACK TO THIS LATER

                        ds.DataSheet.Children.Add(RBSFam);
                        Grid.SetRow(RBSFam, 8);
                    }
                    else if (_myRegDS.Type == "terminator")
                    {
                        RowDefinition rowDef1 = new RowDefinition();
                        RowDefinition rowDef2 = new RowDefinition();
                        RowDefinition rowDef3 = new RowDefinition();
                        RowDefinition rowDef4 = new RowDefinition();

                        ds.DataSheet.RowDefinitions.Add(rowDef1);
                        ds.DataSheet.RowDefinitions.Add(rowDef2);
                        ds.DataSheet.RowDefinitions.Add(rowDef3);
                        ds.DataSheet.RowDefinitions.Add(rowDef4);

                        TextBlock Direction = new TextBlock();
                        Direction.Text     = "Direction";
                        Direction.FontSize = 18;
                        ds.DataSheet.Children.Add(Direction);
                        Grid.SetRow(Direction, 8);

                        ds.PopulateDataSheet(_myRegDS.Terminators.Direction, 8, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ForwardEff, 9, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ReversedEff, 10, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ReversedVers, 11, 1, ds.DataSheet);
                    }

                    #endregion

                    #region Populating Publications
                    Func <String, PubList> _GetPublications =
                        delegate(String id) { return(new PubList(id)); };
                    Action <PubList> callback = delegate(PubList result)
                    {
                        //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

                        int m = 0;

                        if (result.Titles.Count == 0)
                        {
                            int Count = result.Titles.Count;
                            SurfaceListBoxItem NoResults = new SurfaceListBoxItem();
                            TextBlock          Content   = new TextBlock();
                            Content.Text      = "No Results Found";
                            NoResults.Content = Content;
                            ds.Publictions.Items.Add(NoResults);
                        }

                        if (result.Titles.Count > 0)
                        {
                            int TotalArticles = result.Titles.Count;
                            SurfaceListBoxItem ArticleCount = new SurfaceListBoxItem();
                            TextBlock          CountContent = new TextBlock();
                            CountContent.Text    = "Results Found: " + TotalArticles as string;
                            ArticleCount.Content = CountContent;
                            ds.Publictions.Items.Add(ArticleCount);
                        }

                        foreach (String Titles in result.Titles)
                        {
                            //To Test if titles are actually adding
                            SurfaceListBoxItem item      = new SurfaceListBoxItem();
                            TextBlock          PubTitles = new TextBlock();
                            item.Selected += new RoutedEventHandler(item_Selected);
                            item.Content   = Titles;
                            PubTitles.Tag  = result.Links.ElementAt(m);
                            //item.Tag = result.Authors.ElementAt(m);
                            ds.Publictions.Items.Add(item);
                            RowDefinition rowDef1 = new RowDefinition();
                            RowDefinition rowDef2 = new RowDefinition();
                            RowDefinition rowDef3 = new RowDefinition();
                            RowDefinition rowDef4 = new RowDefinition();

                            abs = new PubAbstract(PubTitles.Tag as string, result.getAuthors());

                            item.Tag = "Title:  " + item.Content as string + "\r\n" + "\r\n" + "\r\n"

                                       + "Authors:   " + result.Authors.ElementAt(m) as string + "\r\n" + "\r\n"

                                       + "Abstract:" + "\r\n" + "\r\n"

                                       + abs.getAbstract() as string;

                            m += 1;
                            Console.WriteLine(m);

                            if (m > 20)
                            {
                                break;
                            }
                        }

                        /*foreach (String Titles in result.Titles)
                         * {
                         *  TextBlock Middle = new TextBlock();
                         *  Middle.Text = Titles;
                         *  //ds.Publications.Children.Add(Middle);
                         *  Grid.SetRow(Middle, m);
                         *  m += 1;
                         #endregion
                         * //publications location maybe
                         * //Creates a list of PubMed source related to the query
                         *
                         * }*/
                    };
                    _Publist = _progressBarWrapper.execute <String, PubList>(_GetPublications, _myRegDS.BasicInfo.DescriptionName, callback);
                    #endregion
                    SurfaceWindow1.addData(sender, ds);
                };
                _dataSheet = _progressBarWrapper.execute <String, RegDataSheet>(_getRegDataSheet, partName.Text, _getRegDataSheetCallback);
            }
        }
Exemplo n.º 22
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;
        }
Exemplo n.º 23
0
        //Detects L1module drop target and copies its data into appropriate placeholder
        //Checks if module is full; if so, auto-generate new template and enable dragging on full module
        private void PartInL1()
        {
            //try
            //{
            Point pt = SurfaceWindow1.transformCoords(this, sw1.L1.L1_manTab);

            VisualTreeHelper.HitTest(sw1.L1.L1_manTab, null, new HitTestResultCallback(TargetL1MCallback), new PointHitTestParameters(pt));



            if (targetL1M != null)
            {
                Part L1manclone = clone();
                L1manclone.IsManipulationEnabled = false;
                L1manclone.targetL1M             = targetL1M;

                if (_type == "prom")
                {
                    targetL1M.L1Prom.copyPartInfoFrom(this);
                }
                else if (_type == "rbs")
                {
                    targetL1M.L1RBS.copyPartInfoFrom(this);
                }
                else if (_type == "cds")
                {
                    targetL1M.L1CDS.copyPartInfoFrom(this);
                }
                else if (_type == "term")
                {
                    targetL1M.L1Term.copyPartInfoFrom(this);
                }
                //Console.WriteLine("Target detected!");

                //Check to see if L1M is full and new template needed
                Boolean isFull = true;
                foreach (UIElement elem in targetL1M.L1Grid.Children)
                {
                    if (elem.GetType() == typeof(Part))
                    {
                        Part p = (Part)elem;
                        if (p.Opacity < 1)
                        {
                            isFull = false;
                            break;
                        }
                    }
                }

                if (isFull)
                {
                    sw1.L1.addL1Module();
                    targetL1M.IsManipulationEnabled        = true;
                    targetL1M.Template.Visibility          = System.Windows.Visibility.Hidden;
                    targetL1M.L1ElementMenu.ActivationMode = ElementMenuActivationMode.AlwaysActive;
                }
            }
            else
            {     //Dumped; check if delete from palette, too
                //Console.WriteLine("Missed!");
                sw1.swipeToDelete(this);
            }
            //}
            //catch (Exception exc) { Console.WriteLine("PartInL1 \n" + exc); }
        }
Exemplo n.º 24
0
        private void item_Selected(Object sender, RoutedEventArgs e)
        {
            try
            {
                SurfaceListBoxItem i = sender as SurfaceListBoxItem;

                //abs = new PubAbstract(result.Links.ElementAt(ds.Publictions.Items.IndexOf(i)), result.getAuthors());

                ScatterViewItem absBox = new ScatterViewItem();
                absBox.CanRotate = false;
                absBox.CanScale  = false;
                TextBlock abstext = new TextBlock();
                abstext.Text = i.Tag as string;

                SurfaceWindow1.addData(sender, absBox);

                absBox.Content = abstext;

                //absBox.absgrid.Children.Add(abstext);


                absBox.Background  = Brushes.SteelBlue;
                abstext.Background = Brushes.White;
                abstext.Margin     = new Thickness(10);

                absBox.Width      = 800;
                absBox.MinHeight  = 600;
                abstext.Width     = 780;
                abstext.MinHeight = 580;

                absBox.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(absBox_ContainerManipulationCompleted);

                /*TextBlock Title = new TextBlock();
                 * Title.Text = i.Content as string;
                 * absBox.absgrid.Children.Add(Title);
                 * Grid.SetRow(Title, 0);
                 * Grid.SetColumn(Title, 1);
                 *
                 * TextBlock Authors = new TextBlock();
                 * Authors.Text = result.Authors.ElementAt(ds.Publictions.Items.IndexOf(i));
                 * absBox.absgrid.Children.Add(Title);
                 * Grid.SetRow(Authors, 1);
                 * Grid.SetColumn(Authors, 1);
                 *
                 * TextBlock Journal = new TextBlock();
                 * Journal.Text = abs.getJournal();
                 * absBox.absgrid.Children.Add(Journal);
                 * Grid.SetRow(Journal, 2);
                 * Grid.SetColumn(Journal, 1);
                 *
                 *
                 * ds.Publictions.Items.IndexOf(i);
                 *
                 * /*ScatterViewItem abstractbox = new ScatterViewItem();
                 * TextBlock abstext = new TextBlock();
                 * SurfaceListBoxItem i = sender as SurfaceListBoxItem;
                 * abstext.Text = i.Tag as string;
                 * abstractbox.Content = abstext;*/

                sw1.L0.L0_SV.Items.Add(absBox);
            }
            catch (Exception exc) { Console.WriteLine(exc); }
        }
Exemplo n.º 25
0
 private void hideProgressBar()
 {
     SurfaceWindow1.getProgressIndicator(this).Visibility = Visibility.Collapsed;
 }
Exemplo n.º 26
0
 private void showProgressBar()
 {
     SurfaceWindow1.getProgressIndicator(this).Visibility = Visibility.Visible;
 }