public void PopulateChildren(Map map, float searchStepTime, List <TreeSearchMoveInfo> possibleMoves) { // TODO: if we ever want to do searches more than 1 layer, we should re-implement opposite direction filtering foreach (TreeSearchMoveInfo moveInfo in possibleMoves) { Vector2 vec = moveInfo.BaseDir.Rotate(TankInfo.Rot); List <Vector2> passedPos = new List <Vector2>(); TankStateInfo newStateInfo; if (!moveInfo.IsJet) { newStateInfo = AIUtility.CalcPosInFutureWithRequestedDir(vec, searchStepTime, TankInfo, out passedPos); } else { newStateInfo = AIUtility.CalcPosInFutureWithRequestedDirJets(vec, searchStepTime, TankInfo, out passedPos); } HashSet <Node> passedNodes = new HashSet <Node>(); bool passedOutOfBounds = false; foreach (Vector2 pos in passedPos) { if (map.IsPositionWithinBounds(pos)) { passedNodes.Add(map.PositionToNode(pos)); } else { passedOutOfBounds = true; break; } } if (!passedOutOfBounds) { ChildNodes.Add(new LookaheadNode(this, vec, moveInfo.IsJet, newStateInfo, searchStepTime, passedNodes.ToList())); } } }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is ParameterNode) { if (Parameter1 == null) { Parameter1 = node.AstNode as ParameterNode; ChildNodes.Add(node.AstNode as ParameterNode); } else if (Parameter2 == null) { Parameter2 = node.AstNode as ParameterNode; ChildNodes.Add(node.AstNode as ParameterNode); } else if (Parameter3 == null) { Parameter3 = node.AstNode as ParameterNode; ChildNodes.Add(node.AstNode as ParameterNode); } else if (Parameter4 == null) { Parameter4 = node.AstNode as ParameterNode; ChildNodes.Add(node.AstNode as ParameterNode); } } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }
internal override void ReadChildElement(MSBuildXmlReader reader) { MSBuildChooseOption op = null; switch (reader.LocalName) { case "When": op = new MSBuildChooseOption(); break; case "Otherwise": op = new MSBuildChooseOption(true); break; } if (op != null) { op.ParentNode = this; op.Read(reader); ChildNodes = ChildNodes.Add(op); } else { base.ReadChildElement(reader); } }
/// <summary> /// Calculates the MiniMax tree for a particular board /// </summary> /// <param name="board">Current state of board</param> public MiniMaxTree(Board board) { // MiniMaxTree is only ever called for the Computer player, so presume next move // will always be computer. // Create the list of child nodes this.ChildNodes = new List <MiniMaxNode>(); for (var i = 0; i < Board.BoardSize; i++) { // For each empty cell in the current board if (board.Cells[i] == Board.Cell.Empty) { // Make a copy of the current board.. var childBoard = board.Clone(); // ..fill in the cell with Computers move and calculate score recursively var miniMaxNode = new MiniMaxNode(childBoard, i, Board.Cell.Computer, 0); // Finally, add the node to the children ChildNodes.Add(miniMaxNode); } } }
private void DoSplit() { _childNodes = new ChildNodes <T>(this); List <DataEntry <T, Rect> > tempEntryList = new List <DataEntry <T, Rect> >(_objects); _objects.Clear(); for (int i = 0; i < tempEntryList.Count; i++) { if (_childNodes.Fits(tempEntryList[i])) { _childNodes.Insert(tempEntryList[i]); } else { _objects.Add(tempEntryList[i]); } } PollActivity(); }
public void MoveDown(List <string> NamesToMoveDown) { // --------------------------------------------------------------------- // Move the specified child component names down one spot. // --------------------------------------------------------------------- for (int i = NamesToMoveDown.Count - 1; i >= 0; i--) { int ReferencePosition = ChildNameToIndex(NamesToMoveDown[i]); if (ReferencePosition < ChildNodes.Count - 1) { Component ComponentToMove = ChildNodes[ReferencePosition]; ChildNodes.Remove(ComponentToMove); ChildNodes.Insert(ReferencePosition + 1, ComponentToMove); } else { return; } } MyFile.PublishComponentChanged(this); }
public override void CollectDataFromChildren() { switch ((ChildNodes.First <ISqlNode>() as SqlKeyNode).Text.ToUpper()) { case "+": UnOp = UnOp.Plus; break; case "-": UnOp = UnOp.Minus; break; case "~": UnOp = UnOp.Tilde; break; case "NOT": UnOp = UnOp.Not; break; } }
public IfNode(NodeArgs args, AstNode test, AstNode ifTrue, AstNode ifFalse) : base(args) { ChildNodes.Clear(); Test = test; AddChild("Test", Test); IfTrue = ifTrue; if (IfTrue.IsEmpty()) { IfTrue = null; } AddChild("IfTrue", IfTrue); IfFalse = ifFalse; if (IfFalse.IsEmpty()) { IfFalse = null; } AddChild("IfFalse", IfFalse); }
private LibraryOrTypeNodeViewModel(VbaType type) { Name = type.Name; foreach (var f in type.Fields) { TypesOrMembers.Add(new MemberViewModel(f)); } foreach (var m in type.Methods) { TypesOrMembers.Add(new MemberViewModel(m)); } if (type.Hidden) { AccessUriSource = @"\Resources\lock.png"; } foreach (var i in type.ImplementedInterfaces) { ChildNodes.Add(new LibraryOrTypeNodeViewModel(i)); } SetIconUriSource(type); }
public void MoveUp(List <string> NamesToMoveUp) { // --------------------------------------------------------------------- // Move the specified child component names up one spot. // --------------------------------------------------------------------- for (int i = 0; i != NamesToMoveUp.Count; i++) { int ReferencePosition = ChildNameToIndex(NamesToMoveUp[i]); if (ReferencePosition > 0) { Component ComponentToMove = ChildNodes[ReferencePosition]; ChildNodes.Remove(ComponentToMove); ChildNodes.Insert(ReferencePosition - 1, ComponentToMove); } else { return; } } MyFile.PublishComponentChanged(this); }
internal void AddNode(IList <string> routeTemplateFragments, Type requestHandler) { var headFragment = routeTemplateFragments.First(); var remainingTemplateFragments = routeTemplateFragments.Skip(1).ToList(); var childNode = FindChildNode(headFragment); if (childNode != null) { childNode.AddNode(remainingTemplateFragments, requestHandler); } else { var newChildNode = new RouteHandlerLookupNode(headFragment, remainingTemplateFragments, requestHandler); ChildNodes.Add(newChildNode); if (remainingTemplateFragments.Any()) { newChildNode.AddNode(remainingTemplateFragments, requestHandler); } } }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); CaseConditions = new List <CaseConditionNode>(); Statements = new List <IStatementNode>(); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is CaseConditionListNode) { foreach (ParseTreeNode childNode in node.ChildNodes) { if (childNode.AstNode is CaseConditionNode) { CaseConditions.Add(childNode.AstNode as CaseConditionNode); ChildNodes.Add(childNode.AstNode as CaseConditionNode); } } } else if (node.AstNode is StatementListNode) { (node.AstNode as StatementListNode).GetStatements(node, Statements, ChildNodes); } else if (node.AstNode is BreakStatementNode) { BreakStatement = node.AstNode as BreakStatementNode; ChildNodes.Add(node.AstNode as BreakStatementNode); } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); CaseClauses = new List <CaseClauseNode>(); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is ModelPropertyNode) { ModelProperty = node.AstNode as ModelPropertyNode; ChildNodes.Add(node.AstNode as ModelPropertyNode); } else if (node.AstNode is CaseListNode) { foreach (ParseTreeNode childNode in node.ChildNodes) { if (childNode.AstNode is CaseClauseNode) { CaseClauses.Add(childNode.AstNode as CaseClauseNode); ChildNodes.Add(childNode.AstNode as CaseClauseNode); } } } else if (node.AstNode is DefaultClauseNode) { DefaultClause = node.AstNode as DefaultClauseNode; ChildNodes.Add(node.AstNode as DefaultClauseNode); } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }
public int GetNodeValue() { if (ChildNodes.Count == 0) { return(MetaData.Sum()); } else { int r = 0; var nodeArray = ChildNodes.ToArray(); foreach (int n in MetaData) { if (n <= nodeArray.Length) { r += ChildNodes[n - 1].GetNodeValue(); } } return(r); } }
protected override IEnumerable <Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext) { foreach (var kvp in GetFunctionResult()) { Element element = new Element(new ElementHandle( dynamicContext.ElementProviderName, new TreeFunctionElementGeneratorEntityToken(this.Id.ToString(), this.Tree.TreeId, EntityTokenSerializer.Serialize(parentEntityToken), kvp.Key), dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken) )); element.VisualData = new ElementVisualizedData { Label = kvp.Value, ToolTip = kvp.Value, HasChildren = ChildNodes.Count() > 0, Icon = Core.ResourceSystem.ResourceHandle.BuildIconFromDefaultProvider("folder"), OpenedIcon = Core.ResourceSystem.ResourceHandle.BuildIconFromDefaultProvider("folder") }; yield return(element); } }
/// <summary> /// Copies an existing sitemap node and all properties /// </summary> /// <param name="node"></param> /// <returns></returns> public SiteMapNode Copy() { return(new SiteMapNode { Action = Action, Area = Area, Attributes = new Dictionary <string, object>(Attributes), ChildNodes = ChildNodes.Select(n => n.Copy()).ToList(), Clickable = Clickable, Controller = Controller, Description = Description, DynamicNodeProvider = DynamicNodeProvider, HttpMethod = HttpMethod, ImageUrl = ImageUrl, Key = Key, Order = Order, TargetFrame = TargetFrame, Title = Title, Url = Url, UnresolvedUrl = UnresolvedUrl }); }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); Statements = new List <IStatementNode>(); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is ModelContextNode) { ModelContext = node.AstNode as ModelContextNode; ChildNodes.Add(node.AstNode as ModelContextNode); } else if (node.AstNode is CurrentItemNode) { CurrentItem = node.AstNode as CurrentItemNode; ChildNodes.Add(node.AstNode as CurrentItemNode); } // TODO: investigate why empty from clause node is being created else if (node.AstNode is FromClauseNode && node.FindTokenAndGetText() != null) { FromClause = node.AstNode as FromClauseNode; ChildNodes.Add(node.AstNode as FromClauseNode); } else if (node.AstNode is StatementListNode) { (node.AstNode as StatementListNode).GetStatements(node, Statements, ChildNodes); } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }
/// <summary> /// 删除对象 /// </summary> public void DeleteObject() { if (Parent) { Parent.Remove(this); } var tempChildNodes = ChildNodes.ToArray(); foreach (var item in tempChildNodes) { item.DeleteObject(); } if (DeleteNodeHandle != null) { try { DeleteNodeHandle(this); } catch { } } DestroyImmediate(gameObject); }
public void AddItem(MSBuildItem item, MSBuildItem beforeItem) { AssertCanModify(); item.ParentNode = this; int i; if (beforeItem != null && (i = ChildNodes.IndexOf(beforeItem)) != -1) { ChildNodes = ChildNodes.Insert(i, item); } else { ChildNodes = ChildNodes.Add(item); } item.ResetIndent(false); if (ParentProject != null) { ParentProject.NotifyChanged(); } }
internal void CopyFrom(MSBuildPropertyGroup other) { AssertCanModify(); foreach (var node in other.ChildNodes) { var prop = node as MSBuildProperty; if (prop != null) { var cp = prop.Clone(); var currentPropIndex = ChildNodes.FindIndex(p => (p is MSBuildProperty) && ((MSBuildProperty)p).Name == prop.Name); if (currentPropIndex != -1) { var currentProp = (MSBuildProperty)ChildNodes [currentPropIndex]; ChildNodes = ChildNodes.SetItem(currentPropIndex, cp); } else { ChildNodes = ChildNodes.Add(cp); } properties [cp.Name] = cp; cp.ParentNode = PropertiesParent; cp.Owner = this; cp.ResetIndent(false); } else { ChildNodes = ChildNodes.Add(node); } } foreach (var prop in ChildNodes.OfType <MSBuildProperty> ().ToArray()) { if (!other.HasProperty(prop.Name)) { RemoveProperty(prop); } } NotifyChanged(); }
public void QueueNodes(ICollection <DependencyNode <T> > nodes) { Visited = true; foreach (var parentNode in ParentNodes.OrderBy(x => x.OutgoingWeight)) { if (parentNode.Visited) { continue; } parentNode.QueueNodes(nodes); } nodes.Add(this); foreach (var childNode in ChildNodes.OrderBy(x => x.OutgoingWeight)) { if (childNode.Visited) { continue; } childNode.QueueNodes(nodes); } }
public MSBuildItemGroup AddNewItemGroup(MSBuildObject beforeObject) { AssertCanModify(); var group = new MSBuildItemGroup(); MSBuildObject refNode = null; var lastGroup = ItemGroups.LastOrDefault(); if (lastGroup != null) { refNode = lastGroup; } else { var g = PropertyGroups.LastOrDefault(); if (g != null) { refNode = g; } } group.ParentNode = this; if (beforeObject != null) { ChildNodes = ChildNodes.Insert(ChildNodes.IndexOf(beforeObject), group); } else if (refNode != null) { ChildNodes = ChildNodes.Insert(ChildNodes.IndexOf(refNode) + 1, group); } else { ChildNodes = ChildNodes.Add(group); } group.ResetIndent(true); NotifyChanged(); return(group); }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is ModelContextNode) { ModelContext = node.AstNode as ModelContextNode; ChildNodes.Add(node.AstNode as ModelContextNode); } else if (node.AstNode is CurrentItemNode) { CurrentItem = node.AstNode as CurrentItemNode; ChildNodes.Add(node.AstNode as CurrentItemNode); } else if (node.AstNode is SpecCurrentItemNode) { SpecCurrentItem = node.AstNode as SpecCurrentItemNode; ChildNodes.Add(node.AstNode as SpecCurrentItemNode); } else if (node.AstNode is CollectionHelperNode) { CollectionHelper = node.AstNode as CollectionHelperNode; ChildNodes.Add(node.AstNode as CollectionHelperNode); } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }
public MSBuildImport AddNewImport(string name, string condition = null, MSBuildObject beforeObject = null) { AssertCanModify(); var import = new MSBuildImport { Project = name, Condition = condition }; int index = -1; if (beforeObject != null) { index = ChildNodes.IndexOf(beforeObject); } else { index = ChildNodes.FindLastIndex(ob => ob is MSBuildImport); if (index != -1) { index++; } } import.ParentNode = this; if (index != -1) { ChildNodes = ChildNodes.Insert(index, import); } else { ChildNodes = ChildNodes.Add(import); } import.ResetIndent(false); NotifyChanged(); return(import); }
public override void GetChildNodes() { if (!String.IsNullOrEmpty(FullPath)) { ChildNodes.Clear(); string[] directories = Directory.GetDirectories(FullPath); foreach (string directory in directories) { try { DirectoryTreeNode node = new DirectoryTreeNode(Path.GetFileName(directory), directory, TreeView); node.Level = Level + 1; node.TreeView = TreeView; TreeView.CheckedNodeChanged += new EventHandler <TreeNodeEventArgs>(TreeView_OnCheckedNodeChanged); node.HasChildNodes = (Directory.GetDirectories(node.FullPath).Length > 0); ChildNodes.Add(node); } catch (UnauthorizedAccessException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } catch (DriveNotFoundException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } catch (IOException ex) { OMLApplication.DebugLine("[DirectoryTreeNode] " + ex.Message); } } HasChildNodes = (ChildNodes.Count > 0); } base.GetChildNodes(); }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is TemplatePropertyNode) { TemplateProperty = node.AstNode as TemplatePropertyNode; ChildNodes.Add(node.AstNode as TemplatePropertyNode); } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }
public bool SelectMultipleItemsForMove() { int count = ChildNodes.Count(n => n.IsMultiSelected); if (count < 1) { return(false); } SelectedNodes.Clear(); foreach (var node in ChildNodes.Where(n => n.IsMultiSelected)) { node.DisplayMode = NodeDisplayMode.SelectedForCopyOrMove; SelectedNodes.Add(node); } this.IsMultiSelectActive = false; this.PreviousDisplayMode = this.CurrentDisplayMode; this.CurrentDisplayMode = DriveDisplayMode.CopyOrMoveItem; return(true); }
private int CalculateValue() { if (!ChildNodes.Any()) { return(Metadata.Sum()); } else { var value = 0; foreach (var metadataEntry in Metadata) { var index = metadataEntry - 1; if (index >= 0 && metadataEntry <= ChildNodeCount) { value = value + ChildNodes[index].Value; } } return(value); } }
public HoverHeaderTableFactory(string hoverItem, string periodType, string measureText) : base("th") { var companyNode = new SimpleNode("div", hoverItem.ToLower() == "all"?"Selected Market":hoverItem); companyNode.Classes.Add("snapshot-hover-compnay"); ChildNodes.Add(companyNode); var yearAndMeasureNode = new ComplexNode(); yearAndMeasureNode.Classes.Add("snapshot-hover-head"); //var yearNode = new SimpleNode("span", periodType); //yearNode.Classes.Add("snapshot-hover-year"); //yearAndMeasureNode.ChildNodes.Add(yearNode); var measureNode = new SimpleNode("div", ": " + periodType + " - " + measureText); measureNode.Classes.Add("snapshot-hover-measure"); ChildNodes.Add(measureNode); //ChildNodes.Add(yearAndMeasureNode); }
///-------------------------------------------------------------------------------- /// <summary>This method sets up the AST node and its children in the AST.</summary> /// /// <param name="context">The parsing context.</param> /// <param name="treeNode">The corresponding node in the parse tree.</param> ///-------------------------------------------------------------------------------- public override void Init(ParsingContext context, ParseTreeNode treeNode) { try { base.Init(context, treeNode); foreach (ParseTreeNode node in treeNode.ChildNodes) { if (node.AstNode is ModelContextNode) { ModelContext = node.AstNode as ModelContextNode; ChildNodes.Add(node.AstNode as ModelContextNode); } else if (node.AstNode is PopContextNode) { PopContext = node.AstNode as PopContextNode; ChildNodes.Add(node.AstNode as PopContextNode); } else if (node.AstNode is ThisContextNode) { ThisContext = node.AstNode as ThisContextNode; ChildNodes.Add(node.AstNode as ThisContextNode); } else { ModelContextName = node.FindTokenAndGetText(); } } } catch (ApplicationAbortException) { throw; } catch (System.Exception ex) { ThrowASTException(ex, true); } }