Example #1
0
        private SubNodeBase DefineNode(int index, int max, NodeStructure configuration)
        {
            var minusHalfMax          = -(max / 2);
            var indexFromMinusHalfMax = minusHalfMax + index;
            var forthPartOfPI         = Math.PI / 4;
            //var
            var multiplierForLeftMove = Math.Sin(Math.PI / 2 + (Math.PI / 3.95 * indexFromMinusHalfMax));
            var multiplierForTopMove  = Math.Cos(Math.PI / 2 + (Math.PI / 3.95 * indexFromMinusHalfMax));
            var radius     = 120 + 5 * max / 2;
            var newSubNode = new SubNode(Canvas.GetLeft(this),
                                         Canvas.GetTop(this),
                                         Canvas.GetLeft(this) - multiplierForLeftMove * radius,
                                         Canvas.GetTop(this) - multiplierForTopMove * radius,
                                         //Canvas.GetTop(this) + ((max - 1) * 100 / 2) - index * 100,
                                         nodeStage + 1, configuration);

            //newSubNode.StartEjecting();
            return(newSubNode);
        }
Example #2
0
        public ContentResult GetTree()
        {
            //Result<List<ParentNode>> returnResult = null;
            List <ParentNode> tree       = new List <ParentNode>();
            ParentNode        parentNode = null;
            SubNode           subNode    = null;

            HXD.MS.Entity.User user = (HXD.MS.Entity.User)SessionHelper.Get("User");
            if (user != null)
            {
                DataTable parents = menuBll.GetUserMenuData(user.Id, 0);
                foreach (DataRow dr in parents.Rows)
                {
                    int menuId   = Convert.ToInt32(dr["Id"]);
                    int parentId = Convert.ToInt32(dr["ParentId"]);
                    parentNode = new ParentNode(menuId, dr["Name"].ToString(), dr["Icon"].ToString());
                    DataTable subNodes = menuBll.GetUserMenuData(user.Id, menuId);
                    if (subNodes.Rows.Count > 0)
                    {
                        parentNode.State = "closed";
                    }
                    else
                    {
                        parentNode.State = "open";
                    }
                    foreach (DataRow subMenu in subNodes.Rows)
                    {
                        menuId   = Convert.ToInt32(subMenu["Id"]);
                        parentId = Convert.ToInt32(subMenu["ParentId"]);
                        subNode  = new SubNode(menuId, subMenu["Name"].ToString(), subMenu["Link"].ToString(), subMenu["Icon"].ToString());
                        parentNode.children.Add(subNode);
                    }
                    tree.Add(parentNode);
                }
            }
            return(Content(AjaxMsgHelper.AjaxMsg(CodeType.Ok, "ok", tree)));
        }
Example #3
0
        public void RunCategory()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(p.BaseURL + "categories");
            string     xmlcontents = doc.InnerXml;
            XmlElement xelRoot     = doc.DocumentElement;

            XmlNodeList Categories = xelRoot.SelectNodes("/Categories/Category");

            foreach (XmlNode xndNode in Categories)
            {
                Category c = new Category();
                c.Name = xndNode["Name"].InnerText;
                AllCat.Add(c);
                Console.WriteLine("Category: " + c.Name);

                XmlNodeList SubCategories = xndNode.SelectNodes("Subcategory");
                foreach (XmlNode SubNode in SubCategories)
                {
                    SubCategory sc = new SubCategory();
                    sc.Name = SubNode["Name"].InnerText;
                    AllSubCat.Add(sc);
                    Console.WriteLine("SubCategory: " + SubNode["Name"].InnerText);

                    XmlNodeList SubSubCategories = SubNode.SelectNodes("Subcategory");
                    foreach (XmlNode SubSubNode in SubCategories)
                    {
                        SubSubCategory ssc = new SubSubCategory();
                        ssc.Name = SubSubNode["Name"].InnerText;
                        AllSubSubCat.Add(ssc);
                        Console.WriteLine("SubSubCategory: " + SubSubNode["Name"].InnerText);
                    }
                }
            }
        }
