예제 #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);
                    }
                }
            }
        }
예제 #2
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);
        }