Пример #1
0
 /// <summary>
 /// Signal that the used status of a node has changed.
 /// </summary>
 public void SignalUsedStatusChanged(ObiNode node)
 {
     if (UsedStatusChanged != null)
     {
         UsedStatusChanged(this, new NodeEventArgs <ObiNode>(node));
     }
 }
Пример #2
0
        /// <summary>
        /// Return the correct namespace URI for all Obi nodes.
        /// </summary>
        //public override string XukNamespaceUri { get { return DataModelFactory.NS;

        /// <summary>
        /// Copy the used flag as well as properties.
        /// </summary>
        protected override TreeNode CopyProtected(bool deep, bool inclProperties)
        {
            ObiNode copy = (ObiNode)base.CopyProtected(deep, inclProperties);

            copy.mUsed = mUsed;
            return(copy);
        }
Пример #3
0
 /// <summary>
 /// Find the page number following the one for this node. If the node doesn't have a number,
 /// find the first preceding node that has one.
 /// </summary>
 public PageNumber PageNumberFollowing(ObiNode node)
 {
     while (node != null && !(node is EmptyNode && ((EmptyNode)node).Role_ == EmptyNode.Role.Page))
     {
         node = node.PrecedingNode;
     }
     return(node != null ? ((EmptyNode)node).PageNumber.NextPageNumber() : new PageNumber(1));
 }
Пример #4
0
 /// <summary>
 /// Insert a node at the given index.
 /// The index is interpreted relatively to the position of the other phrases or sections.
 /// If the index is negative, count backward from the end (i.e. -1 inserts in the last position)
 /// </summary>
 public override void Insert(ObiNode node, int index)
 {
     index = node is EmptyNode ? index < 0 ? FirstSectionIndex + index : index :
             index < 0 ? Children.Count + index : index + FirstSectionIndex;
     ((TreeNode)this).Insert(node, index);
     if (node is PhraseNode && ((PhraseNode)node).Role_ == EmptyNode.Role.Heading)
     {
         DidSetHeading((PhraseNode)node);
     }
 }
Пример #5
0
 /// <summary>
 /// Allow only phrase nodes to be inserted.
 /// If the index is negative, count backward from the end (-1 is last.)
 /// </summary>
 public override void Insert(ObiNode node, int index)
 {
     if (!(node is PhraseNode))
     {
         throw new Exception("Only phrase nodes can be added as children of a phrase node.");
     }
     if (index < 0)
     {
         index += Children.Count;
     }
     ((TreeNode)this).Insert(node, index);
 }
