void AudioPlayer_PositionChanged(object sender, PositionChangedEventArgs e)
        {
            if (this.Document == null)
            {
                return;
            }

            var position = e.CurrentPosition;

            DMParagraph newSelectedParagraph = null;
            DMSentence  newSelectedSentence  = null;

            bool isInCurrentPara = this.CheckIsInCurrentParagraph(position);

            if (isInCurrentPara == true)
            {
                newSelectedParagraph = this.SelectedParagraph;

                var isInCurrentSen = this.CheckIsInCurrentSentence(position);
                if (isInCurrentSen == true)
                {
                    newSelectedSentence = this.SelectedSentence;
                }
                else
                {
                    newSelectedSentence = this.SelectedParagraph.GetSentence(position);
                }
            }
            else
            {
                newSelectedParagraph = this.Document.GetParagraph(position);
                if (newSelectedParagraph != null)
                {
                    newSelectedSentence = newSelectedParagraph.GetSentence(position);
                }
            }

            if (newSelectedParagraph != this.SelectedParagraph)
            {
                this.SelectedParagraph = newSelectedParagraph;
            }

            if (newSelectedSentence != this.SelectedSentence)
            {
                this.SelectedSentence = newSelectedSentence;
            }

            SyncableWord word = null;

            if (newSelectedSentence != null)
            {
                word = newSelectedSentence.GetWord(position);
            }

            if (word != this.SelectedWord)
            {
                this.SelectedWord = word;
            }
        }
Exemple #2
0
        private static DMSentence BuildSentence(int index, RecognizedSentence sentence)
        {
            var dmSentence = new DMSentence(index);

            for (int i = 0; i < sentence.Words.Count; i++)
            {
                var          word     = sentence.Words[i];
                SyncableWord syncWord = new SyncableWord(word.Text)
                {
                    BeginTime  = word.Begin,
                    EndTime    = word.End,
                    Confidence = word.Confidence,
                };
                dmSentence.Inlines.Add(syncWord);
            }

            return(dmSentence);
        }