Esempio n. 1
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            object o = listView1.SelectedItem;

            if (o == null)
            {
                return;
            }

            JobDetails item = o as JobDetails;

            if (item.IsRunning)
            {
                System.Windows.MessageBox.Show("无法编辑该任务!", "OKEGui", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            SubWindow subWin = new SubWindow(item);

            subWin.ShowDialog();

            if (!tm.UpdateTask(subWin.GetNewTaskDetail()))
            {
                System.Windows.MessageBox.Show("任务更新失败!", "OKEGui", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return;
        }
Esempio n. 2
0
        public bool UpdateTask(JobDetails detail)
        {
            if (!CheckTask(detail))
            {
                return(false);
            }

            if (Int32.Parse(detail.Tid) < 1)
            {
                return(false);
            }

            taskStatus[Int32.Parse(detail.Tid) - 1] = detail;

            return(true);
        }
Esempio n. 3
0
        public SubWindow(JobDetails task)
        {
            InitializeComponent();
            oldInfo = task;

            info             = DeepCopy <JobDetails>(task);
            this.DataContext = info;

            ContainerFormat.Text = info.ContainerFormat;
            VideoFormat.Text     = info.VideoFormat;
            AudioFormat.Text     = info.AudioFormat;

            InputFileList.Items.Add(info.InputFile);

            isAsked = false;
        }
Esempio n. 4
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // 保存更改
            oldInfo = info;

            oldInfo.ContainerFormat = ContainerFormat.Text == "不封装" ? "" : ContainerFormat.Text;
            oldInfo.VideoFormat     = VideoFormat.Text;
            oldInfo.AudioFormat     = AudioFormat.Text;

            // 更新输出文件拓展名
            if (!oldInfo.UpdateOutputFileName())
            {
                System.Windows.MessageBox.Show("格式错误!", "任务详细", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            isAsked = true;
            this.Close();
        }
Esempio n. 5
0
        // TODO: 改为静态
        public /*static*/ string BuildCommandline(JobDetails config, string extractParam)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("/c ");
            sb.Append("\"");
            // 构建vspipe参数
            sb.Append("\"" + vspipePath + "\"");
            sb.Append(" --y4m ");
            sb.Append("\"" + config.InputScript + "\"");
            sb.Append(" - | ");

            // 构建x265参数
            sb.Append("\"" + x265Path + "\"");
            sb.Append(" --y4m " + extractParam + " -o ");
            sb.Append("\"" + new FileInfo(config.InputFile).FullName + ".hevc" + "\" -");
            sb.Append("\"");

            return(sb.ToString());
        }
Esempio n. 6
0
        private void listView1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            object o = listView1.SelectedItem;

            if (o == null)
            {
                return;
            }

            JobDetails item   = o as JobDetails;
            SubWindow  subWin = new SubWindow(item);

            subWin.ShowDialog();

            if (!tm.UpdateTask(subWin.GetNewTaskDetail()))
            {
                System.Windows.MessageBox.Show("任务更新失败!", "任务详细", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return;
        }
Esempio n. 7
0
        public bool CheckTask(JobDetails td)
        {
            if (td.InputScript == "")
            {
                return(false);
            }

            if (td.InputFile == "")
            {
                return(false);
            }

            if (td.EncoderPath == "")
            {
                return(false);
            }

            if (td.EncoderParam == "")
            {
                // 这里只是额外参数,必要参数会在执行任务之前加上
            }

            if (td.OutputFile == "")
            {
                return(false);
            }

            if (td.VideoFormat == "")
            {
                return(false);
            }

            if (td.AudioFormat == "")
            {
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            object o = listView1.SelectedItem;

            if (o == null)
            {
                return;
            }

            JobDetails item = o as JobDetails;

            if (item.IsRunning)
            {
                System.Windows.MessageBox.Show("无法删除该任务!", "OKEGui", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (!tm.DeleteTask(item))
            {
                System.Windows.MessageBox.Show("任务删除失败!", "OKEGui", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return;
        }
Esempio n. 9
0
        private void WizardFinish(object sender, RoutedEventArgs e)
        {
            // 检查输入脚本是否为oke模板
            var isTemplate = wizardInfo.VSScript.Contains("#OKE:INPUTFILE");

            // 使用正则解析模板, 多行忽略大小写
            Regex r             = new Regex("#OKE:INPUTFILE([\\n\\r ]+\\w+[ ]*=[ ]*)([r]*[\"'].+[\"'])", RegexOptions.Multiline | RegexOptions.IgnoreCase);
            var   inputTemplate = r.Split(wizardInfo.VSScript);

            if (inputTemplate.Length < 4 && wizardInfo.InputFile.Count() > 1)
            {
                System.Windows.MessageBox.Show("任务创建失败!添加多个输入文件请确保VapourSynth脚本使用OKE提供的模板。", "新建任务向导", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // 处理DEBUG标签
            // TODO: 是否进行调试输出
            if (wizardInfo.VSScript.Contains("#OKE:DEBUG") && true)
            {
                Regex dr       = new Regex("#OKE:DEBUG([\\n\\r ]+\\w+[ ]*=[ ]*)(\\w+)", RegexOptions.Multiline | RegexOptions.IgnoreCase);
                var   debugTag = dr.Split(inputTemplate[3]);
                if (debugTag.Length < 4)
                {
                    // error
                    System.Windows.MessageBox.Show("Debug标签语法错误!", "新建任务向导", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                inputTemplate[3] = debugTag[0] + debugTag[1] + "None" + debugTag[3];
            }

            // 新建任务
            // 1、新建脚本文件
            // 2、新建任务参数
            foreach (var inputFile in wizardInfo.InputFile)
            {
                // 新建文件(inputname.m2ts-mm-dd-HH-MM.vpy)
                string vpy = inputTemplate[0] + inputTemplate[1] + "r'" +
                             inputFile + "'" + inputTemplate[3];

                DateTime time = DateTime.Now;

                string fileName = inputFile + "-" + time.ToString("MMddHHmm") + ".vpy";
                System.IO.File.WriteAllText(fileName, vpy);

                var        finfo = new System.IO.FileInfo(inputFile);
                JobDetails td    = new JobDetails();
                td.TaskName = finfo.Name;
                if (wizardInfo.TaskNamePrefix != "")
                {
                    td.TaskName = wizardInfo.TaskNamePrefix + "-" + td.TaskName;
                }

                td.InputScript = fileName;

                td.EncoderPath  = wizardInfo.EncoderPath;
                td.EncoderParam = wizardInfo.EncoderParam;
                td.InputFile    = inputFile;

                td.ContainerFormat = wizardInfo.ContainerFormat;
                td.VideoFormat     = wizardInfo.VideoFormat;
                td.AudioFormat     = wizardInfo.AudioFormat;

                td.IncludeSub = wizardInfo.IncludeSub;

                foreach (var audio in wizardInfo.AudioTracks)
                {
                    td.AudioTracks.Add(audio);
                }

                // 更新输出文件拓展名
                if (!td.UpdateOutputFileName())
                {
                    System.Windows.MessageBox.Show("格式错误!", "新建任务向导", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                td.IsExtAudioOnly = false;

                tm.AddTask(td);
            }
        }
Esempio n. 10
0
 public bool DeleteTask(JobDetails detail)
 {
     return(this.DeleteTask(detail.Tid));
 }