Ejemplo n.º 1
0
        //Differentiates ElementMenu interaction from drag/drop interaction using minimum distance
        //Once minimum distance met, create copy to leave in original spot
        private void L1Module_ContainerManipulationDelta(object sender, ContainerManipulationDeltaEventArgs e)
        {
            try
            {
                Point current = this.Center;
                if (Math.Abs(Original.Y - current.Y) > 10 || Math.Abs(Original.X - current.X) > 10)
                {
                    L1Module l = sender as L1Module;
                    myClone             = l.clone();
                    myClone.Center      = Original;
                    myClone.BorderBrush = l.BorderBrush;

                    ScatterView parent = l.Parent as ScatterView;
                    parent.Items.Add(myClone);

                    if ((parent.Name == "L1_permTab") || (parent.Name == "L1_manTab"))
                    { //Check if in Level1 and give clone L1-appropriate behavior
                        myClone.Opacity = 0.5;
                        myClone.IsManipulationEnabled = false;
                    }
                    else
                    { //Moving L1Module within L2
                        l.changeParents_SV(parent, sw1.L2.L2_SV);
                    }

                    //Prevent it from continuously creating copies
                    l.ContainerManipulationDelta -= L1Module_ContainerManipulationDelta;
                }
            }
            catch (Exception exc) { Console.WriteLine("L1M Delta \n" + exc); }
        }
Ejemplo n.º 2
0
 //Result callback behavior for detection of target L1Modules in the Generate Manually tab
 //Detects Grids belonging to Parts and L1Modules and checks the name to differentiate between the two
 //Sets the dropped Part's targetL1Module variable to the L1Module parent detected
 public HitTestResultBehavior TargetL1MCallback(HitTestResult result)
 {
     if (result.VisualHit.GetType() == typeof(Grid))
     {
         Console.WriteLine("Detected a grid. Is it an L1Grid?");
         Grid targetGrid = (Grid)result.VisualHit;
         if (targetGrid.Name == "L1Grid")
         {
             Console.WriteLine("It was an L1Grid");
             targetL1M = (L1Module)targetGrid.Parent;
             Console.WriteLine(targetGrid.Name);
             return(HitTestResultBehavior.Stop);
         }
         else
         {
             Console.WriteLine("Detected the grid " + targetGrid.Name);
             return(HitTestResultBehavior.Continue);
         }
     }
     else
     {
         Console.WriteLine("Didn't detect a grid.");
         return(HitTestResultBehavior.Continue);
     }
 }
        //Constructor: Primer Designer launched by an L1Module
        public PrimerDesigner2(L1Module l1)
        {
            InitializeComponent();
            Sites.pd2 = this;
            Part.pd2 = this;
            L1Module.pd2 = this;
            L2Module.pd2 = this;
            PrimerDesigner1.pd2 = this;

            PD2_auto.Children.Add(new Sites());
            PD2_manual.Children.Add(new Sites());
            foreach (UIElement elem in l1.L1Grid.Children)
            {
                if (elem.GetType() == typeof(Part))
                {
                    Part p = (Part)elem;
                    addPartSiteSets(PD2_auto, p);
                    addPartSiteSets(PD2_manual, p);
                }
            }
            PD2_auto.Children.Add(new Sites());
            PD2_manual.Children.Add(new Sites());

            matchSites(PD2_auto);
            matchSites(PD2_manual);
        }
Ejemplo n.º 4
0
 //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;
 }
Ejemplo n.º 5
0
        //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;
        }