Example #4
0
        private bool TryExpression(ParserContext context, out IAstNode instr)
        {
            IAstNode value2;

            if (context.Stream.Consume <IAstNode>(TryTerm, context, out var currInstr))
            {
                instr = currInstr;

                while (!context.Stream.Eof)
                {
                    if (context.Stream.Consume(TokenTypes.Plus))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new AddNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.Minus))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new SubNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.GreaterThan))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new GreaterThanNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.LessThan))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new LessThanNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.Equal))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new EqualNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.NotEqual))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new NotEqualNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else
                    {
                        return(true);
                    }
                }

                return(true);
            }

            instr = null;
            return(false);
        }
 public void AddSub(SubNode subNodeToAdd)
 {
     _subList.Add(subNodeToAdd);
 }
Example #6
0
        public WolframAlphaQueryResult LoadResponse(XmlDocument Response)
        {
            System.Threading.Thread.Sleep(1);

            XmlNode MainNode = Response.SelectNodes("/queryresult")[0];

            WA_QueryResult              = new WolframAlphaQueryResult();
            WA_QueryResult.Success      = Convert.ToBoolean(MainNode.Attributes["success"].Value);
            WA_QueryResult.ErrorOccured = Convert.ToBoolean(MainNode.Attributes["error"].Value);
            WA_QueryResult.NumberOfPods = Convert.ToInt32(MainNode.Attributes["numpods"].Value);
            WA_QueryResult.Timing       = Convert.ToDouble(MainNode.Attributes["timing"].Value.Replace(".", ","));
            WA_QueryResult.TimedOut     = MainNode.Attributes["timedout"].Value;
            WA_QueryResult.DataTypes    = MainNode.Attributes["datatypes"].Value;
            WA_QueryResult.Pods         = new List <WolframAlphaPod>();

            foreach (XmlNode Node in MainNode.SelectNodes("pod"))
            {
                System.Threading.Thread.Sleep(1);

                WolframAlphaPod Pod = new WolframAlphaPod();

                Pod.Title           = Node.Attributes["title"].Value;
                Pod.Scanner         = Node.Attributes["scanner"].Value;
                Pod.Position        = Convert.ToInt32(Node.Attributes["position"].Value);
                Pod.ErrorOccured    = Convert.ToBoolean(Node.Attributes["error"].Value);
                Pod.NumberOfSubPods = Convert.ToInt32(Node.Attributes["numsubpods"].Value);
                Pod.SubPods         = new List <WolframAlphaSubPod>();

                foreach (XmlNode SubNode in Node.SelectNodes("subpod"))
                {
                    System.Threading.Thread.Sleep(1);

                    WolframAlphaSubPod SubPod = new WolframAlphaSubPod();
                    SubPod.Title = SubNode.Attributes["title"].Value;

                    foreach (XmlNode ContentNode in SubNode.SelectNodes("plaintext"))
                    {
                        System.Threading.Thread.Sleep(1);
                        SubPod.PodText = ContentNode.InnerText;
                    }

                    foreach (XmlNode ContentNode in SubNode.SelectNodes("img"))
                    {
                        System.Threading.Thread.Sleep(1);

                        WolframAlphaImage Image = new WolframAlphaImage();
                        Image.Location  = new Uri(ContentNode.Attributes["src"].Value);
                        Image.HoverText = ContentNode.Attributes["alt"].Value;
                        Image.Title     = ContentNode.Attributes["title"].Value;
                        Image.Width     = Convert.ToInt32(ContentNode.Attributes["width"].Value);
                        Image.Height    = Convert.ToInt32(ContentNode.Attributes["height"].Value);
                        SubPod.PodImage = Image;
                    }

                    Pod.SubPods.Add(SubPod);
                }

                WA_QueryResult.Pods.Add(Pod);
            }

            return(WA_QueryResult);
        }
Example #7
0
 public abstract T Visit(SubNode node);
