コード例 #1
0
        public SpeakerSynchronizer(WPFTranscription Transcription, AdvancedSpeakerCollection SpeakersDatabase)
            : this()
        {
            this._transcription    = Transcription;
            this._speakersDatabase = SpeakersDatabase;


            _pairs = _transcription.Speakers
                     .OrderBy(s => s.Surname)
                     .ThenBy(s => s.FirstName)
                     .ThenBy(s => s.MiddleName)
                     .Select(s => new SpeakerPair {
                Speaker1 = new SpeakerContainer(s)
            })
                     .ToList();

            //Join speakers from document with speakers from localDB by fullname and order pairs
            var first = _pairs
                        .Join(_speakersDatabase, p => p.Speaker1.Speaker.FullName.ToLower(), s => s.FullName.ToLower(), (sp, s) => new { document = sp, local = s })
                        .GroupBy(s => s.document)
                        .Select(g => g.First())
                        .OrderBy(s => s.local.Surname)
                        .ThenBy(s => s.local.FirstName)
                        .ThenBy(s => s.local.MiddleName);

            //get all speakers from local DB that was not joined
            var other = _speakersDatabase.Except(first.Select(s => s.local).ToArray())
                        .OrderBy(s => s.Surname)
                        .ThenBy(s => s.FirstName)
                        .ThenBy(s => s.MiddleName);

            //concat all speakers from local DB but ordered to match remaining speakers in document.
            listlocal.ItemsSource = first.Select(s => s.local).Concat(other).ToList();


            //add pairs with order matching to listlocal and concat speakers without matching name in local DB
            listdocument.ItemsSource = _pairs = first.Select(s => s.document)
                                                .OrderBy(s => s.Speaker1.SurName)
                                                .ThenBy(s => s.Speaker1.FirstName)
                                                .ThenBy(s => s.Speaker1.MiddleName)
                                                .Concat(_pairs.Except(first.Select(s => s.document))).ToList();
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: Ttxman/NanoTrans
        private void LoadSpeakersDatabase()
        {
            if (Settings.Default.FeatureEnabler.LocalSpeakers)
            {
                if (!File.Exists(Settings.Default.SpeakersDatabasePath))
                    MessageBox.Show(Properties.Strings.MessageBoxLocalSpeakersDatabaseUnreachableLoad, Properties.Strings.MessageBoxWarningCaption, MessageBoxButton.OK, MessageBoxImage.Warning);

                if (Settings.Default.SpeakersDatabasePath.Contains(FilePaths.ProgramDirectory))
                {
                    if (!FilePaths.WriteToAppData)
                    {
                        SpeakerCollection.Deserialize(Settings.Default.SpeakersDatabasePath, SpeakersDatabase);
                    }
                    else
                    {
                        string fname2 = System.IO.Path.Combine(FilePaths.AppDataDirectory, Settings.Default.SpeakersDatabasePath.Substring(FilePaths.ProgramDirectory.Length));
                        if (File.Exists(fname2))
                        {
                            SpeakerCollection.Deserialize(fname2, SpeakersDatabase);
                        }
                        else if (File.Exists(Settings.Default.SpeakersDatabasePath))
                        {
                            SpeakerCollection.Deserialize(Settings.Default.SpeakersDatabasePath, SpeakersDatabase);
                        }
                    }
                }
                else
                {
                    SpeakerCollection.Deserialize(FilePaths.EnsureDirectoryExists(Settings.Default.SpeakersDatabasePath), SpeakersDatabase);
                }
            }
            else
            {
                SpeakersDatabase = new AdvancedSpeakerCollection();
            }
        }
コード例 #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
ファイル: Window1.xaml.cs プロジェクト: Ttxman/NanoTrans
        public Window1()
        {
            this.DataContext = this;
            InitializeComponent();

            LoadGlobalSetup();

            Settings.Default.FeatureEnabler.FeaturesChanged += FeatureEnabler_FeaturesChanged;
#if MINIMAL
            var fe = NanoTrans.Properties.Settings.Default.FeatureEnabler;
            fe.AudioManipulation = false;
            fe.DbMerging = false;
            fe.ChaptersAndSections = false;
            fe.LocalEdit = false;
            fe.LocalSpeakers = false;
            fe.PhoneticEditation = false;
            fe.QuickExport = false;
            fe.QuickNavigation = false;
            fe.VideoFrame = false;
            fe.NonSpeechEvents = false;
            fe.Spellchecking = false;
            fe.Export = false;
            fe.SpeakerAttributes = false;
            fe.VideoFrame = false;

#endif

            SpeakersDatabase = new AdvancedSpeakerCollection();

            _WavReader = new WavReader();
            _WavReader.HaveData += oWav_HaveData;
            _WavReader.HaveFileNumber += oWav_ReportConversionProgress;
            _WavReader.TemporaryWavesDone += new EventHandler(oWav_TemporaryWavesDone);
        }
コード例 #5
0
        public SpeakerSynchronizer(WPFTranscription Transcription, AdvancedSpeakerCollection SpeakersDatabase)
            : this()
        {
            this._transcription = Transcription;
            this._speakersDatabase = SpeakersDatabase;

            _pairs = _transcription.Speakers
                .OrderBy(s => s.Surname)
                .ThenBy(s => s.FirstName)
                .ThenBy(s => s.MiddleName)
                .Select(s => new SpeakerPair { Speaker1 = new SpeakerContainer(s) })
                .ToList();

            //Join speakers from document with speakers from localDB by fullname and order pairs
            var first = _pairs.Join(_speakersDatabase, p => p.Speaker1.Speaker.FullName.ToLower(), s => s.FullName.ToLower(), (sp, s) => new { document = sp, local = s })
                .Distinct()
                .OrderBy(s => s.local.Surname)
                .ThenBy(s => s.local.FirstName)
                .ThenBy(s => s.local.MiddleName);

            //get all speakers from local DB that was not joined
            var other = _speakersDatabase.Except(first.Select(s => s.local).ToArray())
                .OrderBy(s => s.Surname)
                .ThenBy(s => s.FirstName)
                .ThenBy(s => s.MiddleName);

            //concat all speakers from local DB but ordered to match remaining speakers in document.
            listlocal.ItemsSource = first.Select(s => s.local).Concat(other).ToList();

            //add pairs with order matching to listlocal and concat speakers without matching name in local DB
            listdocument.ItemsSource = _pairs = first.Select(s => s.document)
                                                        .OrderBy(s => s.Speaker1.SurName)
                                                        .ThenBy(s => s.Speaker1.FirstName)
                                                        .ThenBy(s => s.Speaker1.MiddleName)
                                                        .Concat(_pairs.Except(first.Select(s => s.document))).ToList();
        }