示例#1
0
 private void SetTreeViewItemStyle( ExtendedTreeViewItem item )
 {
     //string resourceKey = item.Entry.IsIncluded ? "TreeViewItemNormal" : "TreeViewItemExcluded";
     //item.Style = (Style)this.Resources[resourceKey];
     item.Style = (Style)this.FindResource( "TreeViewItemNormal" );
 }
示例#2
0
 private void SetItemSelection( ExtendedTreeViewItem item )
 {
     // What we need to do here is figure out the parent of the selected item,
     // and the position in the parent's collection of entries.  This will be
     // very helpful information when we go to insert a new node.
     IEntry entry = item.Entry;
     this.view.SelectedItem = item;
     this.view.SelectedItemParent = item.ParentCollection;
     this.view.SelectedContent = entry as Content;
     this.view.SelectedEntryParent = entry.Parent;
     this.view.SelectedEntryIndex = this.GetEntryIndex( entry );
 }
示例#3
0
 private ExtendedTreeViewItem CreateTreeViewItem( IEntry entry, ItemCollection parentCollection )
 {
     ExtendedTreeViewItem item = new ExtendedTreeViewItem();
     item.Header = entry;
     item.ContextMenu = this.contextMenu;
     item.Entry = entry;
     item.ParentCollection = parentCollection;
     item.AllowDrop = true;
     item.MouseMove += new MouseEventHandler( item_MouseMove );
     item.Drop += new DragEventHandler( item_Drop );
     this.SetTreeViewItemStyle( item );
     return item;
 }
示例#4
0
        private void ReplicateSubItems( ExtendedTreeViewItem sourceItem, ExtendedTreeViewItem newItem )
        {
            List<ExtendedTreeViewItem> subItems = new List<ExtendedTreeViewItem>();

            foreach( ExtendedTreeViewItem subItem in sourceItem.Items )
                subItems.Add( subItem );

            foreach( ExtendedTreeViewItem subItem in subItems )
            {
                sourceItem.Items.Remove( subItem );
                newItem.Items.Add( subItem );
            }
        }
示例#5
0
        /// <summary>
        /// Add a node in one of three places, based on the user's selection:
        /// 1. If a folder is selected, the new node is added as a child
        /// 2. If a section is select, the new node is added after the selection
        /// 3. If nothing is selected, the new node is added at the end
        /// </summary>
        /// <param name="newContent"></param>
        /// <param name="newItem"></param>
        private void AddContent( Content newContent, ExtendedTreeViewItem newItem )
        {
            if( this.view.HasSelectedContent && this.view.SelectedContent.IsFolder )
            {
                // Add a new node under the selected folder
                this.view.SelectedContent.Children.Add( newContent );
                this.view.SelectedItem.Items.Add( newItem );
            }
            else if( this.view.HasSelectedContent && !this.view.SelectedContent.IsFolder )
            {
                // Add a new node after the selected entry
                this.view.SelectedEntryParent.Children.Insert( this.view.SelectedEntryIndex + 1, newContent );
                this.view.SelectedItemParent.Insert( this.view.SelectedEntryIndex + 1, newItem );
            }
            else
            {
                // Add a new node at the end of the collection
                this.view.SelectedEntryParent.Children.Add( newContent );
                this.view.SelectedItemParent.Add( newItem );
            }

            // Update parent folder's modified date, if this is a child section.
            if( newContent.Parent is Content )
            {
                ((Content)newContent.Parent).LastModified = DateTime.Now;
                // Force parent node to redraw word count
                ((Content)newContent.Parent).RefreshWordCount();
            }
        }