Beispiel #1
0
        /// <summary>Deletes one or more files.</summary>
        /// <param name="FilePattern">The name of a single file or a wildcard pattern such as C:\Temp\*.tmp. FilePattern is assumed to be in %A_WorkingDir% if an absolute path isn't specified.</param>
        /// <param name="PromptUser">Option to Prompt User with Yes/No PopUp Dialog Before Deleting (Default = False)</param>
        public static bool FileDelete(this string FilePattern, bool PromptUser = false)
        {
            _AHK ahk = new _AHK();

            return(ahk.FileDelete(FilePattern, PromptUser));
        }
Beispiel #2
0
            /// <summary>
            /// FFMpeg Create Preview Images From Video Dir
            /// </summary>
            /// <param name="VideoDir"></param>
            /// <param name="SaveDir"></param>
            public void VideoScreenCaps(string VideoDir, ProgressBar progressB, bool NewThread = true, string SaveDir = "", int TilesWide = 3, int TilesTall = 3, string Scale = "320:240", string SaveFormat = "jpg", bool OverWriteExisting = false, string CaptureOpt = "1000")
            {
                if (NewThread)
                {
                    Thread newThread = new Thread(() => VideoScreenCaps(VideoDir, progressB, false, SaveDir, TilesWide, TilesTall, Scale, SaveFormat, OverWriteExisting, CaptureOpt));
                    thr.Start(newThread, "VidThread");
                    //newThread.Start();
                }
                else
                {
                    // string videoFilePath, string saveDir = "", int TilesWide = 3, int TilesTall = 3, string Scale = "320:240", string SaveFormat = "jpg"

                    if (!pathDefined)
                    {
                        pathDefined = FFMpeg_DefinePaths(); if (!pathDefined)
                        {
                            return;
                        }
                    }


                    List <string> files = new List <string>();

                    if (ahk.isFile(VideoDir))
                    {
                        files.Add(VideoDir);
                    }
                    else
                    {
                        files = lst.FileList(VideoDir, "*.*", true, false, true);
                    }

                    if (progressB.InvokeRequired)
                    {
                        progressB.BeginInvoke((MethodInvoker) delegate() { progressB.Maximum = files.Count(); });
                    }
                    else
                    {
                        progressB.Maximum = files.Count();
                    }


                    SaveDir = VideoDir + "\\Previews";

                    Dir_Watch(SaveDir);  // monitor dir for new images and display as created

                    Stopwatch watch = new Stopwatch();

                    int i = 0;
                    foreach (string file in files)
                    {
                        watch.Start();
                        sb(file);

                        i++; sb(i + "/" + files.Count.ToString(), 2);
                        if (progressB.InvokeRequired)
                        {
                            progressB.BeginInvoke((MethodInvoker) delegate() { progressB.Value = i; });
                        }
                        else
                        {
                            progressB.Value = i;
                        }

                        ahk.DisplayText(ahk.FileName(file) + " | " + i + "/" + files.Count, txtCurrentProgress);

                        // calculate time left until folder completed

                        // number of files left in dir to vidCap    // reemaining jobs times last job time = time remaining
                        int      remaining = files.Count() - i; remaining = remaining * lastJobTime;
                        TimeSpan t         = TimeSpan.FromSeconds(remaining);
                        string   remains   = t.TotalMinutes.ToString();
                        if (txtRemainingMin.InvokeRequired)
                        {
                            txtRemainingMin.BeginInvoke((MethodInvoker) delegate() { txtRemainingMin.Text = remains + " Min Left"; });
                        }
                        else
                        {
                            txtRemainingMin.Text = remains + " Min Left";
                        }


                        // check to see if preview image already exists
                        string PreviewImage = SaveDir + "\\" + ahk.FileNameNoExt(file) + "." + SaveFormat;


                        if (!OverWriteExisting)
                        {
                            if (!File.Exists(PreviewImage))
                            {
                                sb("Generating Video Preview Image... " + ahk.FileName(PreviewImage));
                                string previewImg = VidCap_Tiles(file, "", TilesWide, TilesTall, Scale, SaveFormat, CaptureOpt);

                                //if (pictureBox != null) { pictureBox.Image = previewImg.ToImg(); }  // display preview image if viewer visible
                            }
                        }
                        else
                        {
                            ahk.FileDelete(PreviewImage);
                            sb("Generating Video Preview Image... " + ahk.FileName(PreviewImage));
                            string previewImg = VidCap_Tiles(file, "", TilesWide, TilesTall, Scale, SaveFormat, CaptureOpt);

                            //if (pictureBox != null) { pictureBox.Image = previewImg.ToImg(); }  // display preview image if viewer visible
                        }



                        string stopWatchTime = watch.Elapsed.Seconds.ToString(); lastJobTime = watch.Elapsed.Seconds;
                        ahk.DisplayText(stopWatchTime + " seconds", txtJobTimeDisp);
                        watch.Reset();
                    }

                    ahk.OpenDir(SaveDir);
                    ahk.MsgBox("Finished Creating VideoScreenCaps");
                }
            }