コード例 #1
0
        private void TranslatingAllWords()
        {

            ProgressBar_Model pb = new ProgressBar_Model();
            pb.Text = Tx.T("SubtitleEditor.Messages.Processing.TranslatingWordsOfDictionary");
            pb.Minimum = 0;
            pb.Maximum = Subtitles.Items.Count;
            pb.Value = pb.Minimum;

            ViewModelLocator.AddLongTaskProgressBar(pb);

            int cnt = 0;
            foreach (SubtitleItem item in Subtitles.Items)
            {
                foreach(SubtitleItem.Word wrd in item.WordsCollection)
                {
                    wrd.Translating(Subtitles.Dictionary);
                }

                pb.Value = ++cnt;
                if (pb.IsCanceled) break;
            }

            ViewModelLocator.RemoveLongTaskProgressBar(pb);

        }
コード例 #2
0
        private void SplitOnWords()
        {

            ProgressBar_Model pb = new ProgressBar_Model();
            pb.Text = Tx.T("SubtitleEditor.Messages.Processing.SplitOnWords");
            pb.Minimum = 0;
            pb.Maximum = Subtitles.Items.Count;
            pb.Value = pb.Minimum;

            ViewModelLocator.AddLongTaskProgressBar(pb);
            int cnt = 0;

            Subtitles.IsThereDictionary = true;
            //if (Subtitles.Dictionary == null) Subtitles.Dictionary = new Dictionary();

            // create a new words
            int loccnt = 0;
            foreach (SubtitleItem item in Subtitles.Items.OrderBy(x=>x.TimeStart))
            {
                if (item.WordsCollection == null) item.WordsCollection = new SynchronizedObservableCollection<SubtitleItem.Word>();
                PhraseOfCollectMode phrase = new PhraseOfCollectMode(item);
                byte idx = 1;
                foreach (var wrd in phrase.Words)
                {

                    // removes doubles
                    //if (item.WordsCollection.Any(x => x.word == wrd.word)) continue;

                    item.WordsCollection.Add(new SubtitleItem.Word
                    {
                        word = wrd.word,
                        number = idx,
                    });
                    idx++;

                    loccnt++;
                    if (loccnt == 50)
                    {
                        EFDbContext.SaveChgs();
                        loccnt = 0;
                    }

                }

                pb.Value = ++cnt;
                if (pb.IsCanceled) break;

            }

            EFDbContext.SaveChgs();
            ViewModelLocator.RemoveLongTaskProgressBar(pb);
            
        }
コード例 #3
0
        private void ApplyAllRules()
        {

            ProgressBar_Model pb = new ProgressBar_Model();
            pb.Text = Tx.T("SubtitleEditor.Messages.Processing.ApplyAllRules");
            pb.Minimum = 0;
            pb.Maximum = Subtitles.PrimaryLanguage.ProcessingWordsRules.Count;
            pb.Value = pb.Minimum;

            ViewModelLocator.AddLongTaskProgressBar(pb);

            int cnt = 0;
            foreach (ProcessingWordsRules item in Subtitles.PrimaryLanguage.ProcessingWordsRules)
            {
                ApplyRuleToAll(item);

                pb.Value = ++cnt;
                if (pb.IsCanceled) break;

            }
            ViewModelLocator.RemoveLongTaskProgressBar(pb);
        }
コード例 #4
0
        private void TranslateAllSubtitles()
        {
            ProgressBar_Model pb = new ProgressBar_Model();
            pb.Text = Tx.T("SubtitleEditor.Messages.Processing.TranslateAllSubtitles");
            pb.Minimum = 0;
            pb.Maximum = Subtitles.PrimaryLanguage.ProcessingWordsRules.Count;
            pb.Value = pb.Minimum;

            ViewModelLocator.AddLongTaskProgressBar(pb);

            int cnt = 0;
            foreach (var elm in Subtitles.Items)
            {
                if (!string.IsNullOrEmpty(elm.Text)) elm.Text2 = Subtitles.PrimaryLanguage.TranslatePhrase(elm.Text);
                pb.Value = ++cnt;
                if (pb.IsCanceled) break;
            }

            ViewModelLocator.RemoveLongTaskProgressBar(pb);
        }
コード例 #5
0
        private void DeleteWords()
        {
            ProgressBar_Model pb = new ProgressBar_Model();
            pb.Text = Tx.T("SubtitleEditor.Messages.Processing.DeleteWords");
            pb.IsIndeterminate = true;

            ViewModelLocator.AddLongTaskProgressBar(pb);

            var delete = Subtitles.Items.Where(item => item.WordsCollection != null).SelectMany(item => item.WordsCollection);
            EFDbContext.DataBase.SubtitleItem_Words.RemoveRange(delete);

            ViewModelLocator.RemoveLongTaskProgressBar(pb);
        }
コード例 #6
0
 public static void RemoveLongTaskProgressBar(ProgressBar_Model pb)
 {
     BeginInvoke(()=>Instance.AppWnd_VM.LongTasks.Remove(pb));
 }
コード例 #7
0
 public static void AddLongTaskProgressBar(ProgressBar_Model pb)
 {
     BeginInvoke(new Action(()=>Instance.AppWnd_VM.LongTasks.Add(pb)));
 }