public void Add(T t) { CustomNode <T> node = new CustomNode <T>(t); node.NextNode = _CurrentHeader; _CurrentHeader = node; }
public string ParentAny(string path, CustomNode root, string matchpath) { string[] pieces = path.Split(new char[] { '/' }); if (pieces[pieces.Length - 1] == Title) { if (matchpath == "") { matchpath = Title; } else { matchpath = Title + "/" + matchpath; } path = path.Replace(Title, ""); if (path == "") { return(matchpath); } else { return(ParentAny(path, root.Parent, matchpath)); } } return(""); }
public static void RunTests() { //Build a test tree (matches the example) CustomNode root = new CustomNode("Root", null); CustomNode userData = new CustomNode("UserData", root); CustomNode ud_browser = new CustomNode("Browser", userData); CustomNode ud_word = new CustomNode("Word", userData); CustomNode priv = new CustomNode("Private", userData); CustomNode priv_word = new CustomNode("Word", priv); CustomNode windows = new CustomNode("Windows", root); CustomNode programs = new CustomNode("Programs", root); CustomNode notepad = new CustomNode("Notepad", programs); CustomNode prog_word = new CustomNode("Word", programs); CustomNode prog_browser = new CustomNode("Browser", programs); CustomNode custom1 = new CustomNode("Root", root); CustomNode custom2 = new CustomNode("UserData", custom1); CustomNode custom3 = new CustomNode("Word", custom2); CustomNode target = root.Find("Root/UserData/Word"); var v = (GetShortestUniqueQualifier(root, target)); }
public void append(string data) { /*This method walks through the list (from at head) and * continually checks if there is a node next * to the current node in the list * it adds a new node with data if there are no nodes next to the current node * appending data :-)*/ // check if there is a head if (head == null) { // create a head if there is not one head = new CustomNode(data); NodeCount++; return; } // if there is a head -> start walking through the list staring at the head current = head; //Check if there is node next to the current node (taversing the list) while (current.Next != null) { // keep moving through the list one node at a time current = current.Next; } //create a new node if current.next is empty :-) current.Next = new CustomNode(data); NodeCount++; }
public static void GenerateViewsNode(CustomNode parentNode, DatabaseOperation databaseOperation) { DataTable dt = databaseOperation.GetViews(); parentNode.Nodes.Clear(); string previousName = null; foreach (DataRow dr in dt.Rows) { if (dr["name"].ToString() != previousName) { previousName = dr["name"].ToString(); List <DescriptionItem> descriptions = GetDescriptions(dt, dr["name"].ToString()); CustomNode viewNode = new CustomNode(NodeType.View, parentNode, dr["name"].ToString(), descriptions, null); CustomNode viewColumnsNode = new CustomNode(NodeType.ViewColumns, viewNode, "Columns", NodeImage.Folder, 1); CustomNode viewTriggersNode = new CustomNode(NodeType.ViewTriggers, viewNode, "Triggers", NodeImage.Folder, 2); CustomNode viewIndexesNode = new CustomNode(NodeType.ViewIndexes, viewNode, "Indexes", NodeImage.Folder, 3); viewColumnsNode.Nodes.Add(new CustomNode(NodeType.Dummy)); viewTriggersNode.Nodes.Add(new CustomNode(NodeType.Dummy)); viewIndexesNode.Nodes.Add(new CustomNode(NodeType.Dummy)); viewNode.Nodes.Add(viewColumnsNode); viewNode.Nodes.Add(viewTriggersNode); viewNode.Nodes.Add(viewIndexesNode); parentNode.Nodes.Add(viewNode); } } }
public static void GenerateDatabaseNode(CustomNode parentNode, string databaseName, int orderBy) { CustomNode databaseNode = new CustomNode(NodeType.Database, parentNode, databaseName, 0, orderBy); CustomNode tablesNode = new CustomNode(NodeType.Tables, databaseNode, "Tables", NodeImage.Folder, 1); CustomNode viewsNode = new CustomNode(NodeType.Views, databaseNode, "Views", NodeImage.Folder, 2); CustomNode programmabilityNode = new CustomNode(NodeType.Programmability, databaseNode, "Programmability", NodeImage.Folder, 3); CustomNode proceduresNode = new CustomNode(NodeType.StoredProcedures, programmabilityNode, "Stored Procedures", NodeImage.Folder, 1); CustomNode functionsNode = new CustomNode(NodeType.Functions, programmabilityNode, "Functions", NodeImage.Folder, 2); CustomNode tableValuedFunctionsNode = new CustomNode(NodeType.TableValuedFunctions, functionsNode, "Table-valued Functions", NodeImage.Folder, 1); CustomNode scalarValuedFunctionsNode = new CustomNode(NodeType.ScalarValuedFunctions, functionsNode, "Scalar-valued Functions", NodeImage.Folder, 2); tablesNode.Nodes.Add(new CustomNode(NodeType.Dummy)); viewsNode.Nodes.Add(new CustomNode(NodeType.Dummy)); proceduresNode.Nodes.Add(new CustomNode(NodeType.Dummy)); tableValuedFunctionsNode.Nodes.Add(new CustomNode(NodeType.Dummy)); scalarValuedFunctionsNode.Nodes.Add(new CustomNode(NodeType.Dummy)); databaseNode.Nodes.Add(tablesNode); databaseNode.Nodes.Add(viewsNode); functionsNode.Nodes.Add(tableValuedFunctionsNode); functionsNode.Nodes.Add(scalarValuedFunctionsNode); programmabilityNode.Nodes.Add(proceduresNode); programmabilityNode.Nodes.Add(functionsNode); databaseNode.Nodes.Add(programmabilityNode); parentNode.Nodes.Add(databaseNode); }
public static void GenerateScalarValuedFunctionsNode(CustomNode parentNode, DatabaseOperation databaseOperation) { DataTable dt = databaseOperation.GetScalarValuedFunctions(); parentNode.Nodes.Clear(); string previousName = null; foreach (DataRow dr in dt.Rows) { if (dr["name"].ToString() != previousName) { previousName = dr["name"].ToString(); List <DescriptionItem> descriptions = GetDescriptions(dt, dr["name"].ToString()); CustomNode scalarValuedFunctionNode = new CustomNode(NodeType.ScalarValuedFunction, parentNode, dr["name"].ToString(), descriptions, null); CustomNode scalarValuedFunctionParametersNode = new CustomNode(NodeType.ScalarValuedFunctionParameters, scalarValuedFunctionNode, "Parameters", NodeImage.Folder, 1); scalarValuedFunctionParametersNode.Nodes.Add(new CustomNode(NodeType.Dummy)); scalarValuedFunctionNode.Nodes.Add(scalarValuedFunctionParametersNode); parentNode.Nodes.Add(scalarValuedFunctionNode); } } }
public BreadthFirstAlgorithm(int height, int width, GameObject[][] passedArray, bool isFast) : base(height, width, passedArray) { vertices = new CustomNode[height][]; queue = new Queue <CustomNode>(); results = new List <CustomNode>(); isFastExit = isFast; }
public string Any(string path, CustomNode root, string matchpath) { string[] pieces = path.Split(new char[] { '/' }); if (pieces[pieces.Length - 1] == Title) { return(pieces[pieces.Length - 1]); } foreach (var child in root.Children) { var v = child.Any(path, child, matchpath); if (v == "") { // no match continue; } else { if (matchpath == "") { matchpath = v; } else { matchpath = v + "/" + matchpath; } path = path.Replace(v, ""); if (path.EndsWith("/")) { path = path.Remove(path.Length - 1); } if (path == "") { return(matchpath); } else { var vcheck = ParentAny(path, child.Parent, matchpath); if (vcheck == "") { continue; } else { return(vcheck); } } } //if (child.Title == pieces[0]) //{ // matchpath = child.Title + '/' + matchpath; // //string pathnew = path.Substring(path.IndexOf('/')); // return child.Any(path.Remove(0, Title.Length + 1), root, ref i, matchpath); //} } return(""); }
public T GetAndRemove() { T t = _CurrentHeader.Element; CustomNode <T> node = _CurrentHeader.NextNode; _CurrentHeader = node; return(t); }
protected void TilePaint(CustomNode paintNode, Color color) { if (paintNode != startNode && paintNode != endNode) { gridArray[paintNode.x][paintNode.y].GetComponent <Renderer>() .material.color = color; } }
public void Visit(CustomNode node) { if (node != null) { // ask the custom node implementation DoesRequire = node.RequiresSeparator; } }
protected void Rewind(CustomNode pathNode) { results.Add(pathNode); if (pathNode != startNode && pathNode.parent != startNode) { Rewind(pathNode.parent); } }
public void Visit(CustomNode node) { if (node != null) { // whatever people plug in. Hopefully it's valid JSON. OutputString(node.ToCode()); } }
private void TreeView_AfterExpand(object sender, TreeViewEventArgs e) { CustomNode node = (CustomNode)e.Node; CheckDatabase(node); GenerateChildNodes(node); FirePrefetchDdlEvent(node); }
private static void GenerateServerNode(TreeView treeView) { CustomNode serverNode = new CustomNode(NodeType.Server, null, ConfigHandler.ServerName, NodeImage.ServerDatabase, 0); serverNode.Nodes.Add(new CustomNode(NodeType.Dummy)); serverNode.Expand(); treeView.Nodes.Add(serverNode); }
public void CreateCustomNode() { CustomNode cn = new CustomNode(); cn.SetBounds(0, 0, 100, 80); cn.Brush = Color.Black; Canvas.Layer.AddChild(cn); }
public static EditorNode?Load(XElement element) { return(element.Name.ToString().ToLowerInvariant() switch { "eventnode" => EventNode.LoadEventNode(element), "valuenode" => ValueNode.LoadValueNode(element), "customnode" => CustomNode.LoadCustomNode(element), _ => null });
public bool Equals(CustomNode p) { if (p == null) { return(false); } return((m_x == p.m_x) && (m_y == p.m_y)); }
private static bool ShouldGetUsingObjectDefinition(CustomNode node) { if (node.Type == NodeType.TableTrigger || node.Type == NodeType.View || node.Type == NodeType.ViewColumn || node.Type == NodeType.ViewTrigger || node.Type == NodeType.StoredProcedure || node.Type == NodeType.TableValuedFunction || node.Type == NodeType.ScalarValuedFunction || node.Type == NodeType.TableValuedFunctionParameter || node.Type == NodeType.ScalarValuedFunctionParameter || node.Type == NodeType.StoredProcedureParameter) { return(true); } return(false); }
public static string GetCheckWrapper(CustomNode node, string sqlToWrap) { string level1Type = ExtendedPropertiesHelper.GetLevel1Type(node.Type); string level1Name = ExtendedPropertiesHelper.GetLevel1Name(node); string level2Type = ExtendedPropertiesHelper.GetLevel2Type(node.Type); string level2Name = ExtendedPropertiesHelper.GetLevel2Name(node); return(GetCheckWrapper(level1Type, level1Name, level2Type, level2Name, sqlToWrap)); }
public void Add(T value) { if (Head == null) { Head = new CustomNode <T>(value); return; } Head.Append(value); }
public virtual void Visit(CustomNode node) { if (node != null) { foreach (var childNode in node.Children) { childNode.Accept(this); } } }
public void Append(T value) { if (Next == null) { Next = new CustomNode <T>(value); return; } Next.Append(value); }
public CustomNode(NodeType type, CustomNode parentNode, string text, NodeImage image, int orderBy) { Type = type; ParentNode = parentNode; Text = text; Name = text; SelectedImageIndex = Convert.ToInt32(image); ImageIndex = Convert.ToInt32(image); OrderBy = orderBy; }
private static string GetLevel2(CustomNode node) { if (AddLevel2(node.Type)) { return(string.Format(", @level2Type = N'{0}', @level2Name = N'{1}'", GetLevel2Type(node.Type), GetLevel2Name(node).Replace("'", "''"))); } else { return(""); } }
public CustomNode(string title, CustomNode parent) { Title = title; Parent = parent; Children = new List <CustomNode>(); if (Parent != null) { Parent.Children.Add(this); } }
private void ExportNode(CustomNode serverNode, StringBuilder stringBuilder, string extension) { if (extension == "xml") { ExportNodeXml(serverNode, stringBuilder); } else if (extension == "sql") { ExportNodeSql(serverNode, stringBuilder); } }
private void btDrawTreeView_Click(object sender, EventArgs e) { try { if (this.cbModel.SelectedItem != null && this.cbVersion.SelectedItem != null) { this.treeView1.Nodes.Clear(); Cursor.Current = Cursors.WaitCursor; Identifier modelId = this.cbModel.SelectedItem as Identifier; Identifier identifier1 = (this.cbVersion.SelectedItem as CustomVersion).Identifier; OperationResult operationResult = new OperationResult(); List <CustomNode> list = new List <CustomNode>(); foreach (CustomEntity mci in ucManageEntities1.lstEntities.Items) { bool flag = false; foreach (Identifier identifier2 in CustomEntity.GetDBAEntities(modelId, identifier1, mci.ent)) { CustomNode customNode = new CustomNode(mci, identifier2.Name, mci.Name); if (!list.Contains(customNode)) { list.Add(customNode); flag = true; } } if (!flag) { CustomNode customNode = new CustomNode(mci, mci.Name, "root"); if (Enumerable.Count <CustomNode>((IEnumerable <CustomNode>)list, (Func <CustomNode, bool>)(x => x.Ent == mci)) == 0) { list.Add(customNode); } } } TreeNode currentNode = new TreeNode("root"); currentNode.Text = currentNode.Name = "root"; this.BindTree(list, currentNode, Enumerable.First <CustomNode>((IEnumerable <CustomNode>)list).Ent); } else { this.lblError.Text = "You must select a model and a version"; } } catch (Exception ex) { this.lblError.Text = ex.Message; } finally { Cursor.Current = Cursors.Default; } }
public CustomNode(NodeType type, CustomNode parentNode, string text, List <DescriptionItem> descriptions, string parentName) { Type = type; ParentNode = parentNode; Text = text; Name = text; DescriptionChangeable = true; ParentName = parentName; Descriptions = descriptions; SelectedImageIndex = Convert.ToInt32(GetNodeImage(Descriptions)); ImageIndex = Convert.ToInt32(GetNodeImage(Descriptions)); }
public CustomNode<string> AddNode(CustomNode<string> nodeToAdd) { CustomNode<string> result; if (this.Contains(nodeToAdd)) { result = this.treeNodes.FirstOrDefault(n => n.Value == nodeToAdd.Value); } else { this.treeNodes.Add(nodeToAdd); result = nodeToAdd; } return result; }
static void Main() { string stringNumberOfRows = Console.ReadLine().Trim(); int numberOfRows; while (!int.TryParse(stringNumberOfRows, out numberOfRows)) { Console.WriteLine("Invalid input"); } var currentTree = new CustomTree(); for (int i = 1; i < numberOfRows; i++) { string currentLine = Console.ReadLine().Trim(); string currentParent = currentLine.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries)[0]; string currentChild = currentLine.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries)[1]; CustomNode<string> currentParentNode = new CustomNode<string>(currentParent); CustomNode<string> currentChildtNode = new CustomNode<string>(currentChild); var parent = currentTree.AddNode(currentParentNode); var child = currentTree.AddNode(currentChildtNode); parent.AttachChild(child); } var rootNode = currentTree.FindRootNode().Value; Console.WriteLine("The root node is {0}", rootNode); Console.WriteLine(); var allLeafs = currentTree.FindAllLeafs(); foreach (var leaf in allLeafs) { Console.WriteLine("Leaf: {0}", leaf.Value); } Console.WriteLine(); var allMiddle = currentTree.FindAllMiddleNodes(); foreach (var leaf in allMiddle) { Console.WriteLine("Middle node: {0}", leaf.Value); } Console.WriteLine(); }
private static void SolveTasks(StringReader reader, CustomTree<int> tree) { int nodePairsCount; string firstLine = reader.ReadLine(); if (!int.TryParse(firstLine, out nodePairsCount)) { throw new ArgumentException(ValidationConstants.InvalidInput); } for (int i = 0; i < nodePairsCount - 1; i++) { string[] line = reader.ReadLine().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); int parentValue = int.Parse(line[0]); int childValue = int.Parse(line[1]); if (!tree.Contains(parentValue) && !tree.Contains(childValue)) { var theNewNode = new CustomNode<int>(parentValue); theNewNode.AddChild(new CustomNode<int>(childValue)); tree.Add(theNewNode); } else if (!tree.Contains(parentValue) && tree.Contains(childValue)) { var theNode = new CustomNode<int>(parentValue); var theNodeToAdd = tree.Find(childValue); tree.RemoveTreeNode(theNodeToAdd); theNode.AddChild(theNodeToAdd); tree.Add(theNode); } else if (tree.Contains(parentValue) && !tree.Contains(childValue)) { var theNode = tree.Find(parentValue); theNode.AddChild(new CustomNode<int>(childValue)); } else { var theParentNode = tree.Find(parentValue); var theChildNode = tree.Find(childValue); tree.RemoveTreeNode(theChildNode); theParentNode.AddChild(theChildNode); } } }
private void UpdateTreeView() { _model.Nodes.Clear(); TreeViewAdv_Files.BeginUpdate(); foreach (var storageUnit in _treeContainer.TreeRootStorageUnits) { Tuple<int, int> seasonAndEpisode; var file = storageUnit as File; if (file != null) { TryExtractSeasonEpisodeValues(file.OriginalName, out seasonAndEpisode); var fileNode = new CustomNode(file.OriginalName + file.Extension) { Tag = file, SecondText = file.NewName, ThirdText = seasonAndEpisode.Item1.ToString(), ForthText = seasonAndEpisode.Item2.ToString() }; _model.Nodes.Add(fileNode); } var folder = storageUnit as Folder; if (folder == null) { continue; } TryExtractSeasonEpisodeValues(folder.OriginalName, out seasonAndEpisode); var folderNode = new CustomNode(folder.OriginalName) { Tag = folder, SecondText = folder.NewName, ThirdText = seasonAndEpisode.Item1.ToString(), ForthText = seasonAndEpisode.Item2.ToString() }; _model.Nodes.Add(folderNode); UpdateTreeView(folder, folderNode); } TreeViewAdv_Files.EndUpdate(); TreeViewAdv_Files.ExpandAll(); ResizeViewColumns(); }
private static void UpdateTreeView(Folder folder, CustomNode folderNode) { foreach (var child in folder.Children) { Tuple<int, int> seasonAndEpisode; var file = child as File; if (file != null) { TryExtractSeasonEpisodeValues(file.OriginalName, out seasonAndEpisode); var fileNode = new CustomNode(file.OriginalName + file.Extension) { Tag = file, SecondText = file.NewName, ThirdText = seasonAndEpisode.Item1.ToString(), ForthText = seasonAndEpisode.Item2.ToString() }; folderNode.Nodes.Add(fileNode); } var subFolder = child as Folder; if (subFolder == null) { continue; } TryExtractSeasonEpisodeValues(subFolder.OriginalName, out seasonAndEpisode); var subFolderNode = new CustomNode(subFolder.OriginalName) { Tag = subFolder, SecondText = subFolder.NewName, ThirdText = seasonAndEpisode.Item1.ToString(), ForthText = seasonAndEpisode.Item2.ToString() }; folderNode.Nodes.Add(subFolderNode); UpdateTreeView(subFolder, subFolderNode); } }
public virtual void Visit(CustomNode node) { if (node != null) { foreach (var childNode in node.Children) { childNode.Accept(this); } } }
public void Visit(CustomNode node) { // not applicable; terminate }
public void Visit(CustomNode node) { // we're good }
public void Visit(CustomNode node) { if (node != null) { node.Index = NextOrderIndex; } }
public void InitializeComponent() { if (DrawMode == TreeViewDrawMode.OwnerDrawText) { DoubleBuffered = true; this.DrawNode += new DrawTreeNodeEventHandler(OnProjectTree_DrawNode); if (customNodes.Count == 0) { CustomNode customNode = new CustomNode(); customNode.pattern = @"\b([a-z0-9 _]{1,})\b"; customNode.color = new Color[] { Color.DarkSlateGray }; customNodes.Add(customNode); customNode = new CustomNode(); customNode.pattern = @"([a-z0-9]{1,})([.txt]{4})"; customNode.color = new Color[] { Color.Black, Color.Crimson }; customNodes.Add(customNode); } } watcher.EnableRaisingEvents = true; Nodes.Clear(); CreateProjectNodes(); }
public void CreateCustomNode() { CustomNode cn = new CustomNode(); cn.SetBounds(0, 0, 100, 80); cn.Brush = Brushes.Black; Canvas.Layer.AddChild(cn); }
public void Visit(CustomNode node) { if (node != null) { // whatever people plug in. Hopefully it's valid JSON. OutputString(node.ToCode()); } }
public bool Contains(CustomNode<string> nodeToAdd) { var result = this.treeNodes.Any(n => n.Value == nodeToAdd.Value); return result; }