Пример #1
0
        private void OpenImageWindow_Click(object sender, RoutedEventArgs e)
        {
            RunImage iRun = CurrentARun as RunImage;

            if (iRun == null)
            {
                return;
            }
            new ImageWindow(iRun.ImageSource).Show();
        }
Пример #2
0
 private void EditCaptionButton_Click(object sender, RoutedEventArgs e)
 {
     Dispatcher.Invoke((Action)(() =>
     {
         RunImage currentImage = ImageCtrlGrid.Tag as RunImage;
         ImageInlines.Clear();
         Run caption = new Run();
         foreach (RunWord run in currentImage.RunWords)
         {
             caption.Text += run.Text;
         }
         ImageInlines.Add(caption);
         ImageCaptionRTB.ClearValue(RichTextBox.SelectionBrushProperty);
         ImageCaptionRTB.IsReadOnly = false;
         ImageCaptionRTB.CaretBrush = null;
         ImageCaptionRTB.SelectAll();
         ImageCaptionRTB.Focus();
     }));
     CurrentState = State.Caption;
 }
Пример #3
0
        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;
        }
Пример #4
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;
        }
Пример #5
0
        } // 7

        private void UpdateImageCtrlGrid()
        {
            Dispatcher.Invoke((Action)(() =>
            {
                ImageCtrlGrid.Visibility = (CurrentARun != null && CurrentARun.IsImage) ? Visibility.Visible : Visibility.Hidden;
                if (ImageCtrlGrid.Visibility != Visibility.Visible)
                {
                    return;
                }
                RunImage currentImage = CurrentARun as RunImage;
                switch (CurrentState)
                {
                case State.Play:
                case State.Stop:
                case State.Segment:
                case State.Edit:
                    if (ImageCtrlGrid.Tag != currentImage)
                    {
                        ImageCtrlGrid.Tag = currentImage;
                        Image.Source = new BitmapImage(new Uri(currentImage.ImageSource, UriKind.Absolute));
                        ImageCaptionRTB.Document.Blocks.Clear();
                        ImageCaptionRTB.Document.Blocks.Add(new Paragraph());
                        ImageInlines.Clear();
                        foreach (RunWord run in currentImage.RunWords)
                        {
                            ImageInlines.Add(run);
                        }
                    }
                    EditCaptionPanel.Visibility = Visibility.Visible;
                    CancelApplyCaptionPanel.Visibility = Visibility.Hidden;
                    break;

                case State.Caption:
                    EditCaptionPanel.Visibility = Visibility.Hidden;
                    CancelApplyCaptionPanel.Visibility = Visibility.Visible;
                    break;
                }
                #region ImageCaptionRTB
                switch (CurrentState)
                {
                case State.Stop:
                case State.Play:
                case State.Edit:
                    ImageCaptionRTB.SelectionBrush = Brushes.Transparent;
                    ImageCaptionRTB.IsReadOnly = true;
                    ImageCaptionRTB.CaretBrush = Brushes.Transparent;
                    ImageCaptionRTB.IsReadOnlyCaretVisible = false;
                    break;

                case State.Segment:
                    ImageCaptionRTB.SelectionBrush = Brushes.Transparent;
                    ImageCaptionRTB.IsReadOnly = true;
                    ImageCaptionRTB.CaretBrush = null;
                    ImageCaptionRTB.IsReadOnlyCaretVisible = true;
                    break;

                case State.Caption:
                    break;
                }
                #endregion
            }));
        } // 8