private void watcher_EventArrived(object sender, EventArrivedEventArgs e) { var wmiDevice = (ManagementBaseObject)e.NewEvent["TargetInstance"]; var volName = wmiDevice.Properties["VolumeName"].Value; if (volName != null) { _diskName = wmiDevice.Properties["VolumeName"].Value.ToString(); _driveLetter = wmiDevice.Properties["Name"].Value.ToString(); lbl_diskRead.Invoke( (Action) delegate { lbl_diskRead.Text = Resources.Form1_watcher_EventArrived_Ripping_DVD_ + _diskName; }); if ((Properties.Settings.Default.pathToMakeMKV != "") && Directory.Exists(_driveLetter + "/VIDEO_TS")) { JackTheRipper.RunWorkerAsync(new RunDataForRipper { DriveName = _driveLetter, MovieName = CleaningFunctions.MakeValidFileName(_diskName) }); } } else { lbl_diskRead.Invoke( (Action) delegate { lbl_diskRead.Text = Resources.Form1_watcher_EventArrived_Disk_ejected_; }); } }
private void JackTheRipper_DoWork(object sender, DoWorkEventArgs e) { _jackTheRipperIsFinished = false; var ripperData = (RunDataForRipper)e.Argument; //make sure the destination exists Directory.CreateDirectory(Properties.Settings.Default.tempFiles + "/" + ripperData.MovieName); var lockfile = File.Create(Properties.Settings.Default.tempFiles + "/" + ripperData.MovieName + "/" + "lockfile"); lockfile.Close(); var proc = new Process { StartInfo = new ProcessStartInfo { FileName = Properties.Settings.Default.pathToMakeMKV, Arguments = "--r --decrypt --progress=-same --directio=true --minlength=" + Properties.Settings.Default.minTitleTimeToRip + " mkv disc:0 all " + Properties.Settings.Default.tempFiles + "/" + ripperData.MovieName, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; //Create a lock file - need to lock it out so that Encoder wont touch it proc.Start(); while (!proc.StandardOutput.EndOfStream) { var line = proc.StandardOutput.ReadLine(); // PRGV:62,62,65536 is the progress update var progress = 0; if ((line != null) && line.Contains("PRGV")) { progress = GetProgress(ref line); } JackTheRipper.ReportProgress(progress, line); if (JackTheRipper.CancellationPending) { break; } } if (JackTheRipper.CancellationPending) { proc.Kill(); } // We are done! EjectMedia.Eject(@"\\.\" + _driveLetter); File.Delete(Properties.Settings.Default.tempFiles + "/" + ripperData.MovieName + "/" + "lockfile"); var alertWindow = new Notification(e.Cancel ? "Rip process was canceled" : "Finished Rip Process!"); alertWindow.Left = Screen.PrimaryScreen.Bounds.Width - alertWindow.Width; alertWindow.Top = Screen.PrimaryScreen.Bounds.Height - alertWindow.Height; alertWindow.Show(); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { _watcher.Stop(); RawVideoChecker.Stop(); EncodingOnTheFly.CancelAsync(); JackTheRipper.CancelAsync(); while (!_jackTheRipperIsFinished || !_diskEncoderIsFinished) { Thread.Sleep(50); } }