Beispiel #1
0
        public async void UpdateFileOffset()
        {
            var result = new StringBuilder();

            using (var reader = new StreamReader(SrtFile.OpenReadStream()))
            {
                while (!reader.EndOfStream)
                {
                    string lineText = await reader.ReadLineAsync();

                    if (lineText.Contains("-->"))
                    {
                        Offset = Offset.Replace(",", ".");
                        TimeSpan.TryParseExact(Offset, @"hh\:mm\:ss\.fff", null, out TimeSpan offsetTime);

                        DateTime firstTimeCode = DateTime.Parse(lineText.Replace(",", ".").Substring(0, 12));
                        DateTime lastTimeCode  = DateTime.Parse(lineText.Replace(",", ".").Substring(17));
                        firstTimeCode = firstTimeCode.Add(offsetTime);
                        lastTimeCode  = lastTimeCode.Add(offsetTime);

                        lineText = $"{firstTimeCode.ToString("HH:mm:ss,fff")} --> {lastTimeCode.ToString("HH:mm:ss,fff")}";
                    }

                    result.AppendLine(lineText);
                }
                OffsetResult = result.ToString();
            }
        }
        public SubtitlesViewModel(SrtFile srtFile, UserProfile userProfile, bool isResumeFile)
        {
            this.UserProfile   = userProfile;
            this._isResumeFile = isResumeFile;

            InitializeFile(srtFile);

            this.TimeBackwardCommand = new RelayCommand(c => { this.ExecuteTimeBackwardCommand(); }, c => this.CanExecuteTimeBackwardCommand());
            this.TimeForwardCommand  = new RelayCommand(c => { this.ExecuteTimeForwardCommand(); }, c => this.CanExecuteTimeForwardCommand());
            this.PlayPauseCommand    = new RelayCommand(c => { this.ExecutePlayPauseCommand(); }, c => this.CanExecutePlayPauseCommand());
        }
Beispiel #3
0
 private void btnParseSrt_Click(object sender, EventArgs e)
 {
     try
     {
         SrtFile srtFile = new SrtFile(txtAssFile.Text);
         srtFile.SaveAs(txtAssFile.Text + ".2.srt");
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex);
     }
 }
Beispiel #4
0
        private async Task <bool> FileSignatureIsNotTrusted()
        {
            using (var reader = new StreamReader(SrtFile.OpenReadStream()))
            {
                int loopCount = 1;
                int tries     = 5;

                while (!reader.EndOfStream && loopCount < 4)
                {
                    string lineText = await reader.ReadLineAsync();

                    if (int.TryParse(lineText, out int subtitleOrder))
                    {
                        if (subtitleOrder == loopCount)
                        {
                            loopCount++;
                            tries = 5;
                            continue;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (loopCount == 1)
                    {
                        return(true);
                    }
                    else if (tries == 0)
                    {
                        return(true);
                    }
                    else
                    {
                        tries--;
                        continue;
                    }
                }

                return(false);
            }
        }