Example #1
0
        private void MenuItem_MergeSpeakers(object sender, RoutedEventArgs e)
        {
            var             selectedSpeaker = ((SpeakerContainer)SpeakersBox.SelectedValue).Speaker;
            SpeakersManager sm2             = new SpeakersManager(selectedSpeaker, _transcription, _documentSpeakers, _localSpeakers)
            {
                MessageLabel = Properties.Strings.SpeakersManagerSpeakerMergeLabel,
                Message      = selectedSpeaker.FullName,
                Editable     = false,
                SelectMany   = true
            };

            if (sm2.ShowDialog() == true)
            {
                var speakers = sm2.SpeakersBox.SelectedItems.Cast <SpeakerContainer>().Select(x => x.Speaker).ToList();
                speakers.Remove(selectedSpeaker);

                //merge
                selectedSpeaker.Merges.AddRange(speakers.Select(s => new DBMerge(s.DBID, s.DataBaseType)));
                selectedSpeaker.Merges.AddRange(speakers.SelectMany(s => s.Merges));

                if (speakers.Count == 0)
                {
                    return;
                }

                if (MessageBox.Show(string.Format(Properties.Strings.SpeakersManagerSpeakerMergeDialogQuestionFormat, string.Join("\", \"", speakers.Select(s => s.FullName)), selectedSpeaker.FullName), Properties.Strings.SpeakersManagerSpeakerMergeDialogCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    using (SpeakerProvider.DeferRefresh())
                    {
                        foreach (var s in speakers)
                        {
                            if (_documentSpeakers != null)
                            {
                                _documentSpeakers.RemoveSpeaker(s);
                            }
                            if (_localSpeakers != null)
                            {
                                _localSpeakers.RemoveSpeaker(s);
                            }


                            SpeakerProvider.DeleteSpeaker(s);
                        }
                    }

                    _transcription.BeginUpdate();
                    foreach (TranscriptionParagraph tp in _transcription.EnumerateParagraphs())
                    {
                        if (speakers.Contains(tp.Speaker))
                        {
                            tp.Speaker = selectedSpeaker;
                        }
                    }
                    _transcription.EndUpdate();

                    SpeakerProvider.Refresh();
                    SpeakersBox.UnselectAll();
                }
            }
        }
Example #2
0
        private void CAssignSpeaker(object sender, ExecutedRoutedEventArgs e)
        {
            TranscriptionParagraph tpr = null;
            if (sender is TranscriptionParagraph)
                tpr = (TranscriptionParagraph)sender;
            else
                tpr = VirtualizingListBox.ActiveTransctiption as TranscriptionParagraph;

            var mgr = new SpeakersManager(tpr.Speaker, Transcription, Transcription.Speakers, SpeakersDatabase) { MessageLabel = Properties.Strings.mainWindowSpeakersManagerSelectedParagraphMessage, Message = VirtualizingListBox.ActiveTransctiption.Text };
            if (smwidth != null && smheight != null && smleft != null && smtop != null)
            {
                mgr.Width = smwidth.Value;
                mgr.Height = smheight.Value;
                mgr.Left = smleft.Value;
                mgr.Top = smtop.Value;
            }

            if (mgr.ShowDialog() == true && mgr.SelectedSpeaker != null)
            {
                Transcription.BeginUpdate();
                var origspk = tpr.Speaker;
                tpr.Speaker = mgr.SelectedSpeaker;

                if (!Transcription.EnumerateParagraphs().Any(p => p.Speaker == origspk))
                    Transcription.Speakers.Remove(origspk);


                var replaced = AdvancedSpeakerCollection.SynchronizedAdd(Transcription.Speakers, mgr.SelectedSpeaker);

                if (replaced != null)
                {
                    foreach (var p in Transcription.EnumerateParagraphs().Where(p => p.Speaker == replaced))
                        p.Speaker = mgr.SelectedSpeaker;
                }

                Transcription.EndUpdate();
            }

            smwidth = mgr.Width;
            smheight = mgr.Height;
            smleft = mgr.Left;
            smtop = mgr.Top;

            if (mgr.SpeakerChanged)//refresh all sepakers
            {
                var pinned = SpeakersDatabase.Where(s => s.PinnedToDocument);
                Transcription.Speakers.AddRange(pinned.Except(Transcription.Speakers));
            }

            VirtualizingListBox.SpeakerChanged(VirtualizingListBox.ActiveElement);
        }
Example #3
0
        private void CAssignSpeaker(object sender, ExecutedRoutedEventArgs e)
        {
            TranscriptionParagraph tpr = null;

            if (sender is TranscriptionParagraph)
            {
                tpr = (TranscriptionParagraph)sender;
            }
            else
            {
                tpr = VirtualizingListBox.ActiveTransctiption as TranscriptionParagraph;
            }

            var mgr = new SpeakersManager(tpr.Speaker, Transcription, Transcription.Speakers, SpeakersDatabase)
            {
                MessageLabel = Properties.Strings.mainWindowSpeakersManagerSelectedParagraphMessage, Message = VirtualizingListBox.ActiveTransctiption.Text
            };

            if (smwidth != null && smheight != null && smleft != null && smtop != null)
            {
                mgr.Width  = smwidth.Value;
                mgr.Height = smheight.Value;
                mgr.Left   = smleft.Value;
                mgr.Top    = smtop.Value;
            }

            if (mgr.ShowDialog() == true && mgr.SelectedSpeaker != null)
            {
                Transcription.BeginUpdate();
                var origspk = tpr.Speaker;
                tpr.Speaker = mgr.SelectedSpeaker;

                if (!Transcription.EnumerateParagraphs().Any(p => p.Speaker == origspk))
                {
                    Transcription.Speakers.Remove(origspk);
                }


                var replaced = AdvancedSpeakerCollection.SynchronizedAdd(Transcription.Speakers, mgr.SelectedSpeaker);

                if (replaced != null)
                {
                    foreach (var p in Transcription.EnumerateParagraphs().Where(p => p.Speaker == replaced))
                    {
                        p.Speaker = mgr.SelectedSpeaker;
                    }
                }

                Transcription.EndUpdate();
            }

            smwidth  = mgr.Width;
            smheight = mgr.Height;
            smleft   = mgr.Left;
            smtop    = mgr.Top;

            if (mgr.SpeakerChanged)//refresh all sepakers
            {
                var pinned = SpeakersDatabase.Where(s => s.PinnedToDocument);
                Transcription.Speakers.AddRange(pinned.Except(Transcription.Speakers));
            }

            VirtualizingListBox.SpeakerChanged(VirtualizingListBox.ActiveElement);
        }
Example #4
0
        private void MenuItem_MergeSpeakers(object sender, RoutedEventArgs e)
        {
            var selectedSpeaker = ((SpeakerContainer)SpeakersBox.SelectedValue).Speaker;
            SpeakersManager sm2 = new SpeakersManager(selectedSpeaker, _transcription, _documentSpeakers, _localSpeakers)
            {
                MessageLabel = Properties.Strings.SpeakersManagerSpeakerMergeLabel,
                Message = selectedSpeaker.FullName,
                Editable = false,
                SelectMany = true
            };

            if (sm2.ShowDialog() == true)
            {
                var speakers = sm2.SpeakersBox.SelectedItems.Cast<SpeakerContainer>().Select(x => x.Speaker).ToList();
                speakers.Remove(selectedSpeaker);

                //merge
                selectedSpeaker.Merges.AddRange(speakers.Select(s => new DBMerge(s.DBID, s.DataBaseType)));
                selectedSpeaker.Merges.AddRange(speakers.SelectMany(s => s.Merges));

                if (speakers.Count == 0)
                    return;

                if (MessageBox.Show(string.Format(Properties.Strings.SpeakersManagerSpeakerMergeDialogQuestionFormat, string.Join("\", \"", speakers.Select(s => s.FullName)), selectedSpeaker.FullName), Properties.Strings.SpeakersManagerSpeakerMergeDialogCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    using (SpeakerProvider.DeferRefresh())
                    {
                        foreach (var s in speakers)
                        {
                            if (_documentSpeakers != null)
                                _documentSpeakers.RemoveSpeaker(s);
                            if (_localSpeakers != null)
                                _localSpeakers.RemoveSpeaker(s);


                            SpeakerProvider.DeleteSpeaker(s);
                        }
                    }

                    _transcription.BeginUpdate();
                    foreach (TranscriptionParagraph tp in _transcription.EnumerateParagraphs())
                    {
                        if (speakers.Contains(tp.Speaker))
                            tp.Speaker = selectedSpeaker;
                    }
                    _transcription.EndUpdate();

                    SpeakerProvider.Refresh();
                    SpeakersBox.UnselectAll();
                }
            }

        }