/// <summary>
        /// next element in index Depth-first tree traversal. (Phrases are ignored)
        /// </summary>
        /// <returns></returns>
        public TranscriptionElement Next()
        {
            if (_children.Count > 0 && !IsParagraph)
            {
                return(_children[0]);
            }

            if (_Parent == null)
            {
                return(null);
            }
            if (_ParentIndex == _Parent._children.Count - 1)
            {
                TranscriptionElement te = _Parent.NextSibling();
                if (te != null)
                {
                    return(te.Next());
                }

                return(null);
            }
            else
            {
                return(_Parent._children[_ParentIndex + 1]);
            }
        }
 public ChangeAction(ChangeType changeType, TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
 {
     _changeType               = changeType;
     _changedElement           = changedElement;
     _changeTranscriptionIndex = changeIndex;
     _changeAbsoluteIndex      = changeAbsoluteIndex;
 }
 public virtual void Add(TranscriptionElement data)
 {
     _children.Add(data);
     data._Parent      = this;
     data._ParentIndex = _children.Count - 1;
     OnContentChanged(new InsertAction(data, data.TranscriptionIndex, data.AbsoluteIndex));
 }
Exemple #4
0
        public VirtualTypeList(TranscriptionElement parent, List <TranscriptionElement> list)
        {
            if (parent == null)
            {
                throw new ArgumentNullException();
            }

            _elementlist = list;
            _parent      = parent;
        }
Exemple #5
0
        public override void Insert(TranscriptionIndex index, TranscriptionElement value)
        {
            ValidateIndexOrThrow(index);
            if (!index.IsPhraseIndex)
            {
                throw new IndexOutOfRangeException("index");
            }

            Phrases.Insert(index.PhraseIndex, (TranscriptionPhrase)value);
        }
        public virtual void Insert(int index, TranscriptionElement data)
        {
            if (index < 0 || index > Children.Count)
            {
                throw new IndexOutOfRangeException();
            }

            _children.Insert(index, data);
            data._Parent = this;
            for (int i = index; i < _children.Count; i++)
            {
                _children[i]._ParentIndex = i;
            }

            OnContentChanged(new InsertAction(data, data.TranscriptionIndex, data.AbsoluteIndex));
        }
Exemple #7
0
 public override void Insert(TranscriptionIndex index, TranscriptionElement value)
 {
     ValidateIndexOrThrow(index);
     if (index.IsParagraphIndex)
     {
         if (index.IsPhraseIndex)
         {
             Paragraphs[index.ParagraphIndex].Insert(index, value);
         }
         else
         {
             Paragraphs.Insert(index.ParagraphIndex, (TranscriptionParagraph)value);
         }
     }
     else
     {
         throw new IndexOutOfRangeException("index");
     }
 }
        public virtual bool Replace(TranscriptionElement oldelement, TranscriptionElement newelement)
        {
            int index = _children.IndexOf(oldelement);

            if (index >= 0)
            {
                var oi = oldelement.TranscriptionIndex;
                var oa = oldelement.AbsoluteIndex;

                newelement._Parent      = this;
                newelement._ParentIndex = oldelement._ParentIndex;

                oldelement._Parent      = null;
                oldelement._ParentIndex = -1;

                _children[index] = newelement;

                OnContentChanged(new ReplaceAction(oldelement, oi, oa));
                return(true);
            }
            return(false);
        }
 /// <summary>
 /// get next sibling == get next element in Depth-first tree traversal of same type as this
 /// </summary>
 /// <returns></returns>
 public TranscriptionElement NextSibling()
 {
     if (_Parent == null)
     {
         return(null);
     }
     if (_ParentIndex == _Parent._children.Count - 1)
     {
         TranscriptionElement te = _Parent.NextSibling();
         if (te != null && te.Children.Count > 0)
         {
             return(te._children[0]);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(_Parent._children[_ParentIndex + 1]);
     }
 }
 /// <summary>
 /// get next sibling == get previous element in Depth-first tree traversal of same type as this
 /// </summary>
 /// <returns></returns>
 public TranscriptionElement PreviousSibling()
 {
     if (_Parent == null)
     {
         return(null);
     }
     if (_ParentIndex == 0)
     {
         TranscriptionElement te = _Parent.PreviousSibling();
         if (te != null && te.Children.Count > 0)
         {
             return(te._children[te._children.Count - 1]);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(_Parent._children[_ParentIndex - 1]);
     }
 }
        public virtual void RemoveAt(int index)
        {
            if (index < 0 || index >= Children.Count)
            {
                throw new IndexOutOfRangeException();
            }

            TranscriptionElement element = _children[index];
            int indexabs = element.AbsoluteIndex;
            var c        = _children[index];
            var ci       = c.TranscriptionIndex;
            var ca       = c.AbsoluteIndex;

            c._Parent      = null;
            c._ParentIndex = -1;
            _children.RemoveAt(index);

            for (int i = index; i < _children.Count; i++)
            {
                _children[i]._ParentIndex = i;
            }

            OnContentChanged(new RemoveAction(c, ci, ca));
        }
 public InsertAction(TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
     : base(ChangeType.Add, changedElement, changeIndex, changeAbsoluteIndex)
 {
 }
 public override void Add(TranscriptionElement data)
 {
     throw new NotSupportedException();
 }
 public ReplaceAction(TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
     : base(ChangeType.Replace, changedElement, changeIndex, changeAbsoluteIndex)
 {
 }
 public abstract void Insert(TranscriptionIndex index, TranscriptionElement value);
 public override bool Remove(TranscriptionElement value)
 {
     throw new NotSupportedException();
 }
 public override void Insert(int index, TranscriptionElement data)
 {
     throw new NotSupportedException();
 }
 public TextAction(TranscriptionElement changedelement, TranscriptionIndex changeIndex, int changeAbsoluteIndex, string oldtstring)
     : base(ChangeType.Modify, changedelement, changeIndex, changeAbsoluteIndex)
 {
     _oldtstring = oldtstring;
 }
 public override bool Replace(TranscriptionElement oldelement, TranscriptionElement newelement)
 {
     throw new NotSupportedException();
 }
 public virtual bool Remove(TranscriptionElement value)
 {
     RemoveAt(_children.IndexOf(value));
     return(true);
 }
 public override void Insert(TranscriptionIndex index, TranscriptionElement value)
 {
     throw new NotImplementedException();
 }
 public EndAction(TranscriptionElement changedelement, TranscriptionIndex changeIndex, int changeAbsoluteIndex, TimeSpan oldtime)
     : base(ChangeType.Modify, changedelement, changeIndex, changeAbsoluteIndex)
 {
     _oldtime = oldtime;
 }