public static void XmlTreeViewAdd(TreeViewItem afterItem, string tagName, string value) { XmlTreeViewItem treeNode = new XmlTreeViewItem { Header = value, TagName = tagName, IsExpanded = true, }; XmlTreeViewAdd(afterItem, treeNode); }
public static XmlTreeViewItem ClearTreeView(TreeView tv) { tv.Items.Clear(); XmlTreeViewItem treeNode = new XmlTreeViewItem { //Should be Root Header = "Databases", IsExpanded = true }; tv.Items.Add(treeNode); return treeNode; }
public static XmlTreeViewItem GetTreeViewRoot(TreeView tv) { XmlTreeViewItem node = (XmlTreeViewItem)tv.Items[0]; if (node != null) { while (node.Parent != null && node.Parent.GetType() != typeof(TreeView)) { node = (XmlTreeViewItem)node.Parent; } } return(node); }
public static XmlTreeViewItem ClearTreeView(TreeView tv) { tv.Items.Clear(); XmlTreeViewItem treeNode = new XmlTreeViewItem { //Should be Root Header = "Databases", IsExpanded = true }; tv.Items.Add(treeNode); return(treeNode); }
public static void BuildNodes(XmlTreeViewItem treeNode, XElement element) { foreach (XNode child in element.Nodes()) { XElement childElement = child as XElement; XmlTreeViewItem childTreeNode = new XmlTreeViewItem { //Get First attribute where it is equal to value Header = childElement.Attributes().First(s => s.Name == "name").Value, TagName = childElement.Name.LocalName, //Automatically expand elements IsExpanded = true, }; treeNode.Items.Add(childTreeNode); BuildNodes(childTreeNode, childElement); } }
public static XmlTreeViewItem GetXmlTreeViewItem(TreeView tv, string tagName, string name) { XmlTreeViewItem root = GetTreeViewRoot(tv); return(GetXmlTreeViewItemRec(root, tagName, name)); }
private void tvDs_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { _selectedTreeViewItem = ((XmlTreeViewItem)((TreeView)sender).SelectedItem); ContextMenu contextMenu = new ContextMenu(); if (_selectedTreeViewItem == null) return; if (_selectedTreeViewItem.TagName == "table") { _currentInjectionStrategy.SelectedTable = _selectedTreeViewItem.Header.ToString(); _currentInjectionStrategy.SelectedDb = ((XmlTreeViewItem)_selectedTreeViewItem.Parent).Header.ToString(); } else if (_selectedTreeViewItem.TagName == "db") { _currentInjectionStrategy.SelectedTable = string.Empty; _currentInjectionStrategy.SelectedDb = _selectedTreeViewItem.Header.ToString(); } MenuItem menuItem = new MenuItem { Header = "Insert" }; menuItem.Click += OptionClick; contextMenu.Items.Add(new MenuItem().Header = "Copy"); _selectedTreeViewItem.ContextMenu = contextMenu; }