//Differentiates ElementMenu interaction from drag/drop interaction //Once minimum distance met, create copy to leave in original spot private void Part_ContainerManipulationDelta(object sender, ContainerManipulationDeltaEventArgs e) { try { Point x = this.Center; if (Math.Abs(Original.Y - x.Y) > 20 || Math.Abs(Original.X - x.X) > 20) { Part p = sender as Part; myClone = p.clone(); myClone.Center = Original; //Put clone in original's place myClone.BorderBrush = p.BorderBrush; ScatterView parent = p.Parent as ScatterView; parent.Items.Add(myClone); if (parent.Name == "L0_resultsSV") { //Check if Level0 and give clone L0-appropriate behavior (e.g. dimming/disabling) myClone.Opacity = 0.5; //Visually indicate not selectable myClone.IsManipulationEnabled = false; //Disable manipulation until original's fate determined } else { //Moving Part from L1 parts holder to L1Module build tabs; needs to be in L1_SV during transfer p.changeParents_SV(parent, sw1.L1.L1_SV); } //Prevent it from continuously creating copies p.ContainerManipulationDelta -= Part_ContainerManipulationDelta; } } catch (Exception exc) { Console.WriteLine("Part Delta \n" + exc); } }
/// <summary> /// Constructor helper: adds Parts and their fusion sites to panel /// </summary> /// <param name="parent"></param> /// <param name="p"></param> /// <param name="isLevel0">Boolean flag implemented to indicate whether this method is called in class constructor via Level 0, 1, or 2 /// (to determine whether to add a second fusion site after Part -- deals with duplicate fusion site issue @T.Feng)</param> private void addPartSiteSets(StackPanel parent, Part p, bool isLevel0) { Part copy = p.clone(); String seq1 = copy.SitesList.ElementAt(0).Sequence; String seq2 = copy.SitesList.ElementAt(1).Sequence; parent.Children.Add(new Sites(seq1)); copy.ElementMenu.Items.Remove(copy.PD); copy.BorderBrush = p.BorderBrush; copy.IsManipulationEnabled = false; parent.Children.Add(copy); //only add fusion site for seq2 if in Level 0 (Part), else next Part's seq1 fusion site will do it @T.Feng if (isLevel0) { parent.Children.Add(new Sites(seq2)); } }
//Constructor helper: adds Parts and their fusion sites to panel private void addPartSiteSets(StackPanel parent, Part p) { Part copy = p.clone(); String seq1 = copy.SitesList.ElementAt(0).Sequence; String seq2 = copy.SitesList.ElementAt(1).Sequence; parent.Children.Add(new Sites(seq1)); copy.ElementMenu.Items.Remove(copy.PD); copy.BorderBrush = p.BorderBrush; copy.IsManipulationEnabled = false; parent.Children.Add(copy); parent.Children.Add(new Sites(seq2)); }
//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 }
/// <summary> /// Constructor helper: adds Parts and their fusion sites to panel /// </summary> /// <param name="parent"></param> /// <param name="p"></param> /// <param name="isLevel0">Boolean flag implemented to indicate whether this method is called in class constructor via Level 0, 1, or 2 /// (to determine whether to add a second fusion site after Part -- deals with duplicate fusion site issue @T.Feng)</param> private void addPartSiteSets(StackPanel parent, Part p, bool isLevel0) { Part copy = p.clone(); String seq1 = copy.SitesList.ElementAt(0).Sequence; String seq2 = copy.SitesList.ElementAt(1).Sequence; parent.Children.Add(new Sites(seq1)); copy.ElementMenu.Items.Remove(copy.PD); copy.BorderBrush = p.BorderBrush; copy.IsManipulationEnabled = false; parent.Children.Add(copy); //only add fusion site for seq2 if in Level 0 (Part), else next Part's seq1 fusion site will do it @T.Feng if (isLevel0) parent.Children.Add(new Sites(seq2)); }