Example #8
0
    void Inherit()
    {
        string inheritedClass     = "";
        bool   isAlreadyInherited = false;

        foreach (Node node in target.nodes)
        {
            if (node is InheritTargetNode t)
            {
                isAlreadyInherited = true;
                inheritedClass     = t.target;
                break;
            }
        }
        if (!isAlreadyInherited)
        {
            InheritTargetNode t = target.AddNode <InheritTargetNode>() as InheritTargetNode;
            t.name        = "Inherit Target";
            t.target      = inheritGraph.name;
            t.IsDeletable = false;
            AssetDatabase.AddObjectToAsset(t, target);
            List <Node> createdNonSubNodes = new List <Node>();
            Dictionary <string, List <string> > outputPorts = new Dictionary <string, List <string> >();
            foreach (Node _node in inheritGraph.nodes)
            {
                if (_node == null)
                {
                    continue;
                }
                if (_node is SubNode sub)
                {
                    SubNode node = target.AddNode(_node.GetType()) as SubNode;
                    node.OnCreated();
                    node.name        = inherited_prefix + _node.name;
                    node.nodeName    = sub.nodeName;
                    node.isInherited = true;
                    node.InheritFrom(_node);
                    node.position = _node.position;
                    AssetDatabase.AddObjectToAsset(node, target);
                }
                else if (_node is ITreeGraphNode i)
                {
                    Node newNode = target.AddNode(_node.GetType());
                    newNode.OnCreated();

                    if (newNode is ITreeGraphNode new_i)
                    {
                        new_i.SetNodeName(i.GetNodeName());
                        new_i.InheritFrom(_node);
                    }

                    newNode.name     = _node.name;
                    newNode.position = _node.position;
                    AssetDatabase.AddObjectToAsset(newNode, target);

                    string nodeName = i.GetNodeName();
                    if (!createdNonSubNodes.Contains(newNode))
                    {
                        createdNonSubNodes.Add(newNode);
                        if (!outputPorts.ContainsKey(nodeName))
                        {
                            outputPorts[nodeName] = new List <string>();
                            var outputs = _node.GetOutputPort("output").GetConnections();
                            foreach (var output in outputs)
                            {
                                if (output.node is ITreeGraphNode ibt_output)
                                {
                                    if (!outputPorts[nodeName].Contains(ibt_output.GetNodeName()))
                                    {
                                        outputPorts[nodeName].Add(ibt_output.GetNodeName());
                                    }
                                }
                            }
                        }
                    }
                }
            }


            foreach (Node parent in createdNonSubNodes)
            {
                ITreeGraphNode ibt_parent = parent as ITreeGraphNode;
                if (outputPorts.ContainsKey(ibt_parent.GetNodeName()))
                {
                    foreach (string outputTarget in outputPorts[ibt_parent.GetNodeName()])
                    {
                        Node child = null;
                        foreach (Node _child in createdNonSubNodes)
                        {
                            ITreeGraphNode ibt_target = _child as ITreeGraphNode;
                            if (ibt_target.GetNodeName() == outputTarget)
                            {
                                child = _child;
                                break;
                            }
                        }

                        if (child != null)
                        {
                            parent.GetOutputPort("output").Connect(child.GetInputPort("input"));
                        }
                    }
                }
            }

            if (NodeEditorPreferences.GetSettings().autoSave)
            {
                AssetDatabase.SaveAssets();
            }
            NodeEditorWindow.RepaintAll();
        }
        else
        {
            Debug.LogError("This graph has already inherited \"" + inheritedClass + "\".");
        }
    }
    // $ANTLR start "additiveExpression"
    // JavaScript.g:302:1: additiveExpression : multiplicativeExpression ( ( ( LT )* ( '+' | '-' ) additiveExpression )=> ( LT )* ( '+' | '-' ) additiveExpression | ) ;
    public JavaScriptParser.additiveExpression_return additiveExpression() // throws RecognitionException [1]
    {   
        JavaScriptParser.additiveExpression_return retval = new JavaScriptParser.additiveExpression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken LT357 = null;
        IToken char_literal358 = null;
        IToken char_literal359 = null;
        JavaScriptParser.multiplicativeExpression_return multiplicativeExpression356 = default(JavaScriptParser.multiplicativeExpression_return);

        JavaScriptParser.additiveExpression_return additiveExpression360 = default(JavaScriptParser.additiveExpression_return);


        object LT357_tree=null;
        object char_literal358_tree=null;
        object char_literal359_tree=null;

        try 
    	{
            // JavaScript.g:303:2: ( multiplicativeExpression ( ( ( LT )* ( '+' | '-' ) additiveExpression )=> ( LT )* ( '+' | '-' ) additiveExpression | ) )
            // JavaScript.g:303:4: multiplicativeExpression ( ( ( LT )* ( '+' | '-' ) additiveExpression )=> ( LT )* ( '+' | '-' ) additiveExpression | )
            {
            	root_0 = (object)adaptor.GetNilNode();

            	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression2725);
            	multiplicativeExpression356 = multiplicativeExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, multiplicativeExpression356.Tree);
            	// JavaScript.g:303:29: ( ( ( LT )* ( '+' | '-' ) additiveExpression )=> ( LT )* ( '+' | '-' ) additiveExpression | )
            	int alt187 = 2;
            	alt187 = dfa187.Predict(input);
            	switch (alt187) 
            	{
            	    case 1 :
            	        // JavaScript.g:304:3: ( ( LT )* ( '+' | '-' ) additiveExpression )=> ( LT )* ( '+' | '-' ) additiveExpression
            	        {
            	        	// JavaScript.g:304:44: ( LT )*
            	        	do 
            	        	{
            	        	    int alt185 = 2;
            	        	    int LA185_0 = input.LA(1);

            	        	    if ( (LA185_0 == LT) )
            	        	    {
            	        	        alt185 = 1;
            	        	    }


            	        	    switch (alt185) 
            	        		{
            	        			case 1 :
            	        			    // JavaScript.g:304:44: LT
            	        			    {
            	        			    	LT357=(IToken)Match(input,LT,FOLLOW_LT_in_additiveExpression2747); if (state.failed) return retval;

            	        			    }
            	        			    break;

            	        			default:
            	        			    goto loop185;
            	        	    }
            	        	} while (true);

            	        	loop185:
            	        		;	// Stops C# compiler whining that label 'loop185' has no statements

            	        	// JavaScript.g:304:47: ( '+' | '-' )
            	        	int alt186 = 2;
            	        	int LA186_0 = input.LA(1);

            	        	if ( (LA186_0 == 99) )
            	        	{
            	        	    alt186 = 1;
            	        	}
            	        	else if ( (LA186_0 == 100) )
            	        	{
            	        	    alt186 = 2;
            	        	}
            	        	else 
            	        	{
            	        	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	        	    NoViableAltException nvae_d186s0 =
            	        	        new NoViableAltException("", 186, 0, input);

            	        	    throw nvae_d186s0;
            	        	}
            	        	switch (alt186) 
            	        	{
            	        	    case 1 :
            	        	        // JavaScript.g:304:48: '+'
            	        	        {
            	        	        	char_literal358=(IToken)Match(input,99,FOLLOW_99_in_additiveExpression2752); if (state.failed) return retval;
            	        	        	if ( state.backtracking == 0 )
            	        	        	{char_literal358_tree = new AddNode(char_literal358) ;
            	        	        		root_0 = (object)adaptor.BecomeRoot(char_literal358_tree, root_0);
            	        	        	}

            	        	        }
            	        	        break;
            	        	    case 2 :
            	        	        // JavaScript.g:304:64: '-'
            	        	        {
            	        	        	char_literal359=(IToken)Match(input,100,FOLLOW_100_in_additiveExpression2760); if (state.failed) return retval;
            	        	        	if ( state.backtracking == 0 )
            	        	        	{char_literal359_tree = new SubNode(char_literal359) ;
            	        	        		root_0 = (object)adaptor.BecomeRoot(char_literal359_tree, root_0);
            	        	        	}

            	        	        }
            	        	        break;

            	        	}

            	        	PushFollow(FOLLOW_additiveExpression_in_additiveExpression2767);
            	        	additiveExpression360 = additiveExpression();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, additiveExpression360.Tree);

            	        }
            	        break;
            	    case 2 :
            	        // JavaScript.g:306:2: 
            	        {
            	        }
            	        break;

            	}


            }

            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	retval.Tree = (object)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);}
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }