Beispiel #1
0
 public void ListOfAnchorNodes_Remove(EmptyNode node)
 {
     if (m_ListOfAnchorNodes.Contains(node))
     {
         m_ListOfAnchorNodes.Remove(node);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Set the kind or custom class of the node.
 /// </summary>
 public void SetRole(Role role, string customRole)
 {
     if (mRole != role || mCustomRole != customRole)
     {
         ChangedRoleEventArgs args = new ChangedRoleEventArgs(this, mRole, mCustomRole);
         if (mRole == EmptyNode.Role.Heading && this.IsRooted)
         {
             AncestorAs <SectionNode> ().UnsetHeading(this as PhraseNode);                                                     //@singleSection: allow clearing of heading role without a parent
         }
         if (mRole == Role.Anchor && mRole != Role.Anchor)
         {
             m_AssociatedNode = null;
         }
         mRole       = role;
         mCustomRole = customRole;
         if (role != Role.Page)
         {
             mPageNumber = null;
         }
         if (role != Role.Custom)
         {
             mCustomRole = null;
         }
         if (role == Role.Heading && !AncestorAs <SectionNode>().DidSetHeading(this))
         {
             mRole       = args.PreviousRole;
             mCustomRole = args.PreviousCustomRole;
             return;
         }
         if (ChangedRole != null)
         {
             ChangedRole(this, args);
         }
     }
 }
Beispiel #3
0
 public void ListOfAnchorNodes_Add(EmptyNode node)
 {
     if (!m_ListOfAnchorNodes.Contains(node))
     {
         m_ListOfAnchorNodes.Add(node);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Copy the node.
        /// </summary>
        protected override TreeNode CopyProtected(bool deep, bool inclProperties)
        {
            EmptyNode copy = (EmptyNode)base.CopyProtected(deep, inclProperties);

            copy.CopyAttributes(this);
            return(copy);
        }
Beispiel #5
0
        // to do: call this function in getter of AssociatedNode property
        public void AssignAssociatedNodeByParsingLocationString(int firstDecemdentOffset)
        {
            if (m_AssociatedNode == null && !string.IsNullOrEmpty(m_AssociatedNodeLocation))
            {
                string[] locationArray = m_AssociatedNodeLocation.Split('_');
                if (locationArray.Length > 0)
                {//1
                    TreeNode iterationNode = this.Root;
                    for (int i = locationArray.Length - 1; i >= 0; i--)
                    {//2
                        int childIndex = -1;
                        int.TryParse(locationArray[i], out childIndex);
                        if (childIndex > -1 && i == locationArray.Length - 1)
                        {
                            childIndex = childIndex + firstDecemdentOffset;
                        }

                        iterationNode = (childIndex >= 0 && childIndex < iterationNode.Children.Count) ? iterationNode.Children.Get(childIndex) : null;
                        if (iterationNode == null)
                        {
                            break;
                        }
                    } //-2
                    m_AssociatedNode = iterationNode != null ? (EmptyNode)iterationNode : null;
                }     //-1
            }
        }
Beispiel #6
0
 /// <summary>
 /// Unset the heading node, if it was indeed this one.
 /// </summary>
 public void UnsetHeading(PhraseNode node)
 {
     if (node == mHeading)
     {
         mHeading = null;
     }
 }
Beispiel #7
0
        /// <summary>
        /// Copy all attributes of node in parameter to another.
        /// </summary>
        public void CopyAttributes(EmptyNode node)
        {
            mRole       = node.mRole;
            mCustomRole = node.mCustomRole;
            mPageNumber = node.mPageNumber != null?node.mPageNumber.Clone() : null;

            mTODO = node.TODO;
        }
Beispiel #8
0
 /// <summary>
 /// Set the heading to be the given node, if it has audio and there is no heading already.
 /// Return whether the node was actually suitable as heading.
 /// </summary>
 public bool DidSetHeading(EmptyNode node)
 {
     if (node is PhraseNode && mHeading == null)
     {
         mHeading = node;
         return(true);
     }
     return(false);
 }
Beispiel #9
0
        protected override TreeNode ExportProtected(urakawa.Presentation destPres)
        {
            UpdateAssociatedNodeLocationString();
            EmptyNode exportedNode = (EmptyNode)base.ExportProtected(destPres);

            exportedNode.CopyAttributes(this);
            exportedNode.m_AssociatedNodeLocation = this.m_AssociatedNodeLocation;
            //exportedNode.AssociatedNode = this.AssociatedNode;
            return(exportedNode);
        }
Beispiel #10
0
        /// <summary>
        /// Copy all attributes of node in parameter to another.
        /// </summary>
        public void CopyAttributes(EmptyNode node)
        {
            mRole       = node.mRole;
            mCustomRole = node.mCustomRole;
            mPageNumber = node.mPageNumber != null?node.mPageNumber.Clone() : null;

            mTODO = node.TODO;
            if (node.m_CommentText != null)
            {
                m_CommentText = node.m_CommentText;
            }
        }
Beispiel #11
0
 /// <summary>
 /// Add a custom class to the list.  Duplicates are filtered out.
 /// </summary>
 public void AddCustomClass(string customClass, EmptyNode node)
 {
     if (customClass == null || customClass == "")
     {
         return;
     }
     if (!mCustomClasses.ContainsKey(customClass))
     {
         mCustomClasses.Add(customClass, new List <EmptyNode>(1));
         if (CustomClassAddded != null)
         {
             CustomClassAddded(this, new CustomClassEventArgs(customClass));
         }
     }
     mCustomClasses[customClass].Add(node);
 }
Beispiel #12
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) { });
 }
Beispiel #13
0
        public EmptyNode GetAnchorForReferencedNode(EmptyNode referencedNode)
        {
            List <EmptyNode> nodesToRemove = new List <EmptyNode>();

            for (int i = 0; i < m_ListOfAnchorNodes.Count; i++)
            {
                EmptyNode n = m_ListOfAnchorNodes[i];
                if (!n.IsRooted)
                {
                    m_ListOfAnchorNodes.Remove(n);
                    --i;
                    continue;
                }
                if (n.AssociatedNode != null && n.AssociatedNode == referencedNode)
                {
                    return(n);
                }
            }
            for (int i = 0; i < m_ListOfSectionsToBeIteratedForAnchors.Count; i++)
            {
                SectionNode section = m_ListOfSectionsToBeIteratedForAnchors[i];
                EmptyNode   anchor  = null;
                for (int j = 0; j < section.PhraseChildCount; j++)
                {
                    EmptyNode n = section.PhraseChild(j);
                    if (n.Role_ == EmptyNode.Role.Anchor)
                    {
                        ListOfAnchorNodes_Add(n);
                        if (n.AssociatedNode == referencedNode)
                        {
                            anchor = n;
                        }
                    }
                }

                m_ListOfSectionsToBeIteratedForAnchors.Remove(section);
                i--;
                if (anchor != null)
                {
                    return(anchor);
                }
            }
            return(null);
        }
Beispiel #14
0
 /// <summary>
 /// Remove a custom class from the list.
 /// </summary>
 public void RemoveCustomClass(string customClass, EmptyNode node)
 {
     if (mCustomClasses.ContainsKey(customClass))
     {
         if (node != null)
         {
             mCustomClasses[customClass].Remove(node);
         }
         if (mCustomClasses[customClass].Count == 0 ||
             (mCustomClasses[customClass].Count == 1 && mCustomClasses[customClass][0] == null))    // condition appended because custom class without an empty node is initialised with null entry
         {
             if (EmptyNode.SkippableNamesList.Contains(customClass))
             {
                 return;
             }
             mCustomClasses.Remove(customClass);
             if (CustomClassRemoved != null)
             {
                 CustomClassRemoved(this, new CustomClassEventArgs(customClass));
             }
         }
     }
 }
Beispiel #15
0
 /// <summary>
 /// During recording of a phrase, its audio may/should be updated.
 /// </summary>
 public void UpdateAudioForPhrase(EmptyNode phrase, ManagedAudioMedia media)
 {
     ((PhraseNode)phrase).Audio = media;
 }