Ejemplo n.º 1
0
        private bool SelectPreviousRunWord()
        {
            if (CurrentRunWord == null)
            {
                return(false);
            }
            ARun prevRun = CurrentARun.LogicalPrevious();

            if (IsPlayingOnlyText)
            {
                while (prevRun != null && prevRun.IsImage)
                {
                    prevRun = prevRun.LogicalPrevious();
                }
            }
            if (prevRun == null)
            {
                return(false);
            }
            prevRun.Select();
            return(true);
        }
Ejemplo n.º 2
0
        private bool SelectNextRunWord()
        {
            if (CurrentRunWord == null)
            {
                return(false);
            }

            ARun nextRun = CurrentARun.LogicalNext();

            if (IsPlayingOnlyText)
            {
                while (nextRun != null && nextRun.IsImage)
                {
                    nextRun = nextRun.LogicalNext();
                }
            }
            if (nextRun == null)
            {
                return(false);
            }
            nextRun.Select();
            return(true);
        }
Ejemplo n.º 3
0
        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem oldTVI = e.OldValue as TreeViewItem;
            TreeViewItem newTVI = e.NewValue as TreeViewItem;

            //Console.WriteLine("OLD: " + oldTVI + ", NEW: " + newTVI);
            if (newTVI == null || newTVI.Tag == null)
            {
                return;
            }

            Cursor = Cursors.Wait;
            Content oldContent = CurrentContent;
            Content newContent = (newTVI.Tag is ImageBlock ? (newTVI.Tag as ImageBlock).Content : newTVI.Tag as Content);

            if (oldContent != newContent)
            {
                Paragraphs.Clear();
                if (CurrentContent != null)
                {
                    foreach (Block block in CurrentContent.Blocks)
                    {
                        foreach (Sentence sentence in block.Sentences)
                        {
                            sentence.ClearCachedSound();
                        }
                    }
                }
                if (SelectedTVI != null)
                {
                    SelectedTVI.Background = ProjectProperties.Transparent;
                }
                foreach (TreeViewItem tvi in _AllContentsTVI.Items)
                {
                    if (tvi.Tag == oldContent)
                    {
                        tvi.Background = ProjectProperties.Transparent;
                    }
                }

                CurrentState   = State.Stop;
                SelectedTVI    = newTVI;
                CurrentContent = newContent;
                //Console.WriteLine("Sentences Count = " + CurrentContent.TotalSentences);

                foreach (Block block in CurrentContent.Blocks)
                {
                    Paragraph paragraph = new Paragraph();
                    Paragraphs.Add(paragraph);

                    if (block is ImageBlock)
                    {
                        RunImage image = new RunImage(block as ImageBlock);
                        InitiateRun(image);
                        paragraph.Inlines.Add(image);
                        continue;
                    }

                    foreach (Sentence sentence in block.Sentences)
                    {
                        //Console.WriteLine("S: " + sentence.ID);
                        sentence.GetCachedSound();
                        foreach (Word word in sentence.Words)
                        {
                            RunWord run = new RunWord(word);
                            paragraph.Inlines.Add(run);
                            InitiateRun(run);
                        }
                    }
                }
                SelectedTVI.Background = ProjectProperties.SelectedContent;
                foreach (TreeViewItem tvi in _AllContentsTVI.Items)
                {
                    if (tvi.Tag == newContent)
                    {
                        tvi.Background = ProjectProperties.SelectedContent;
                    }
                }

                PageTeller.Text = (1 + ProjectInfo.Contents.IndexOf(CurrentContent)) + " / " + ProjectInfo.Contents.Count;
            }

            if (newTVI.Tag is ImageBlock)
            {
                RunImage runImg = (newTVI.Tag as ImageBlock).Run;
                runImg.Select();
                runImg.BringIntoView();
            }
            else if (CurrentARun == null)
            {
                SelectFirstRunWord();
            }
            else
            {
                CurrentARun.Select();
            }
            Cursor = Cursors.Arrow;
        }