private void LoadSubtitleFile(string fileName) { SubtitleFile newSubFile; try { newSubFile = new SubtitleFile(fileName); //subfile.SaveXml("c:\\temp\\test.xml"); } catch (SUPFileFormatException) { MessageBox.Show("Couldn't open the file\n" + fileName + ".\nMaybe it's not a BluRay .sup file?\nStandard resolution DVD and HD DVD subtitles aren't supported.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); newSubFile = null; } catch (IOException e) { MessageBox.Show("Couldn't open the file\n" + fileName + "\nbecause of \n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); newSubFile = null; } catch (Exception e) { ErrorForm form = new ErrorForm(e); form.ShowDialog(); newSubFile = null; } if (newSubFile != null) { //If the new file has been loaded successfully, dispose of the old one if (subfile != null) { subfile.Close(); } subfile = newSubFile; nextButton.Enabled = true; previousButton.Enabled = true; autoOCRButton.Enabled = true; ocrButton.Enabled = true; letterOKButton.Enabled = true; saveButton.Enabled = true; subtitleType.Text = "Bluray"; /*else if (subfile.Type == SubtitleFile.SubtitleType.Scenarist) * subtitleType.Text = "Scenarist";*/ currentNum = 0; #if DEBUG currentNum = 17; #endif currentSubtitle = LoadSubtitleImage(currentNum); UpdateTextBox(); totalPages.Text = "/ " + subfile.NumSubtitles; UpdateBitmaps(); // Update the window title Text = "SupRip " + version + " - " + fileName.Substring(fileName.LastIndexOf('\\') + 1); } }
static void Main(string[] args) { //Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length >= 1) { //SubtitleFile subfile = new SubtitleFile("F:\\hdrip\\hb.sup"); //subfile.WriteBitmap("c:\\temp\\test.png", 20); SubtitleFile subfile = new SubtitleFile(args[0]); int nb = 20; if (args.Length >= 2) { nb = Int32.Parse(args[1]); } int spacing = 100; if (args.Length >= 3) { spacing = Int32.Parse(args[2]); } try { subfile.WriteBitmaps(args[0], nb, spacing); } catch (Exception e) { Console.WriteLine("exception " + e.Message); } } else { #if DEBUG Application.Run(new MainForm()); #else try { Application.Run(new MainForm()); } catch (Exception e) { ErrorForm form = new ErrorForm(e); form.ShowDialog(); } #endif } }