/// <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)); } }
/// <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); }
/// <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)); }
/// <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); } }
/// <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); }
/// <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); } }
/// <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)); } }
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) { }); }
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>(); } } }
/// <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>())); }
public abstract void Insert(ObiNode node, int index);
public void InsertAfter(ObiNode node, ObiNode anchor) { int index = Children.IndexOf(anchor); base.Insert(node, index + 1); }
public void InsertAfterSelf(ObiNode node) { Parent.InsertAfter(node, this); }
// Our own overrides public virtual void AppendChild(ObiNode node) { base.AppendChild(node); }
public Clipboard(ObiNode node, bool deep) { mNode = node; mDeep = deep; }
public override int IndexForNewNode(ObiNode newNode) { return(newNode is SectionNode ? Node.Index + 1 : mIndex); }
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))); }
/// <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>()); }
public void InsertBefore(ObiNode node, ObiNode anchor) { int index = Children.IndexOf(anchor); base.Insert(node, index); }
public void RemoveChild(ObiNode child) { Children.Remove(child); }
public override ObiNode ParentForNewNode(ObiNode newNode) { return(newNode is SectionNode?Node.ParentAs <ObiNode>() : Node); }
/// <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); }
//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; }
public override void Insert(ObiNode node, int index) { throw new Exception("Empty nodes have no children."); }
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; }
/// <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)); }