コード例 #1
0
ファイル: BatchTool.cs プロジェクト: teslazap/sublib1
 private void processfile(FileInfo file)
 {
     if (!isactive)
     {
         return;
     }
     if ((file.Extension == ".mts") || (file.Extension == ".m2ts"))
     {
         try
         {
             String          message      = "   Opening File: " + file.FullName;
             SubGenEventArgs neweventargs = new SubGenEventArgs(message, false, "");
             if (OnSubgenResult != null)
             {
                 OnSubgenResult(this, neweventargs);
             }
             SubFile newvideofile = new SubFile();
             newvideofile.FpsType   = cameratype;
             newvideofile.VideoFile = file.FullName;
             newvideofile.MakeSubTitles();
             newvideofile.RemoveSubTime();
             String filename = "   Processed File: " + file.FullName;
             neweventargs = new SubGenEventArgs(filename, false, "");
             if (OnSubgenResult != null)
             {
                 OnSubgenResult(this, neweventargs);
             }
             if (showsubtime)
             {
                 savesubtitles(file, newvideofile.FullSubOutput);
             }
             else
             {
                 savesubtitles(file, newvideofile.NoTimeSubOutput);
             }
         }
         catch
         {
             String          filename     = "   Error Processing File: " + file.FullName;
             SubGenEventArgs neweventargs = new SubGenEventArgs(filename, true, "");
             if (OnSubgenResult != null)
             {
                 OnSubgenResult(this, neweventargs);
             }
         }
         //
         //  add code to actually generate and save the subtitles in here
         //  try/catch to find errors and trigger appropriate event
         //
         //Thread.Sleep(2000); //to simulate reading a real file - erase when code wired up.
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: teslazap/sublib1
 private void generatesubtitles()
 {
     try
     {
         subtitle_handle.MakeSubTitles();   //calls the c dll, may be slow from large file, hence separate thread
         //subtitle_handle.SplitSubTitles();
         //Thread.Sleep(4000);                   //simulate large file - comment this out when done
         subtitle_handle.RemoveSubTime();        //automatically remove time
         btn_subgen.Invoke((MethodInvoker) delegate()
         {
             rtb_subcontent.Text = subtitle_handle.FullSubOutput;
             //rtb_subcontent.Text = subtitle_handle.NoTimeSubOutput;
             rtb_subcontent.Enabled = true;
             btn_savesubs.Enabled   = true;
             btn_subgen.Enabled     = true;
             cb_timedisp.Enabled    = true;
             //Cursor = Cursors.Default;
         });  //methodinvoker is HANDY!
         //btn_subgen.Invoke(new MethodInvoker (delegate() { rtb_subcontent.Text = subtitle_handle.FullSubOutput; }));  //this also works!
     }
     catch (System.Exception e)
     {
         btn_subgen.Invoke((MethodInvoker) delegate()
         {
             String errormessage = "There is a problem with the video file.\nYou may not have selected a .mts or .m2ts\nfile or it may be corrupt.\n\nThe error type is: " + e.Message;
             MessageBox.Show(errormessage,
                             "File Open Error");
         });
     }
     finally
     {
         btn_subgen.Invoke((MethodInvoker) delegate()
         {
             UseWaitCursor  = false;
             timer1.Enabled = false;
         });
     }
 }