示例#1
0
        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();
        }
示例#2
0
 private static void EjectAllCDs()
 {
     foreach (var drive in DriveInfo.GetDrives())
     {
         if (drive.DriveType == DriveType.CDRom)
         {
             EjectMedia.Eject(@"\\.\" + drive.Name.Replace('\\', ' ').TrimEnd());
         }
     }
 }