Esempio n. 1
0
 //-------------------------------------------------
 private void _Notify(GenericNode <T> .NodeNotification Notification_in)
 {
     // Ignore pending notifications.
     if ((Notification_in.Status == GenericNode <T> .NodeNotification.NotificationStatus.Pending))
     {
         return;
     }
     // Process notification.
     if ((Notification_in is GenericNode <T> .NodeUpdateNotification))
     {
         GenericNode <S> node = this.FindDescNode(Notification_in.Node.Key);
         if (!this._Silent)
         {
             // Propogate the update notification.
             node.NotifyUpdate(GenericNode <S> .NodeNotification.NotificationStatus.Completed);
         }
         this.OnNodeUpdate(node);
     }
     else if ((Notification_in is GenericNode <T> .NodeAddChildNotification))
     {
         // Synchronize and add the new children.
         GenericNode <T> .NodeAddChildNotification notification = (GenericNode <T> .NodeAddChildNotification)Notification_in;
         GenericNode <S> parentnode = null;
         if (this.Key == notification.Node.Key)
         {
             parentnode = this;
         }
         else
         {
             parentnode = this.FindDescNode(notification.Node.Key);
         }
         GenericNode <S> childnode = new GenericNode <S>(notification.Node.Key, default(S), null);
         childnode.Key = notification.ChildNode.Key;
         this._NodeConverter.Convert(notification.ChildNode, childnode);
         GenericConvertingVisitor <T, S> visitor = new GenericConvertingVisitor <T, S>(notification.ChildNode, this._NodeConverter);
         notification.ChildNode.VisitDecendentsDepthFirst(visitor);
         parentnode.AddChild(childnode, notification.ChildIndex, this._Silent);
         this.OnNodeAddChild(parentnode, childnode);
     }
     else if ((Notification_in is GenericNode <T> .NodeRemoveChildNotification))
     {
         // Remove the children.
         GenericNode <T> .NodeRemoveChildNotification notification = (GenericNode <T> .NodeRemoveChildNotification)Notification_in;
         GenericNode <S> parentnode = this.FindDescNode(notification.Node.Key);
         GenericNode <S> childnode  = null;
         childnode = parentnode.RemoveChild(notification.ChildIndex, this._Silent);
         this.OnRemoveChild(parentnode, childnode);
     }
     else if ((Notification_in is GenericNode <T> .NodeClearChildrenNotification))
     {
         // Clear the children.
         GenericNode <T> .NodeClearChildrenNotification notification = (GenericNode <T> .NodeClearChildrenNotification)Notification_in;
         GenericNode <S> parentnode = this.FindDescNode(notification.Node.Key);
         parentnode.ClearChildren(this._Silent);
         this.OnClearChildren(parentnode);
     }
     return;
 }
        public GenericNode ConvertToGenericNode(TextTree tree, int nodeIndex)
        {
            var node = new GenericNode(TextTree.LabelMapping[tree.vLabel[nodeIndex]]);

            int childIndex = tree.firstChild[nodeIndex];

            while (childIndex != -1)
            {
                node.AddChild(ConvertToGenericNode(tree, childIndex));
                childIndex = tree.nextSibling[childIndex];
            }
            return(node);
        }