Exemplo n.º 1
0
            private static NTreeViewItem AddFolder(NTreeViewItemCollection items, string name)
            {
                // Find the place for the folder item
                int i;

                for (i = items.Count - 1; i >= 0; i--)
                {
                    if (items[i].Items.Count > 0)
                    {
                        // This is not a leaf node, which means we have reached the last folder in the given list of items
                        break;
                    }
                }

                // Insert the folder item
                NTreeViewItem item = CreateItem(NResources.Image__16x16_Folders_png, name);

                items.Insert(i + 1, item);
                return(item);
            }
Exemplo n.º 2
0
        private void OnAddButtonClicked(NEventArgs args)
        {
            NTreeViewItem selItem = m_TreeView.SelectedItem;
            string        text    = selItem == null ? "Item " + m_TreeView.Items.Count.ToString() :
                                    selItem.Tag.ToString();

            if (args.TargetNode == m_AddButton)
            {
                if (selItem == null)
                {
                    // Add the item as a last item in the tree view
                    m_TreeView.Items.Add(CreateTreeViewItem(text));
                }
                else
                {
                    // Add the item as a last item in the selected item
                    text += "." + selItem.Items.Count.ToString();
                    selItem.Items.Add(CreateTreeViewItem(text));
                }
            }
            else if (args.TargetNode == m_InsertBeforeButton)
            {
                // Insert the item before the selected one
                NTreeViewItemCollection items = (NTreeViewItemCollection)selItem.ParentNode;
                text += ".Before";
                items.Insert(selItem.IndexInParent, CreateTreeViewItem(text));
            }
            else if (args.TargetNode == m_InsertAfterButton)
            {
                // Insert the item after the selected one
                NTreeViewItemCollection items = (NTreeViewItemCollection)selItem.ParentNode;
                text += ".After";
                items.Insert(selItem.IndexInParent + 1, CreateTreeViewItem(text));
            }

            if (m_TreeView.Items.Count == 1)
            {
                m_RemoveAllButton.Enabled = true;
            }
        }