Ejemplo n.º 1
0
        private void AddToQueue(FileSystemEventArgs e, ExtentionType extentionType)
        {
            bool seenBefore = HashCheck.DoCheck(e.FullPath);

            if (!seenBefore)
            {
                //Create Media Item for Queue
                MediaFile mediaFile = new MediaFile
                {
                    DtDateTimeStamp   = DateTime.Now,
                    ConversionType    = extentionType,
                    StrName           = e.Name,
                    StrOriginFilePath = e.FullPath,
                    StrOutputFilePath = GetCustomFolder(e, ChkCustomOutput.Checked),
                    Hash     = HashCheck.GetHash(e),
                    Progress = 10
                };

                _conversionQueue.Enqueue(mediaFile);

                dgvQueue.BeginInvoke((Action)(() =>
                {
                    if (dgvQueue.Rows.Count < 0)
                    {
                        SetupGrid();
                    }
                    dgvQueue.DataSource = _conversionQueue.ToList();
                }));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes changes to watch folder
        /// </summary>
        /// <param name="e"></param>
        private void ChangeDetected(FileSystemEventArgs e)
        {
            if (RbtnMKVtoMP4.Checked)
            {
                _outputExtension = ExtentionType.Mp4;
            }

            if (e.ChangeType == WatcherChangeTypes.Created || e.ChangeType == WatcherChangeTypes.Changed)
            {
                AddToQueue(e, _outputExtension);

                //If file is folder
                if (Directory.Exists(e.FullPath))
                {
                    //Get files from folder
                    foreach (string file in Directory.GetFiles(e.FullPath))
                    {
                        _outputFile = GetCustomFolder(e, ChkCustomOutput.Checked);

                        if (file.EndsWith(".mkv")) //if file is a .mkv
                        {
                            bool seenBefore = HashCheck.DoCheck(file);

                            if (!seenBefore)
                            {
                                //If convert to MKV option checked
                                if (RbtnMKVtoMP4.Checked)
                                {
                                    ConvertToMp4(file, _outputFile);
                                }
                            }
                        }
                        else
                        {
                            //Recursively look into other folders and repeat
                            var eventArgs = new FileSystemEventArgs(
                                WatcherChangeTypes.Created,
                                Path.GetDirectoryName(file),
                                Path.GetFileName(file));
                            ChangeDetected(eventArgs);
                        }
                    }
                }

                else
                {
                    //single file (not in folder)
                    if (e.ChangeType == WatcherChangeTypes.Created || e.ChangeType == WatcherChangeTypes.Changed)
                    {
                        bool seenBefore = HashCheck.DoCheck(e.FullPath);

                        if (!seenBefore)
                        {
                            _outputFile = GetCustomFolder(e, ChkCustomOutput.Checked);

                            //If convert to MKV option checked
                            if (RbtnMKVtoMP4.Checked)
                            {
                                ConvertToMp4(e.FullPath, _outputFile);
                                LogFile(e);
                            }
                        }
                    }
                }
            }
        }