public async void GoToTree() { IsComlete.Invoke(this, false); await Task.Run(() => { foreach (var node in abstractNodes) { if (ReqursionIsStoped) { break; } node.SelectNode(abstractNodes.Where(x => x == node).Count(), IsBinary); TreeChannge.Invoke(this, tree.GetTreeAsUnorderedLists()); Step?.Invoke(this, node.Code); Thread.Sleep(500); abstractNodes = abstractNodes.Skip(1).ToList(); } }); ReqursionIsStoped = false; IsComlete.Invoke(this, true); }
public async void Custom(AbstractNode node, string command) { var result = Regex.Split(command, @"\W|_").Where(x => x.Length > 0).ToArray(); var targetNode = await node.GetByName(node, result.Last()); for (var i = result.Count() - 1; i != -1; i--) { if (result[i] == "car") { if (targetNode?.Left != null) { targetNode = targetNode?.Left; Step?.Invoke(this, targetNode.Code); } else { targetNode = targetNode?.Right; Step?.Invoke(this, targetNode.Code); } } if (result[i] == "cdr") { if (targetNode?.Right != null) { targetNode = targetNode?.Right; Step?.Invoke(this, targetNode.Code); } else { targetNode = targetNode?.Left; Step?.Invoke(this, targetNode.Code); } } targetNode?.SelectNode(1, IsBinary); TreeChannge.Invoke(this, tree.GetTreeAsUnorderedLists()); Thread.Sleep(500); } }
private static void OnTreeChange(object sender, string arg) { TreeChannge.Invoke(sender, arg); }