상속: System.Windows.Controls.TreeViewItem
예제 #1
0
        public static void XmlTreeViewAdd(TreeViewItem afterItem, string tagName, string value)
        {
            XmlTreeViewItem treeNode = new XmlTreeViewItem
            {
                Header     = value,
                TagName    = tagName,
                IsExpanded = true,
            };

            XmlTreeViewAdd(afterItem, treeNode);
        }
예제 #2
0
        public static void XmlTreeViewAdd(TreeViewItem afterItem, string tagName, string value)
        {
            XmlTreeViewItem treeNode = new XmlTreeViewItem
            {
                Header = value,
                TagName = tagName,
                IsExpanded = true,
            };

            XmlTreeViewAdd(afterItem, treeNode);
        }
예제 #3
0
        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;
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
 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);
     }
 }
예제 #8
0
        public static XmlTreeViewItem GetXmlTreeViewItem(TreeView tv, string tagName, string name)
        {
            XmlTreeViewItem root = GetTreeViewRoot(tv);

            return(GetXmlTreeViewItemRec(root, tagName, name));
        }
예제 #9
0
        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;
        }