Ejemplo n.º 6
0
        //public Point SetPosition()
        //{
        //    Point newCenter;
        //    ScatterView parentSV = (ScatterView)this.Parent;
        //    double ParentWidth = parentSV.Width;
        //    int NumberParts = (int)Math.Floor((ParentWidth / (this.Width + 10)));
        //    double startX = Width / 2 + 10;
        //    double startY = (this.Height + 10) / 2;
        //    int count = parentSV.Items.Count;
        //    int multiplierX = (count - 1) % NumberParts;
        //    int multiplierY = (count - 1) / NumberParts;
        //    newCenter = new Point(startX + multiplierX * (Width + 10), startY + multiplierY * (Height + 10));


        //    return newCenter;
        //}

        #endregion

        #region DRAG AND DROP HELPERS

        //Clones the part and copies content values and type
        //Used in both Part_ContainerManipulationDelta and _...Completed
        public L1Module clone()
        {
            L1Module copy = new L1Module();

            copy.L1Prom.copyPartInfoFrom(this.L1Prom);
            copy.L1RBS.copyPartInfoFrom(this.L1RBS);
            copy.L1CDS.copyPartInfoFrom(this.L1CDS);
            copy.L1Term.copyPartInfoFrom(this.L1Term);
            return(copy);
        }
Ejemplo n.º 7
0
        private void select_PrimerDesigner(object sender, RoutedEventArgs e)
        {
            //Iterate through parts and get data for each before entering Primer Designer
            foreach (UIElement p in L1Grid.Children)
            {
                if (p.GetType() == typeof(Part))
                {
                    ((Part)p).getDataForPrimerDesigner();
                }
            }
            L1Module copy = clone();

            copy.PD.IsEnabled  = false;
            copy.PD.Visibility = Visibility.Collapsed;
            sw1.SW_SV.Items.Add(new PrimerDesigner2(copy));
        }
        //If scatterviewitem (Part, DS, Seq) swipe to delete
        public void swipeToDelete(ScatterViewItem svi)
        {
            if (svi.Center.X > (L0.Width - 100) || svi.Center.X < 100)
            {
                if (svi.GetType() == typeof(Part) || svi.GetType() == typeof(L1Module))
                {
                    ScatterView palette = new ScatterView();

                    if (svi.GetType() == typeof(Part))
                    {
                        Part p = (Part)svi;
                        palette = (ScatterView)p.MyClone.Parent;
                        palette.Items.Remove(p.MyClone);
                    }
                    if (svi.GetType() == typeof(L1Module))
                    {
                        L1Module l = (L1Module)svi;
                        palette = (ScatterView)l.MyClone.Parent;
                        palette.Items.Remove(l.MyClone);
                    }

                    List <ScatterViewItem> storeSVIList = new List <ScatterViewItem>();
                    foreach (ScatterViewItem m in palette.Items)
                    {
                        storeSVIList.Add(m);
                    }
                    palette.Items.Clear();
                    foreach (ScatterViewItem o in storeSVIList)
                    {
                        palette.Items.Add(o);
                        o.Center = SetPosition(o);
                    }
                    return;
                }
                L0.L0_SV.Items.Remove(svi);
                L1.L1_SV.Items.Remove(svi);
                L2.L2_SV.Items.Remove(svi);
                if (pd1 != null)
                {
                    pd1.MainSV.Items.Remove(svi);
                }
                if (pd2 != null)
                {
                    pd2.MainSV.Items.Remove(svi);
                }
            }
        }
        /// <summary>
        /// Generates and prints device permutations from all available parts.
        /// Obeys set permutation rules.
        /// </summary>
        /// <param name="?"></param>
        /// <param name="?"></param>
        /// <returns> All available device permutations from the parts given. </returns>

        public List <L2Module> Permute(List <L1Module> ListModulesToPermute)
        {
            List <L2Module> L2ModulesToReturn = new List <L2Module>();

            //Get current working directory
            string file = Directory.GetCurrentDirectory();

            //change directory to EugeneFiles directory and read text file based on ListModulesToPermute count
            file = file.Substring(0, file.IndexOf("bin")) + @"Resources\EugeneFiles\permute" + ListModulesToPermute.Count + ".txt";
            string       text = "";
            StreamReader sr   = new StreamReader(file);

            while (!sr.EndOfStream) //read to end of file
            {
                text = sr.ReadLine().ToString();
            }
            sr.Close();

            text = text.Replace("Device hybridDevice_", "");
            text = text.Replace("absDevice", "");
            //parsing text file and adding permutations to the L2 module
            string[] textminusparentheses = text.Split(new char[] { '(', ')' });

            foreach (string numberasstringcomma in textminusparentheses)
            {
                if (numberasstringcomma.Replace(" ", "").Length > 2 && !(numberasstringcomma.StartsWith(","))) //go through each individual permutation
                {
                    string[] permOrderArray = numberasstringcomma.Split(new char[] { ',' });
                    //clean--> to do
                    L2Module tempL2Module = new L2Module();
                    foreach (string permNumberString in permOrderArray)
                    {
                        int index = Convert.ToInt32(permNumberString) - 1;

                        L1Module childToAdd = ListModulesToPermute.ElementAt(index).clone();
                        childToAdd.IsManipulationEnabled = false;
                        //Disable manipulation and assoc. events
                        childToAdd.Background = sw1.L2.L1MColors.ElementAt(tempL2Module.Children.Count - 1);
                        //childToAdd.BorderBrush = childToAdd.Background;
                        tempL2Module.L2M.Children.Add(childToAdd);
                    }
                    L2ModulesToReturn.Add(tempL2Module);
                }
            }

            return(L2ModulesToReturn);
        }
        //Constructor: Primer Designer launched by an L1Module
        public PrimerDesigner2(L1Module l1)
        {
            InitializeComponent();
            Sites.pd2           = this;
            Part.pd2            = this;
            L1Module.pd2        = this;
            L2Module.pd2        = this;
            PrimerDesigner1.pd2 = this;

            //_moduleNum = 1; //launched by L1Module

            //PD2_auto.Children.Add(new Sites()); //remove duplicate fusion sites
            //PD2_manual.Children.Add(new Sites()); //remove duplicate fusion sites

            int forLoopCounter = 0; //for keeping track of last part to add second fusion site

            foreach (UIElement elem in l1.L1Grid.Children)
            {
                if (elem.GetType() == typeof(Part))
                {
                    Part p = (Part)elem;

                    if (forLoopCounter == 3) //4th Part being added, add second fusion site
                    {
                        addPartSiteSets(PD2_auto, p, true);
                        addPartSiteSets(PD2_manual, p, true);
                    }
                    else
                    {
                        addPartSiteSets(PD2_auto, p, false);
                        addPartSiteSets(PD2_manual, p, false);
                    }
                    forLoopCounter++;
                }
            }
            //PD2_auto.Children.Add(new Sites()); //remove duplicate fusion sites
            //PD2_manual.Children.Add(new Sites()); //remove duplicate fusion sites

            //matchSites(PD2_auto); //remove duplicate fusion sites
            //matchSites(PD2_manual); //remove duplicate fusion sites

            //initializeFusionSiteChecker(); //initialize array to hold all possible fusion sites to be added
        }
