private void ApplyCaptionButton_Click(object sender, RoutedEventArgs e) { RunImage iRun = ImageCtrlGrid.Tag as RunImage; String caption = ""; foreach (Paragraph par in ImageCaptionRTB.Document.Blocks) { foreach (Run run in par.Inlines) { caption += run.Text; } caption += "\n"; } iRun.SetCaption(caption); foreach (RunWord runWord in iRun.RunWords) { InitiateRun(runWord); } ImageCtrlGrid.Tag = null; iRun.Select(); CurrentState = State.Stop; }
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; }