public SyntaxVisualizerForm(IVisualizerObjectProvider provider) { if (provider == null) { throw new ArgumentNullException("provider"); } InitializeComponent(); Provider = provider; var data = (InitalizeData)provider.GetObject(); Root = data.Root; Target = data.Target; }
private SyntaxVisualizerTree MakeTree(dynamic data) { if(data == null) { return null; } if(TreeDictionary.ContainsKey(data)) { return TreeDictionary[data]; } var parent = MakeTree(data.Parent); var id = NextId++; var ret = new SyntaxVisualizerTree(id, data.ToString(), parent); IdList.Add(data); TreeDictionary.Add(data, ret); return ret; }
private void AppendTrees(TreeNode node, SyntaxVisualizerTree data) { var nodes = node.Nodes; if(nodes.Count > 0) { return; } data.TransferValues(Provider); foreach (var v in data.Child) { AppendTree(nodes, v); } }
private TreeNode AppendTree(TreeNodeCollection nodes, SyntaxVisualizerTree data) { var node = nodes.Add(data.ToString()); node.Tag = data; return node; }
private void ShowValueList(SyntaxVisualizerTree data) { if (data == null) { valueList.Items.Clear(); return; } valueList.BeginUpdate(); valueList.Items.Clear(); data.TransferValues(Provider); foreach(var v in data.PropertyValues) { AddValue(v.Key, v.Value); } valueList.EndUpdate(); }
private void SelectElement(SyntaxVisualizerTree data) { var node = GetTreeNode(data); if(node == null) { MessageBox.Show(this, "指定されたElementはツリー内にありませんでした。", "探索結果"); return; } node.EnsureVisible(); syntaxTree.SelectedNode = node; }
private TreeNode GetTreeNode(SyntaxVisualizerTree data) { TreeNodeCollection nodes; if (data == null) { return null; } else if (data.Equals(Root)) { nodes = syntaxTree.Nodes; } else { var node = GetTreeNode(data.Parent); if(node == null) { return null; } AppendTrees(node, data.Parent); node.Expand(); nodes = node.Nodes; } foreach(TreeNode node in nodes) { if(node.Tag.Equals(data)) { return node; } } return null; }