Пример #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();
                }
            }
        }
Пример #2
0
        public SpeakerManagerViewModel(SpeakerCollection documentSpeakers, SpeakerCollection localSpeakers, SpeakersApi api, SpeakersManager window)
        {
            _window = window;
            _api    = api;
            if (_api != null)
            {
                _loadingTimer           = new System.Timers.Timer(1000);
                _loadingTimer.AutoReset = false;
                _loadingTimer.Elapsed  += _loadingTimer_Elapsed;
            }

            this._document = documentSpeakers;
            this._local    = localSpeakers;

            _showOnline   = Settings.Default.SpeakerManagerShowOnline;
            _showLocal    = Settings.Default.SpeakerManagerShowLocal;
            _showDocument = Settings.Default.SpeakerManagerShowDocument;

            this.PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
            {
                switch (e.PropertyName)
                {
                case "ShowLocal":
                    Settings.Default.SpeakerManagerShowLocal = this.ShowLocal;
                    break;

                case "ShowDocument":
                    Settings.Default.SpeakerManagerShowLocal = this.ShowDocument;
                    break;

                case "ShowOnline":
                    Settings.Default.SpeakerManagerShowLocal = this.ShowOnline;
                    break;
                }
            };


            ReloadSpeakers();
        }
Пример #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);
        }
Пример #4
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);
        }
Пример #5
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();
                }
            }

        }