Ejemplo n.º 1
0
        private void ConvertProgress(object parameters)
        {
            TextLog("--------------------------------------");
            TextLog("正在转换第【 " + (tempNow++) + " 】个视频......");
            var     item = (VideoMp4)parameters;
            Process p    = new Process();

            p.StartInfo.FileName = cmdPath;

            p.StartInfo.Arguments             = item.CmdString;
            p.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
            p.StartInfo.UseShellExecute       = false;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow        = true;
            //p.ErrorDataReceived += new DataReceivedEventHandler(Log);
            p.Start();
            p.BeginErrorReadLine();
            p.WaitForExit();
            p.Close();

            iCount--;
            if (iCount < 0)
            {
                iCount = 0;
            }
            iNow++;
            TextLog("第【 " + iNow + " 】个视频转换完成。");
            LogHelper.AddEventLog("第【 " + iNow + "】个视频转换完成。");
            TextLog(item);
            if (iNow == iAmount)
            {
                TextLog("视频转换完成,共完成 " + iAmount + " 个视频的转换。");
                LogHelper.AddEventLog("视频转换完成,共完成 " + iAmount + " 个视频的转换。");
                EnableButton();
            }

            //进度条
            this.Dispatcher.Invoke(new Action(delegate
            {
                var jindu = Math.Round((iNow / pb.Maximum * 1.0), 2) * 100;

                this.pb.Value = iNow;
                this.tb.Text  = jindu + "%";
                Thread.Sleep(10);
            }));

            p.Dispose();
        }
Ejemplo n.º 2
0
        private void TextLog(VideoMp4 item)
        {
            if (this.Dispatcher.CheckAccess())
            {
                //ignore
            }
            else
            {
                this.Dispatcher.Invoke(new Action(delegate
                {
                    LogTextBox.Text += "转换完成,生成文件" + item.NewFileName + "\n";
                    LogTextBox.Text += "文件路径为" + item.NewFilePath + "\n";

                    LogHelper.AddEventLog("转换完成,生成文件" + item.NewFileName + "\n");
                    LogHelper.AddEventLog("文件路径为" + item.NewFilePath + "\n");
                }));
            }
        }