Ejemplo n.º 1
0
        //method to check sockets for variables
        private static void findSocketedMethods(Block platform, Block newMethodBlock)
        {
            List <int> socketLocs = socketFinder(platform);
            ListBox    socket;

            //cycling through sockets to search
            foreach (int locale in socketLocs)
            {
                socket = socketMole(platform, locale);
                if (socket.Items.Count > 0)
                {
                    Block tempBlock = (Block)socket.Items.ElementAt(0);
                    //recursive call to go as deep into socket as possible
                    if (tempBlock.flag_hasSocks && !tempBlock.Text.Equals("METHOD"))
                    {
                        findSocketedMethods(tempBlock, newMethodBlock);
                    }
                    else if (tempBlock.metadataList.Count >= 2 && tempBlock.metadataList[1].Equals(newMethodBlock.metadataList[1])) //bearing and infinite blocks need the metadatalistcheck
                    {
                        ListBox socketBox         = tempBlock.Parent as ListBox;
                        SocketDragDropTarget SDDT = socketBox.Parent as SocketDragDropTarget;
                        SDDT.removeItem(socketBox);
                        SDDT.ResizeAndAdd(socketBox, newMethodBlock.cloneSelf(true));
                    }
                    else if (tempBlock.flag_hasSocks) //method in a method check?
                    {
                        findSocketedMethods(tempBlock, newMethodBlock);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //these are methods used to locate blocks and sockets, as well as performing potential transfers
        #region Socket Location and Transfer Methods

        //method to tunnel into the block and return the socket that is at the given position
        public static ListBox socketMole(Block source, int i)
        {
            List <System.Windows.UIElement> components;

            //checking for methods
            if (source.flag_isCustom && source.flag_transformer)
            {
                //checking if in main panel or socket based on whether the line number is present
                if (source.innerPane.Children.Count == 4)
                {
                    StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(3);
                    components = innards.Children.ToList();
                }
                else
                {
                    StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(2);
                    components = innards.Children.ToList();
                }
            }
            //checking for assignment blocks and diverting accordingly
            else if (source.ToString().Contains("ASSIGN"))
            {
                StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(2);
                components = innards.Children.ToList();
            }
            //checking for logic-style blocks
            else if (source.flag_transformer)
            {
                //accounting for situations where the block is already transformed
                if (source.innerPane.Children.ElementAt(0) is StackPanel)
                {
                    StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(0);
                    components = innards.Children.ToList();
                }
                else
                {
                    i++;
                    components = source.innerPane.Children.ToList();
                }
            }
            else
            {
                components = source.innerPane.Children.ToList();
            }

            //getting the socket to be returned
            SocketDragDropTarget SDDT = (SocketDragDropTarget)components.ElementAt(i);
            ListBox listBox           = (ListBox)SDDT.Content;

            return(listBox);
        }
Ejemplo n.º 3
0
        public static void AddToSocket(Block source, int i, Block child)
        {
            List <System.Windows.UIElement> components;

            //checking for logic-style blocks
            if (!(source.innerPane.Children.ElementAt(0) is TextBlock))
            {
                StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(0);
                components = innards.Children.ToList();
            }
            //checking for assignment blocks and diverting accordingly
            else if (source.ToString().Contains("ASSIGN") && source.innerPane.Children.Count > 2)
            {
                StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(2);
                components = innards.Children.ToList();
            }
            //checking for method blocks
            else if (source.flag_isCustom && source.flag_transformer)
            {
                //checking if in main panel or socket
                if (source.innerPane.Children.Count == 4)
                {
                    StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(3);
                    components = innards.Children.ToList();
                }
                else
                {
                    if (source.innerPane.Children.ElementAt(2) is TextBlock)
                    {
                        components = new List <UIElement>();
                    }
                    else
                    {
                        StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(2);
                        components = innards.Children.ToList();
                    }
                }
            }
            else
            {
                components = source.innerPane.Children.ToList();
            }

            SocketDragDropTarget SDDT = (SocketDragDropTarget)components.ElementAt(i);
            ListBox listBox           = (ListBox)SDDT.Content;

            SDDT.ResizeAndAdd(listBox, child);
        }
Ejemplo n.º 4
0
        //return the block of the dropTarget's parent
        public static Block getParentBlock(ListBox dropTarget)
        {
            SocketDragDropTarget SDDT = (SocketDragDropTarget)dropTarget.Parent; //destination listbox's socket drop target
            StackPanel           SP   = (StackPanel)SDDT.Parent;                 //destination listbox's main stack panel

            //checking if the destination listbox is a transformed block
            if (SP.Parent is StackPanel)
            {
                SP = (StackPanel)SP.Parent; //transformed block's outer stackpanel
            }
            Grid   G = (Grid)SP.Parent;     //destination listbox's primary grid
            Canvas C = (Canvas)G.Parent;    //destination listbox's main canvas
            Border B = (Border)C.Parent;    //destination listbox's outer border

            return((Block)B.Parent);        //returning the destination listbox's actual parent block
        }
Ejemplo n.º 5
0
        //returns the string of the dropTarget's parent block
        public static string checkParentBlock(ListBox dropTarget)
        {
            SocketDragDropTarget SDDT = (SocketDragDropTarget)dropTarget.Parent; //destination listbox's socket drop target
            StackPanel           SP   = (StackPanel)SDDT.Parent;                 //destination listbox's main stack panel
            Grid G;                                                              //declaring the main grid

            //checking if the destination listbox is a transformed block
            if (SP.Parent is StackPanel)
            {
                StackPanel SP2 = (StackPanel)SP.Parent; //transformed block's outer stackpanel
                G = (Grid)SP2.Parent;                   //transformed block's primary grid
            }
            else
            {
                G = (Grid)SP.Parent;     //destination listbox's primary grid
            }
            Canvas C = (Canvas)G.Parent; //destination listbox's main canvas
            Border B = (Border)C.Parent; //destination listbox's outer border

            return(B.Parent.ToString()); //returning the destination listbox's actual parent block name
        }
Ejemplo n.º 6
0
        //method to return a list of sockets in the destination block, based on the destination listbox
        private static List <ListBox> getDestinationBlockSockets(ListBox destination)
        {
            List <ListBox>                  socketList = new List <ListBox>();                     //list of sockets found
            SocketDragDropTarget            SDDT       = (SocketDragDropTarget)destination.Parent; //destination listbox's socket target
            StackPanel                      panel      = (StackPanel)SDDT.Parent;                  //destination block's stackpanel
            List <System.Windows.UIElement> components = panel.Children.ToList();                  //children of destination block

            //cycling through the block's children to find a socket and adding it to the list if so
            foreach (System.Windows.UIElement element in components)
            {
                if (element is SocketDragDropTarget)
                {
                    ListBox b = ((SocketDragDropTarget)element).Content as ListBox;
                    if (b.ToString().Contains("ListBox"))
                    {
                        socketList.Add(b);
                    }
                }
            }
            return(socketList);
        }