Пример #6
0
        /// <summary>
        /// Following node in document order: section, then its phrase children, then its section children,
        /// then its siblings, etc.
        /// </summary>
        public virtual ObiNode FollowingNodeAfter(int index_after)
        {
            ObiNode parent = ParentAs <ObiNode>();

            if (parent != null)
            {
                int index_self = parent.Children.IndexOf(this);
                return(Children.Count > index_after + 1 ? (ObiNode)Children.Get(index_after + 1) :
                       index_self < Parent.Children.Count - 1 ? (ObiNode)Parent.Children.Get(index_self + 1) :
                       parent.FollowingNodeAfter(index_self));
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
 /// <summary>
 /// Get the page number for this node. If the node already has a page number, return it.
 /// If it has no page number, find the nearest preceding block with a page number and add one.
 /// </summary>
 public PageNumber PageNumberFor(ObiNode node)
 {
     if (node is EmptyNode && ((EmptyNode)node).Role_ == EmptyNode.Role.Page)
     {
         return(((EmptyNode)node).PageNumber);
     }
     else
     {
         ObiNode n = node.PrecedingNode;
         while (n != null && !(n is EmptyNode && ((EmptyNode)n).Role_ == EmptyNode.Role.Page))
         {
             n = n.PrecedingNode;
         }
         return(n != null ? ((EmptyNode)n).PageNumber.NextPageNumber() : new PageNumber(1));
     }
 }
Пример #8
0
 public void LocateBookMarkAndAssociatedNode()
 {
     AcceptDepthFirst(delegate(urakawa.core.TreeNode n)
     {
         if (n.IsMarked)
         {
             m_Bookmarked = (ObiNode)n;
         }
         // work around to load associate node because the sdk do not have event to indicate suk-in complete
         if (n is EmptyNode && ((EmptyNode)n).Role_ == EmptyNode.Role.Anchor)
         {
             EmptyNode e = ((EmptyNode)n).AssociatedNode;
         }
         return(true);
     }, delegate(urakawa.core.TreeNode n) { });
 }
Пример #9
0
 private void UpdateAssociatedNodeLocationString()
 {
     if (AssociatedNode != null && AssociatedNode.IsRooted)       //@AssociateNode
     {
         ObiNode iterationNode = AssociatedNode;
         m_AssociatedNodeLocation = "";
         while (iterationNode != this.Root)
         {
             if (AssociatedNode != iterationNode)
             {
                 m_AssociatedNodeLocation += "_";
             }
             m_AssociatedNodeLocation += iterationNode.Parent.Children.IndexOf(iterationNode).ToString();
             iterationNode             = iterationNode.ParentAs <ObiNode>();
         }
     }
 }
Пример #10
0
 /// <summary>
 /// Find the parent node for a new node to be added at the current selection.
 /// The new node can either be a SectionNode or an EmtpyNode.
 /// The rule is to add inside containers and after cursor/phrase block.
 /// </summary>
 public virtual ObiNode ParentForNewNode(ObiNode newNode)
 {
     return(newNode is SectionNode ?
            (Node is SectionNode ? Node.ParentAs <ObiNode>() : Node.AncestorAs <SectionNode>()) :
            (Node is SectionNode ? Node : Node.ParentAs <ObiNode>()));
 }
Пример #11
0
 public abstract void Insert(ObiNode node, int index);
Пример #12
0
        public void InsertAfter(ObiNode node, ObiNode anchor)
        {
            int index = Children.IndexOf(anchor);

            base.Insert(node, index + 1);
        }
Пример #13
0
 public void InsertAfterSelf(ObiNode node)
 {
     Parent.InsertAfter(node, this);
 }
Пример #14
0
        // Our own overrides

        public virtual void AppendChild(ObiNode node)
        {
            base.AppendChild(node);
        }
Пример #15
0
 public Clipboard(ObiNode node, bool deep)
 {
     mNode = node;
     mDeep = deep;
 }
Пример #16
0
 public override int IndexForNewNode(ObiNode newNode)
 {
     return(newNode is SectionNode ? Node.Index + 1 : mIndex);
 }
Пример #17
0
 public virtual int IndexForNewNode(ObiNode newNode)
 {
     return(newNode is SectionNode ?
            (Node is SectionNode ? (Node.Index + 1) : Node.AncestorAs <SectionNode>().SectionChildCount) :
            (Node is SectionNode ? Node.PhraseChildCount : (Node.Index + 1)));
 }
Пример #18
0
        /// <summary>
        /// Get the nearest ancestor of the given type. This is useful to get the section ancestor of a phrase
        /// regardless of its nesting level.
        /// </summary>
        public T AncestorAs <T>() where T : ObiNode
        {
            ObiNode parent = Parent as ObiNode;

            return(parent == null || parent is T ? parent as T : parent.AncestorAs <T>());
        }
Пример #19
0
        public void InsertBefore(ObiNode node, ObiNode anchor)
        {
            int index = Children.IndexOf(anchor);

            base.Insert(node, index);
        }
Пример #20
0
 public void RemoveChild(ObiNode child)
 {
     Children.Remove(child);
 }
Пример #21
0
 public override ObiNode ParentForNewNode(ObiNode newNode)
 {
     return(newNode is SectionNode?Node.ParentAs <ObiNode>() : Node);
 }
Пример #22
0
        /// <summary>
        /// Append a child node (of any kind) at the right position.
        /// </summary>
        public override void AppendChild(ObiNode node)
        {
            int index = node is EmptyNode ? FirstSectionIndex : Children.Count;

            ((TreeNode)this).Insert(node, index);
        }
Пример #23
0
 //public MetadataSelection(RootNode node, ProjectView.MetadataView control, ProjectView.MetadataItemSelection item)
 public MetadataSelection(ObiNode node, ProjectView.MetadataView control, ProjectView.MetadataItemSelection item) //sdk2
     : base(node, control)
 {
     mItem = item;
 }
Пример #24
0
 public override void Insert(ObiNode node, int index)
 {
     throw new Exception("Empty nodes have no children.");
 }
Пример #25
0
        public IControlWithSelection Control;  // control in which it is selected

        /// <summary>
        /// Create a new selection object.
        /// </summary>
        public NodeSelection(ObiNode node, IControlWithSelection control)
        {
            Node    = node;
            Control = control;
        }
Пример #26
0
        /// <summary>
        /// Get a command to renumber this node and all following nodes from this number.
        /// </summary>
        public virtual CompositeCommand RenumberCommand(ProjectView.ProjectView view, PageNumber from)
        {
            ObiNode n = FollowingNode;

            return(n == null ? null : n.RenumberCommand(view, from));
        }