Beispiel #1
0
        private void UpdateItemThread(IResource resource, ConversationNode node)
        {
            ConversationNode newParentNode = FindParentInList(resource, false);

            if (newParentNode != null)
            {
                if (node.Parent != null)
                {
                    node.Parent.RemoveChild(node);
                }
                newParentNode.AddChild(node);
                if (newParentNode.LvNode == null)
                {
                    // the new parent belongs to a thread which wasn't expanded
                    _listView.Nodes.Remove(resource);
                    node.LvNode = null;
                }
                else
                {
                    CollapseState oldState = newParentNode.LvNode.CollapseState;
                    node.LvNode.SetParent(newParentNode.LvNode);
                    if (oldState == CollapseState.NoChildren)
                    {
                        newParentNode.LvNode.Expanded = false;
                    }
                }
            }
            else
            {
                node.LvNode.SetParent(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Finds or adds a conversation node for the specified resource.
        /// </summary>
        /// <param name="res">The resource to find the node for.</param>
        /// <returns>The conversation node instance.</returns>
        private ConversationNode GetConversationNode(IResource res)
        {
            lock ( _conversationNodeMap )
            {
                ConversationNode node = (ConversationNode)_conversationNodeMap [res.Id];
                if (node != null)
                {
                    return(node);
                }

                node = new ConversationNode(res);

                IResource parent = _threadingHandler.GetThreadParent(res);
                if (parent != null)
                {
                    ConversationNode parentNode = GetConversationNode(parent);
                    parentNode.AddChild(node);
                }
                else
                {
                    _conversationRoots.Add(node);
                }

                _conversationNodeMap [res.Id] = node;
                return(node);
            }
        }
Beispiel #3
0
        protected override void HandleResourceAdded(object sender, ResourceIndexEventArgs e)
        {
            if (_disposed)
            {
                return;
            }

            lock ( _resourceList )
            {
                ConversationNode newNode = GetConversationNode(e.Resource);
                newNode.InList = true;

                foreach (IResource child in _threadingHandler.GetThreadChildren(e.Resource))
                {
                    ConversationNode childNode = FindConversationNode(child.Id);
                    if (childNode != null && !newNode.HasChild(childNode))
                    {
                        newNode.AddChild(childNode);
                    }
                }

                if (_threadingHandler.GetThreadParent(e.Resource) == null)
                {
                    OnThreadRootAdded(e.Resource, newNode);
                }
                else
                {
                    // if the parent is not in list, the node should be added as a root (#6376)
                    if (!OnThreadChildAdded(e.Resource, newNode))
                    {
                        OnThreadRootAdded(e.Resource, newNode);
                    }
                }
            }


            OnResourceCountChanged();
        }