예제 #1
0
        private void Sound_PositionChanged(object sender, PositionChangedEventArgs e)
        {
            switch (CurrentState)
            {
            case State.Stop:
                break;

            case State.Play:
                if (!e.IsEnded && !CurrentRunWord.IsIn(e.BytePosition))
                {
                    while (SelectNextRunWord() && !CurrentRunWord.IsIn(e.BytePosition))
                    {
                        ;
                    }
                    if (CurrentRunWord == null)
                    {
                        SelectFirstRunWord();
                    }
                }
                break;

            case State.Segment:
                break;

            case State.Edit:
                break;
            }
        }
예제 #2
0
 private void PlaySound()
 {
     if (CurrentRunWord == null)
     {
         return;
     }
     if (IsPlayingOnlyText)
     {
         if (CurrentARun.IsImage)
         {
             if (!SelectNextRunWord())
             {
                 return;
             }
         }
     }
     PlayingSound = CurrentRunWord.GetSentenceCachedSound();
     PlayingSound.PositionChanged += Sound_PositionChanged;
     PlayingSound.SoundEnded      += PlayingSound_SoundEnded;
     AudioPlaybackEngine.Instance.PlaySound(PlayingSound);
 }
예제 #3
0
        private void BackwardB_Click(object sender, RoutedEventArgs e)
        {
            (sender as FrameworkElement).Cursor = Cursors.Wait;
            switch (CurrentState)
            {
            case State.Stop:
                if (SelectPreviousRunWord())
                {
                    CurrentRunWord.PlayCachedSound();
                }
                break;

            case State.Play:
                CurrentState = State.Stop;
                StopSound();
                if (SelectPreviousRunWord())
                {
                    CurrentRunWord.PlayCachedSound();
                }
                break;

            case State.Segment:
                break;

            case State.Edit:
                CurrentState = State.Stop;
                if (SelectPreviousRunWord())
                {
                    CurrentRunWord.PlayCachedSound();
                }
                break;

            case State.Caption:
                break;
            }
            (sender as FrameworkElement).Cursor = Cursors.Hand;
        }
예제 #4
0
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            (sender as FrameworkElement).Cursor = Cursors.Wait;
            switch (CurrentState)
            {
            case State.Stop:
                break;

            case State.Play:
                break;

            case State.Segment:
                break;

            case State.Edit:
                int selectIndex = DictComboBox.Items.IndexOf(DictComboBox.Text);
                if (selectIndex == -1)
                {
                    selectIndex = DictComboBox.Items.Add(DictComboBox.Text);
                    if (!ProjectInfo.Dictionary.ContainsKey(CurrentRunWord.Text))
                    {
                        ProjectInfo.Dictionary.Add(CurrentRunWord.Text, new List <String>()
                        {
                            CurrentRunWord.Text
                        });
                    }
                    ProjectInfo.Dictionary[CurrentRunWord.Text].Add(DictComboBox.Text);
                }
                if (ApplyOnlyThisWord.IsChecked == true)
                {
                    CurrentRunWord.SelectDictAt(selectIndex);
                }
                else if (ApplyAll.IsChecked == true)
                {
                    foreach (Content content in ProjectInfo.Contents)
                    {
                        foreach (Block block in content.Blocks)
                        {
                            foreach (Sentence sentence in block.Sentences)
                            {
                                foreach (Word word in sentence.Words)
                                {
                                    if (word.OriginalText.Equals(CurrentRunWord.Text))
                                    {
                                        if (ExceptLockWord.IsChecked == false || !word.Locked)
                                        {
                                            word.ChangeDictIndex(selectIndex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (ApplyAllFromHere.IsChecked == true)
                {
                    bool foundFirstWord = false;
                    foreach (Content content in ProjectInfo.Contents)
                    {
                        if (content.ID < CurrentContent.ID)
                        {
                            continue;
                        }
                        foreach (Block block in content.Blocks)
                        {
                            foreach (Sentence sentence in block.Sentences)
                            {
                                foreach (Word word in sentence.Words)
                                {
                                    if (word == ProjectInfo.CurrentWord)
                                    {
                                        CurrentRunWord.SelectDictAt(selectIndex);
                                        foundFirstWord = true;
                                    }
                                    else if (foundFirstWord && word.OriginalText.Equals(CurrentRunWord.Text))
                                    {
                                        if (ExceptLockWord.IsChecked == false || !word.Locked)
                                        {
                                            word.ChangeDictIndex(selectIndex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                CurrentRunWord.PlayCachedSound();
                break;

            case State.Caption:
                break;
            }
            (sender as FrameworkElement).Cursor = Cursors.Hand;
        }