Ejemplo n.º 11
0
        //Determines user intent by checking location of drop against threshold and whether a clone exists (i.e. drag intent)
        private void L1Module_ContainerManipulationCompleted(object sender, ContainerManipulationCompletedEventArgs e)
        {
            L1Module    l      = sender as L1Module;
            ScatterView parent = l.Parent as ScatterView;

            try
            {
                if (!(myClone == null))
                {
                    if ((parent.Name == "L1_permTab") || (parent.Name == "L1_manTab"))
                    {
                        //Drop L1Module into L2 or delete
                        l.L1ModuleInL1();
                    }
                    else
                    {
                        //Drop L1Module into L2Module or delete
                        l.L1ModuleInL2();
                    }

                    parent.Items.Remove(l);
                }
                else
                {
                    if (parent.Name == "L2_L1ModulesSV")
                    { //If in L2
                        if (l.BorderBrush != Brushes.White)
                        {
                            //Restore white border
                            l.BorderBrush = Brushes.White;
                        }
                        else
                        {
                            l.BorderBrush = Brushes.Navy;
                        } //highlights border
                    }
                }
            }
            catch (Exception exc) { Console.WriteLine("L1M Completd \n" + exc); }
        }
Ejemplo n.º 12
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;
            }
        }
 public HitTestResultBehavior resultCallback(HitTestResult result)
 {
     if (result.VisualHit.GetType() == typeof(Grid))
     {
         Grid target = (Grid)result.VisualHit;
         if (target.Name == "L1Grid")
         {
             //Console.WriteLine("Found an L1Module.");
             L1Module parent = (L1Module)target.Parent;
             hitResult = parent;
             return(HitTestResultBehavior.Stop);
         }
         else
         {
             //Console.WriteLine("Didn't get the L1Module in the StackPanel.");
             return(HitTestResultBehavior.Continue);
         }
     }
     else
     {
         //Console.WriteLine("Didn't detect a Grid.");
         return(HitTestResultBehavior.Continue);
     }
 }
