public void FindById() { Application.Init(); var nodes = new Nodes(); var rootTag = Guid.NewGuid(); var rootNode = new TestNode(new Tree(new Window("test")), "root-icon", "root", rootTag, new object()); nodes.AddNode(rootNode); Assert.AreEqual(rootNode, nodes.SelectSingleNode(rootTag)); var childTag = Guid.NewGuid(); var childNode = new TestNode(new Tree(new Window("test")), "child-icon", "child", childTag, new object()); rootNode.AddChild(childNode); Assert.AreEqual(childNode, nodes.SelectSingleNode(childTag)); var grandchildTag = new object(); var grandchildNode = new TestNode(new Tree(new Window("test")), "grandchild-icon", "grandchild", grandchildTag, new object()); childNode.AddChild(grandchildNode); Assert.AreEqual(grandchildNode, nodes.SelectSingleNode(grandchildTag)); }
public GDDocumentBlock AddBlock() { GDDocumentBlock block = new GDDocumentBlock(); Nodes.AddNode(block); return(block); }
public GDLineBreak AddLineBreak() { GDLineBreak lb = new GDLineBreak(); Nodes.AddNode(lb); return(lb); }
void Update() { if (GameController.health > 0) { timeUntilNode -= Time.deltaTime; var portionRemaining = timeUntilNode / timeBetweenNodes; cam.orthographicSize = GetCameraSize(portionRemaining); timerCircle.fillAmount = portionRemaining; } if (timeUntilNode < 0) { controller.CheckEfficiency(); timeUntilNode = timeBetweenNodes; if (GameController.health > 0) { var point = new Vector2(0, 0); var limit = cam.orthographicSize * 0.8f; do { point.x = Random.Range(-limit, limit); point.y = Random.Range(-limit, limit); }while (!CheckNodePosition(point, nodes.NodeList)); nodes.AddNode(point); measure.MeasureOptimalPath(); controller.UpdateMinEfficiency(); } } }
/// <summary> /// Adds points using the mod-2 rule of SFS. This is used to add the boundary /// points of dim-1 geometries (Curves/MultiCurves). According to the SFS, /// an endpoint of a Curve is on the boundary /// if it is in the boundaries of an odd number of Geometries. /// </summary> /// <param name="argIndex"></param> /// <param name="coord"></param> private void InsertBoundaryPoint(int argIndex, Coordinate coord) { Node n = Nodes.AddNode(coord); Label lbl = n.Label; // the new point to insert is on a boundary int boundaryCount = 1; // determine the current location for the point (if any) LocationType loc = LocationType.Null; if (lbl != null) { loc = lbl.GetLocation(argIndex, PositionType.On); } if (loc == LocationType.Boundary) { boundaryCount++; } // determine the boundary status of the point according to the Boundary Determination Rule LocationType newLoc = DetermineBoundary(boundaryCount); if (lbl != null) { lbl.SetLocation(argIndex, newLoc); } }
public GDTable AddTable() { GDTable table = new GDTable(); Nodes.AddNode(table); return(table); }
protected override void LoadNodes(CancellationToken token) { var nodes = new Dictionary <string, BaseBranchNode>(); var branches = Module.GetRefs(true, true) .Where(branch => branch.IsRemote && !branch.IsTag) .Select(branch => branch.Name); var remotes = Module.GetRemotes(allowEmpty: true); foreach (var branchPath in branches) { var remote = branchPath.Split('/').First(); if (!remotes.Contains(remote)) { continue; } var remoteBranchNode = new RemoteBranchNode(this, branchPath); var parent = remoteBranchNode.CreateRootNode(nodes, (tree, parentPath) => CreateRemoteBranchPathNode(tree, parentPath, remote)); if (parent != null) { Nodes.AddNode(parent); } } }
public GDTextRun Append(string text) { GDTextRun textRun = new GDTextRun(); textRun.Text = text; Nodes.AddNode(textRun); return(textRun); }
private Nodes FillBranchTree(IEnumerable <string> branches, CancellationToken token) { #region ex // (input) // a-branch // develop/crazy-branch // develop/features/feat-next // develop/features/feat-next2 // develop/issues/iss444 // develop/wild-branch // issues/iss111 // master // // -> // (output) // 0 a-branch // 0 develop/ // 1 features/ // 2 feat-next // 2 feat-next2 // 1 issues/ // 2 iss444 // 1 wild-branch // 1 wilds/ // 2 card // 0 issues/ // 1 iss111 // 0 master #endregion var nodes = new Nodes(this); var aheadBehindData = _aheadBehindDataProvider?.GetData(); var currentBranch = Module.GetSelectedBranch(); var pathToNode = new Dictionary <string, BaseBranchNode>(); foreach (var branch in branches) { token.ThrowIfCancellationRequested(); var localBranchNode = new LocalBranchNode(this, branch, branch == currentBranch); if (aheadBehindData != null && aheadBehindData.ContainsKey(localBranchNode.FullPath)) { localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay()); } var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath)); if (parent != null) { nodes.AddNode(parent); } } return(nodes); }
void RegenerateNodes() { nodes.ResetNodes(false); for (var x = 0; x < 30;) { var point = new Vector2(Random.Range(-10f, 10f), Random.Range(-10f, 10f)); if (NodeGenerator.CheckNodePosition(point, nodes.NodeList)) { nodes.AddNode(point); x++; } } }
/// <summary> /// /// </summary> /// <param name="argIndex"></param> /// <param name="coord"></param> /// <param name="onLocation"></param> private void InsertPoint(int argIndex, Coordinate coord, LocationType onLocation) { Node n = Nodes.AddNode(coord); Label lbl = n.Label; if (lbl == null) { n.Label = new Label(argIndex, onLocation); } else { lbl.SetLocation(argIndex, onLocation); } }
private void FillBranchTree(IEnumerable <string> branches) { #region ex // (input) // a-branch // develop/crazy-branch // develop/features/feat-next // develop/features/feat-next2 // develop/issues/iss444 // develop/wild-branch // issues/iss111 // master // // -> // (output) // 0 a-branch // 0 develop/ // 1 features/ // 2 feat-next // 2 feat-next2 // 1 issues/ // 2 iss444 // 1 wild-branch // 1 wilds/ // 2 card // 0 issues/ // 1 iss111 // 0 master #endregion ex var nodes = new Dictionary <string, BaseBranchNode>(); var branchFullPaths = new List <string>(); foreach (var branch in branches) { var localBranchNode = new LocalBranchNode(this, branch); var parent = localBranchNode.CreateRootNode(nodes, (tree, parentPath) => new BranchPathNode(tree, parentPath)); if (parent != null) { Nodes.AddNode(parent); } branchFullPaths.Add(localBranchNode.FullPath); } FireBranchAddedEvent(branchFullPaths); }
private void FillBranchTree(IEnumerable <string> branches, CancellationToken token) { #region ex // (input) // a-branch // develop/crazy-branch // develop/features/feat-next // develop/features/feat-next2 // develop/issues/iss444 // develop/wild-branch // issues/iss111 // master // // -> // (output) // 0 a-branch // 0 develop/ // 1 features/ // 2 feat-next // 2 feat-next2 // 1 issues/ // 2 iss444 // 1 wild-branch // 1 wilds/ // 2 card // 0 issues/ // 1 iss111 // 0 master #endregion ex var currentBranch = Module.GetSelectedBranch(); var nodes = new Dictionary <string, BaseBranchNode>(); var branchFullPaths = new List <string>(); foreach (var branch in branches) { token.ThrowIfCancellationRequested(); var localBranchNode = new LocalBranchNode(this, branch, branch == currentBranch); var parent = localBranchNode.CreateRootNode(nodes, (tree, parentPath) => new BranchPathNode(tree, parentPath)); if (parent != null) { Nodes.AddNode(parent); } branchFullPaths.Add(localBranchNode.FullPath); } }
private void FillTagTree(IEnumerable <GitRef> tags) { var nodes = new Dictionary <string, BaseBranchNode>(); foreach (var tag in tags) { var branchNode = new TagNode(this, tag.Name, tag); var parent = branchNode.CreateRootNode(nodes, (tree, parentPath) => new BasePathNode(tree, parentPath)); if (parent != null) { Nodes.AddNode(parent); } } }
protected override async Task LoadNodesAsync(CancellationToken token) { await TaskScheduler.Default; token.ThrowIfCancellationRequested(); var nodes = new Dictionary <string, BaseBranchNode>(); var branches = Module.GetRefs(tags: true, branches: true, noLocks: true) .Where(branch => branch.IsRemote && !branch.IsTag) .OrderBy(branch => branch.Name) .Select(branch => branch.Name); token.ThrowIfCancellationRequested(); var remoteByName = Module.GetRemotes().ToDictionary(r => r.Name); foreach (var branchPath in branches) { token.ThrowIfCancellationRequested(); var remoteName = branchPath.SubstringUntil('/'); if (remoteByName.TryGetValue(remoteName, out var remote)) { var remoteBranchNode = new RemoteBranchNode(this, branchPath); var parent = remoteBranchNode.CreateRootNode( nodes, (tree, parentPath) => CreateRemoteBranchPathNode(tree, parentPath, remote)); if (parent != null) { Nodes.AddNode(parent); } } } return; BaseBranchNode CreateRemoteBranchPathNode(Tree tree, string parentPath, Remote remote) { if (parentPath == remote.Name) { return(new RemoteRepoNode(tree, parentPath, remote)); } return(new BasePathNode(tree, parentPath)); } }
/// <summary>Gets the hierarchical branch tree from the specified list of <paramref name="branches"/>.</summary> public void FillBranchTree(IEnumerable <string> branches) { #region ex // (input) // a-branch // develop/crazy-branch // develop/features/feat-next // develop/features/feat-next2 // develop/issues/iss444 // develop/wild-branch // issues/iss111 // master // // -> // (output) // 0 a-branch // 0 develop/ // 1 features/ // 2 feat-next // 2 feat-next2 // 1 issues/ // 2 iss444 // 1 wild-branch // 1 wilds/ // 2 card // 0 issues/ // 1 iss111 // 0 master #endregion ex Dictionary <string, BaseBranchNode> nodes = new Dictionary <string, BaseBranchNode>(); foreach (string branch in branches) { BranchNode branchNode = new BranchNode(this, branch); BaseBranchNode parent = branchNode.CreateRootNode(nodes, (tree, parentPath) => new BranchPathNode(tree, parentPath)); if (parent != null) { Nodes.AddNode(parent); } } }
private Nodes FillTagTree(IEnumerable <IGitRef> tags, CancellationToken token) { var nodes = new Nodes(this); var pathToNodes = new Dictionary <string, BaseBranchNode>(); foreach (var tag in tags) { token.ThrowIfCancellationRequested(); var branchNode = new TagNode(this, tag.Name, tag); var parent = branchNode.CreateRootNode(pathToNodes, (tree, parentPath) => new BasePathNode(tree, parentPath)); if (parent != null) { nodes.AddNode(parent); } } return(nodes); }
private Nodes FillTagTree(IReadOnlyList <IGitRef> tags, CancellationToken token) { var nodes = new Nodes(this); var pathToNodes = new Dictionary <string, BaseBranchNode>(); foreach (IGitRef tag in tags) { token.ThrowIfCancellationRequested(); bool isVisible = !IsFiltering.Value || (tag.ObjectId is not null && _refsSource.Contains(tag.ObjectId)); var tagNode = new TagNode(this, tag.ObjectId, tag.Name, isVisible); var parent = tagNode.CreateRootNode(pathToNodes, (tree, parentPath) => new BasePathNode(tree, parentPath)); if (parent is not null) { nodes.AddNode(parent); } } return(nodes); }
protected override async Task LoadNodesAsync(CancellationToken token) { await TaskScheduler.Default; token.ThrowIfCancellationRequested(); var nodes = new Dictionary <string, BaseBranchNode>(); var branches = Module.GetRefs() .Where(branch => branch.IsRemote && !branch.IsTag) .OrderBy(r => r.Name) .Select(branch => branch.Name); token.ThrowIfCancellationRequested(); var remotes = Module.GetRemotes(allowEmpty: true); var branchFullPaths = new List <string>(); foreach (var branchPath in branches) { token.ThrowIfCancellationRequested(); var remote = branchPath.Split('/').First(); if (!remotes.Contains(remote)) { continue; } var remoteBranchNode = new RemoteBranchNode(this, branchPath); var parent = remoteBranchNode.CreateRootNode(nodes, (tree, parentPath) => CreateRemoteBranchPathNode(tree, parentPath, remote)); if (parent != null) { Nodes.AddNode(parent); } branchFullPaths.Add(remoteBranchNode.FullPath); } }
private void AddTopAndNodesToTree( ref Nodes nodes, List <SubmoduleNode> submoduleNodes, GitModule threadModule, SubmoduleInfoResult result) { // Create tree of SubmoduleFolderNode for each path directory and add input SubmoduleNodes as leaves. // Example of (SuperPath + LocalPath).ToPosixPath() for all nodes: // // C:/code/gitextensions2/Externals/conemu-inside // C:/code/gitextensions2/Externals/Git.hub // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/conemu-inside // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/Git.hub // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/ICSharpCode.TextEditor // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/Externals/NBug // C:/code/gitextensions2/Externals/ICSharpCode.TextEditor/gitextensions/GitExtensionsDoc // C:/code/gitextensions2/Externals/NBug // C:/code/gitextensions2/GitExtensionsDoc // // What we want to do is first remove the topModule portion, "C:/code/gitextensions2/", and // then build our tree by breaking up each path into parts, separated by '/'. // // Note that when we break up the paths, some parts are just directories, the others are submodule nodes: // // Externals / ICSharpCode.TextEditor / gitextensions / Externals / Git.hub // folder submodule submodule folder submodule // // Input 'nodes' is an array of SubmoduleNodes for all the submodules; now we need to create SubmoduleFolderNodes // and insert everything into a tree. var topModule = threadModule.GetTopModule(); // Build a mapping of top-module-relative path to node var pathToNodes = new Dictionary <string, Node>(); // Add existing SubmoduleNodes foreach (var node in submoduleNodes) { pathToNodes[GetNodeRelativePath(topModule, node)] = node; } // Create and add missing SubmoduleFolderNodes foreach (var node in submoduleNodes) { var parts = GetNodeRelativePath(topModule, node).Split(Delimiters.ForwardSlash); for (int i = 0; i < parts.Length - 1; ++i) { var path = string.Join("/", parts.Take(i + 1)); if (!pathToNodes.ContainsKey(path)) { pathToNodes[path] = new SubmoduleFolderNode(this, parts[i]); } } } // Now build the tree var rootNode = new DummyNode(); var nodesInTree = new HashSet <Node>(); foreach (var node in submoduleNodes) { Node parentNode = rootNode; var parts = GetNodeRelativePath(topModule, node).Split(Delimiters.ForwardSlash); for (int i = 0; i < parts.Length; ++i) { var path = string.Join("/", parts.Take(i + 1)); var nodeToAdd = pathToNodes[path]; // If node is not already in the tree, add it if (!nodesInTree.Contains(nodeToAdd)) { parentNode.Nodes.AddNode(nodeToAdd); nodesInTree.Add(nodeToAdd); } parentNode = nodeToAdd; } } Validates.NotNull(result.TopProject); // Add top-module node, and move children of root to it var topModuleNode = new SubmoduleNode( this, result.TopProject, result.TopProject.Bold, result.TopProject.Bold ? result.CurrentSubmoduleStatus : null, "", result.TopProject.Path); topModuleNode.Nodes.AddNodes(rootNode.Nodes); nodes.AddNode(topModuleNode); }
private async Task <Nodes> LoadNodesAsync(CancellationToken token) { await TaskScheduler.Default; token.ThrowIfCancellationRequested(); var nodes = new Nodes(this); var pathToNodes = new Dictionary <string, BaseBranchNode>(); var branches = Module.GetRefs(tags: true, branches: true, noLocks: true) .Where(branch => branch.IsRemote && !branch.IsTag) .OrderBy(branch => branch.Name) .Select(branch => branch.Name); token.ThrowIfCancellationRequested(); var enabledRemoteRepoNodes = new List <RemoteRepoNode>(); var remoteByName = Module.GetRemotes().ToDictionary(r => r.Name); var gitRemoteManager = new GitRemoteManager(() => Module); // Create nodes for enabled remotes with branches foreach (var branchPath in branches) { token.ThrowIfCancellationRequested(); var remoteName = branchPath.SubstringUntil('/'); if (remoteByName.TryGetValue(remoteName, out var remote)) { var remoteBranchNode = new RemoteBranchNode(this, branchPath); var parent = remoteBranchNode.CreateRootNode( pathToNodes, (tree, parentPath) => CreateRemoteBranchPathNode(tree, parentPath, remote)); if (parent != null) { enabledRemoteRepoNodes.Add((RemoteRepoNode)parent); } } } // Create nodes for enabled remotes without branches var enabledRemotesNoBranches = gitRemoteManager.GetEnabledRemoteNamesWithoutBranches(); foreach (var remoteName in enabledRemotesNoBranches) { if (remoteByName.TryGetValue(remoteName, out var remote)) { var node = new RemoteRepoNode(this, remoteName, gitRemoteManager, remote, true); enabledRemoteRepoNodes.Add(node); } } // Add enabled remote nodes in order enabledRemoteRepoNodes .OrderBy(node => node.FullPath) .ForEach(node => nodes.AddNode(node)); // Add disabled remotes, if any var disabledRemotes = gitRemoteManager.GetDisabledRemotes(); if (disabledRemotes.Count > 0) { var disabledRemoteRepoNodes = new List <RemoteRepoNode>(); foreach (var remote in disabledRemotes.OrderBy(remote => remote.Name)) { var node = new RemoteRepoNode(this, remote.Name, gitRemoteManager, remote, false); disabledRemoteRepoNodes.Add(node); } var disabledFolderNode = new RemoteRepoFolderNode(this, _inactiveRemoteNodeLabel.Text); disabledRemoteRepoNodes .OrderBy(node => node.FullPath) .ForEach(node => disabledFolderNode.Nodes.AddNode(node)); nodes.AddNode(disabledFolderNode); } return(nodes); BaseBranchNode CreateRemoteBranchPathNode(Tree tree, string parentPath, Remote remote) { if (parentPath == remote.Name) { return(new RemoteRepoNode(tree, parentPath, gitRemoteManager, remote, true)); } return(new BasePathNode(tree, parentPath)); } }
private async Task <Nodes> FillBranchTreeAsync(IReadOnlyList <IGitRef> branches, CancellationToken token) { var nodes = new Nodes(this); var pathToNodes = new Dictionary <string, BaseBranchNode>(); var enabledRemoteRepoNodes = new List <RemoteRepoNode>(); var remoteByName = (await Module.GetRemotesAsync().ConfigureAwaitRunInline()).ToDictionary(r => r.Name); var remotesManager = new ConfigFileRemoteSettingsManager(() => Module); // Create nodes for enabled remotes with branches foreach (IGitRef branch in branches) { token.ThrowIfCancellationRequested(); Validates.NotNull(branch.ObjectId); bool isVisible = !IsFiltering.Value || _refsSource.Contains(branch.ObjectId); var remoteName = branch.Name.SubstringUntil('/'); if (remoteByName.TryGetValue(remoteName, out Remote remote)) { var remoteBranchNode = new RemoteBranchNode(this, branch.ObjectId, branch.Name, isVisible); var parent = remoteBranchNode.CreateRootNode( pathToNodes, (tree, parentPath) => CreateRemoteBranchPathNode(tree, parentPath, remote)); if (parent is not null) { enabledRemoteRepoNodes.Add((RemoteRepoNode)parent); } } } // Create nodes for enabled remotes without branches var enabledRemotesNoBranches = remotesManager.GetEnabledRemoteNamesWithoutBranches(); foreach (var remoteName in enabledRemotesNoBranches) { if (remoteByName.TryGetValue(remoteName, out var remote)) { var node = new RemoteRepoNode(this, remoteName, remotesManager, remote, true); enabledRemoteRepoNodes.Add(node); } } // Add enabled remote nodes in order enabledRemoteRepoNodes .OrderBy(node => node.FullPath) .ForEach(node => nodes.AddNode(node)); // Add disabled remotes, if any var disabledRemotes = remotesManager.GetDisabledRemotes(); if (disabledRemotes.Count > 0) { var disabledRemoteRepoNodes = new List <RemoteRepoNode>(); foreach (var remote in disabledRemotes.OrderBy(remote => remote.Name)) { var node = new RemoteRepoNode(this, remote.Name, remotesManager, remote, false); disabledRemoteRepoNodes.Add(node); } var disabledFolderNode = new RemoteRepoFolderNode(this, Strings.Inactive); disabledRemoteRepoNodes .OrderBy(node => node.FullPath) .ForEach(node => disabledFolderNode.Nodes.AddNode(node)); nodes.AddNode(disabledFolderNode); } return(nodes); BaseBranchNode CreateRemoteBranchPathNode(Tree tree, string parentPath, Remote remote) { if (parentPath == remote.Name) { return(new RemoteRepoNode(tree, parentPath, remotesManager, remote, true)); } return(new BasePathNode(tree, parentPath)); } }
public void AddRemote(string remoteName) { Nodes.AddNode(new RemoteRepoNode(this, remoteName)); Nodes.FillTreeViewNode(this.TreeViewNode); }
public GDDocumentBlock AddBlock(GDDocumentBlock block) { Nodes.AddNode(block); return(block); }