Exemplo n.º 1
0
        private void MenuItem_DeleteSpeaker(object sender, RoutedEventArgs e)
        {
            var selectedSpeaker = ((SpeakerContainer)SpeakersBox.SelectedValue).Speaker;

            if (MessageBox.Show(string.Format(Properties.Strings.SpeakersManagerDeleteSpeakerDialogFormat, selectedSpeaker), Properties.Strings.SpeakersManagerDeleteSpeakerDialogQuestion, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                using (SpeakerProvider.DeferRefresh())
                {
                    SpeakerProvider.DeleteSpeaker(selectedSpeaker);
                    _transcription.BeginUpdate();
                    foreach (TranscriptionParagraph tp in _transcription.EnumerateParagraphs())
                    {
                        if (tp.Speaker == selectedSpeaker)
                        {
                            tp.Speaker = Speaker.DefaultSpeaker;
                        }
                    }
                    _transcription.EndUpdate();
                }
                SpeakersBox.UnselectAll();
            }
        }
Exemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var cleardicts = _pairs.Where(p => p.Speaker2 == null).Count();

            if (cleardicts > 0)
            {
                if (MessageBox.Show("Chcete v lokální databázi vytvořit nové položky pro všechny nepřiřazené mluvčí?", "automatické vytváření mluvčích", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    foreach (var p in _pairs.Where(pa => pa.Speaker2 == null))
                    {
                        var n = new SpeakerContainer(p.Speaker1.Speaker.Copy());
                        n.Speaker.DataBaseType = DBType.User;
                        _speakersDatabase.Add(n.Speaker);
                        p.Speaker2 = n;
                    }
                }
            }

            var pairdict = _pairs.Where(p => p.Speaker2 != null).ToDictionary(p => p.Speaker1.Speaker, p => (p.Speaker2 == null) ? null : p.Speaker2.Speaker);

            _transcription.BeginUpdate();
            foreach (var par in _transcription.EnumerateParagraphs())
            {
                Speaker os;
                if (pairdict.TryGetValue(par.Speaker, out os))
                {
                    par.Speaker = os;
                }
            }
            _transcription.EndUpdate();
            foreach (var spe in pairdict.Keys)
            {
                _transcription.Speakers.RemoveSpeaker(spe);
            }

            this.DialogResult = true;
            Close();
        }
Exemplo n.º 3
0
        public SpeakersManager(Speaker originalSpeaker, WPFTranscription transcription, SpeakerCollection documentSpeakers, SpeakerCollection localSpeakers = null)
        {
            DataContext = this;//not good :)
            _originalSpeaker = originalSpeaker;
            _localSpeakers = localSpeakers;
            _documentSpeakers = documentSpeakers;
            _transcription = transcription;

            InitializeComponent();
            SpeakerProvider = new SpeakerManagerViewModel(new SpeakerCollection(documentSpeakers.Concat(transcription.EnumerateParagraphs().Select(p => p.Speaker)).Where(s => s != Speaker.DefaultSpeaker).Distinct()), localSpeakers, transcription.Api, this);

            var ss = SpeakerProvider.GetContainerForSpeaker(originalSpeaker);
            if (ss != null)
                ss.Marked = true;
            SpeakersBox.SelectedValue = ss;
            SpeakersBox.ScrollIntoView(SpeakersBox.SelectedItem);

            if (_transcription.Api != null)
            {
                SpeakerProvider.ShowLocal = false;
                SpeakerProvider.ShowOnline = true;
            }
            //SpeakersBox.Items.SortDescriptions.Add( new SortDescription("",ListSortDirection.Ascending));
        }
Exemplo n.º 4
0
        public SpeakersManager(Speaker originalSpeaker, WPFTranscription transcription, SpeakerCollection documentSpeakers, SpeakerCollection localSpeakers = null)
        {
            DataContext       = this;//not good :)
            _originalSpeaker  = originalSpeaker;
            _localSpeakers    = localSpeakers;
            _documentSpeakers = documentSpeakers;
            _transcription    = transcription;

            InitializeComponent();
            SpeakerProvider = new SpeakerManagerViewModel(new SpeakerCollection(documentSpeakers.Concat(transcription.EnumerateParagraphs().Select(p => p.Speaker)).Where(s => s != Speaker.DefaultSpeaker).Distinct()), localSpeakers, transcription.Api, this);

            var ss = SpeakerProvider.GetContainerForSpeaker(originalSpeaker);

            if (ss != null)
            {
                ss.Marked = true;
            }
            SpeakersBox.SelectedValue = ss;
            SpeakersBox.ScrollIntoView(SpeakersBox.SelectedItem);

            if (_transcription.Api != null)
            {
                SpeakerProvider.ShowLocal  = false;
                SpeakerProvider.ShowOnline = true;
            }
            //SpeakersBox.Items.SortDescriptions.Add( new SortDescription("",ListSortDirection.Ascending));
        }