Ejemplo n.º 14
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);
            }
        }
        //Constructor: Primer Designer launched by an L1Module
        public PrimerDesigner2(L1Module l1)
        {
            InitializeComponent();
            Sites.pd2 = this;
            Part.pd2 = this;
            L1Module.pd2 = this;
            L2Module.pd2 = this;
            PrimerDesigner1.pd2 = this;

            //_moduleNum = 1; //launched by L1Module

            //PD2_auto.Children.Add(new Sites()); //remove duplicate fusion sites
            //PD2_manual.Children.Add(new Sites()); //remove duplicate fusion sites

            int forLoopCounter = 0; //for keeping track of last part to add second fusion site

            foreach (UIElement elem in l1.L1Grid.Children)
            {
                if (elem.GetType() == typeof(Part))
                {
                    Part p = (Part)elem;

                    if (forLoopCounter == 3) //4th Part being added, add second fusion site
                    {
                        addPartSiteSets(PD2_auto, p, true);
                        addPartSiteSets(PD2_manual, p, true);
                    }
                    else
                    {
                        addPartSiteSets(PD2_auto, p, false);
                        addPartSiteSets(PD2_manual, p, false);
                    }
                    forLoopCounter++;
                }
            }
            //PD2_auto.Children.Add(new Sites()); //remove duplicate fusion sites
            //PD2_manual.Children.Add(new Sites()); //remove duplicate fusion sites

            //matchSites(PD2_auto); //remove duplicate fusion sites
            //matchSites(PD2_manual); //remove duplicate fusion sites

            //initializeFusionSiteChecker(); //initialize array to hold all possible fusion sites to be added
        }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
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;
        }
Ejemplo n.º 18
0
 //Result callback behavior for detection of target L1Modules in the Generate Manually tab
 //Detects Grids belonging to Parts and L1Modules and checks the name to differentiate between the two
 //Sets the dropped Part's targetL1Module variable to the L1Module parent detected
 public HitTestResultBehavior TargetL1MCallback(HitTestResult result)
 {
     if (result.VisualHit.GetType() == typeof(Grid))
     {
         Console.WriteLine("Detected a grid. Is it an L1Grid?");
         Grid targetGrid = (Grid)result.VisualHit;
         if (targetGrid.Name == "L1Grid")
         {
             Console.WriteLine("It was an L1Grid");
             targetL1M = (L1Module)targetGrid.Parent;
             Console.WriteLine(targetGrid.Name);
             return HitTestResultBehavior.Stop;
         }
         else
         {
             Console.WriteLine("Detected the grid " + targetGrid.Name);
             return HitTestResultBehavior.Continue;
         }
     }
     else
     {
         Console.WriteLine("Didn't detect a grid.");
         return HitTestResultBehavior.Continue;
     }
 }