void newOriginalFunction() { originalFile = new SubtitlesFile(SubtitlesFile.WhichText.Original); subtitleList = originalFile.createNewSubtitles(subtitleList); translationFile = null; if (video.IsLoaded) { StopVideo(); } }
void cmdBindingNewTranslation_Executed(object sender, ExecutedRoutedEventArgs e) { translationFile = new SubtitlesFile(SubtitlesFile.WhichText.Translation); Subtitles translationSubtitles = translationFile.createNewSubtitles(null); foreach (Subtitle sub in subtitleList) { sub.Translation = Properties.Settings.Default.newTranslationText; } showColumns(); }
void cmdBindingOpenTranslation_Executed(object sender, ExecutedRoutedEventArgs e) { translationFile = new SubtitlesFile(SubtitlesFile.WhichText.Translation); if (translationFile.getOpenFileName("Choose translation subtitles")) { Subtitles translationSubtitles = translationFile.fileOpen(null); addTranslation(translationSubtitles); showColumns(); } }
void cmdBindingOpenOriginal_Executed(object sender, ExecutedRoutedEventArgs e) { if (savedAllChanged()) { // if user cancel the selection the original remains unchanged SubtitlesFile newOriginalFile = new SubtitlesFile(SubtitlesFile.WhichText.Original); if (!newOriginalFile.getOpenFileName("Choose original subtitles")) { return; } newOriginalFunction(); originalFile = newOriginalFile; subtitleList = originalFile.fileOpen(subtitleList); videoFile = getVideoFileFromSubtitle(originalFile.FileName); if (videoFile != null) { video.Source = new Uri(videoFile, UriKind.Relative); } showColumns(); } }
public MainWindow() { string org = null; string trans = null; string vid = null; string proj = null; string[] arg = Environment.GetCommandLineArgs(); if (arg.Length > 1) { if (arg[1] == "/h" || arg[1] == "/?") { Console.WriteLine("SFKSubEditor [project|original [translation] [movie]]"); Console.WriteLine("project - project file"); Console.WriteLine("original - original subtitles"); Console.WriteLine("translation - translation subtitles"); Console.WriteLine("video - video file"); Application.Current.Shutdown(); Environment.Exit(0); } if (arg[1].Substring(arg[1].LastIndexOf(".") + 1) == MainWindow.projectFileExtension) { proj = arg[1]; } else { org = arg[1]; } if (arg.Length > 2) { trans = arg[2]; } if (arg.Length > 3) { vid = arg[3]; } } InitializeComponent(); InitializeCommands(); if (org != null) { originalFile = new SubtitlesFile(SubtitlesFile.WhichText.Original, org); subtitleList = originalFile.fileOpen(subtitleList); if (trans != null) { translationFile = new SubtitlesFile(SubtitlesFile.WhichText.Translation, trans); Subtitles translationSubtitles = translationFile.fileOpen(null); addTranslation(translationSubtitles); } if (vid != null) { videoFile = vid; video.Source = new Uri(videoFile, UriKind.Relative); } else { videoFile = getVideoFileFromSubtitle(originalFile.FileName); if (videoFile != null) { video.Source = new Uri(videoFile, UriKind.Relative); } } } else if (proj != null) { } else { // from the beginning we have new subtitles newOriginalFunction(); } dataGrid1.ItemsSource = subtitleList; dataGrid1.DataContext = subtitleList; showColumns(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(50); timer.Tick += new EventHandler(timer_Tick); PlayVideo(); }
/// <summary> /// Write srt subtitles to file. If already exists is overwritten. /// IO error has to be catch in upper levels. /// </summary> /// <param name="file">File with subtitles (full path).</param> /// <param name="encoding">Encoding of file.</param> /// <param name="subAList">List with subtitles.</param> void ISubFile.WriteSubFile(String fileName, Encoding fileEncoding, BindingList<Subtitle> subList, SubtitlesFile.WhichText what) { using (StreamWriter sw = new StreamWriter(fileName, false, fileEncoding, 32000)) { String[] lines; int i = 1; foreach (Subtitle sub in subList) { sw.WriteLine(i); sw.WriteLine(sub.TimeBegin.ToString("hh':'mm':'ss','fff") + " --> " + sub.TimeEnd.ToString("hh':'mm':'ss','fff")); if (what == SubtitlesFile.WhichText.Original) lines = sub.Original.Split('|'); else lines = sub.Translation.Split('|'); for (int j = 0; j < lines.Length; j++) { sw.WriteLine(lines[j]); } sw.WriteLine(); i++; } } }
void cmdBindingOpenOriginal_Executed(object sender, ExecutedRoutedEventArgs e) { if (savedAllChanged()) { // if user cancel the selection the original remains unchanged SubtitlesFile newOriginalFile = new SubtitlesFile(SubtitlesFile.WhichText.Original); if (!newOriginalFile.getOpenFileName("Choose original subtitles")) return; newOriginalFunction(); originalFile = newOriginalFile; subtitleList = originalFile.fileOpen(subtitleList); videoFile = getVideoFileFromSubtitle(originalFile.FileName); if (videoFile != null) video.Source = new Uri(videoFile, UriKind.Relative); showColumns(); } }
void newOriginalFunction() { originalFile = new SubtitlesFile(SubtitlesFile.WhichText.Original); subtitleList = originalFile.createNewSubtitles(subtitleList); translationFile = null; if (video.IsLoaded) StopVideo(); }
/// <summary> /// Write sub subtitles to the file. /// IO error has to be catch in upper levels. /// </summary> /// <param name="file">File with subtitles (full path).</param> /// <param name="encoding">Encoding of file.</param> /// <param name="subAList">List with subtitles.</param> void ISubFile.WriteSubFile(String fileName, Encoding fileEncoding, BindingList<Subtitle> subList, SubtitlesFile.WhichText what) { float unit = 1000 / FrameRate; using (StreamWriter sw = new StreamWriter(fileName, false, fileEncoding,32000)) { // first line of the file is famerate - begin and end is 1 sw.WriteLine("{1}{1}" + FrameRate.ToString("0.000", new CultureInfo("en-US"))); foreach (Subtitle sub in subList) { if (what == SubtitlesFile.WhichText.Original) sw.WriteLine("{" + timeSpanToFrame(sub.TimeBegin, FrameRate, unit) + "}{" + timeSpanToFrame(sub.TimeEnd, FrameRate, unit) + "}" + sub.Original); else sw.WriteLine("{" + timeSpanToFrame(sub.TimeBegin, FrameRate, unit) + "}{" + timeSpanToFrame(sub.TimeEnd, FrameRate, unit) + "}" + sub.Translation); } } }
public MainWindow() { string org = null; string trans = null; string vid = null; string proj = null; string[] arg = Environment.GetCommandLineArgs(); if (arg.Length > 1) { if (arg[1] == "/h" || arg[1] == "/?") { Console.WriteLine("SFKSubEditor [project|original [translation] [movie]]"); Console.WriteLine("project - project file"); Console.WriteLine("original - original subtitles"); Console.WriteLine("translation - translation subtitles"); Console.WriteLine("video - video file"); Application.Current.Shutdown(); Environment.Exit(0); } if (arg[1].Substring(arg[1].LastIndexOf(".") + 1) == MainWindow.projectFileExtension) proj = arg[1]; else org = arg[1]; if (arg.Length > 2) trans = arg[2]; if (arg.Length > 3) vid = arg[3]; } InitializeComponent(); InitializeCommands(); if (org != null) { originalFile = new SubtitlesFile(SubtitlesFile.WhichText.Original,org); subtitleList = originalFile.fileOpen(subtitleList); if (trans != null) { translationFile = new SubtitlesFile(SubtitlesFile.WhichText.Translation,trans); Subtitles translationSubtitles = translationFile.fileOpen(null); addTranslation(translationSubtitles); } if (vid != null) { videoFile = vid; video.Source = new Uri(videoFile,UriKind.Relative); } else { videoFile = getVideoFileFromSubtitle(originalFile.FileName); if (videoFile != null) { video.Source = new Uri(videoFile, UriKind.Relative); } } } else if (proj != null) { } else { // from the beginning we have new subtitles newOriginalFunction(); } dataGrid1.ItemsSource = subtitleList; dataGrid1.DataContext = subtitleList; showColumns(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(50); timer.Tick += new EventHandler(timer_Tick); PlayVideo(); }