コード例 #1
0
        // !!点击开始转换
        private void StartBtn_Click(object sender, EventArgs e)
        {
            if (this.fileListView.Items.Count == 0)
            {
                string noFileMsg = "未添加任何文件";
                MessageBox.Show(noFileMsg);
            }
            else
            {
                if (checkSettingChange() == -1)
                {
                    MessageBox.Show("一个或多个任务的预设已被删除,请重新添加预设!");
                    return;
                }

                if (checkSettingChange() == 1) // 1为真,表示有变化
                {
                    string       note = "检测到预设已修改,是否覆盖当前选中的预设?\n点击“确定”将覆盖并应用该预设到全部任务。点击“取消”将中止任务且不做改动。";
                    DialogResult dr   = MessageBox.Show(note, "检测到预设修改", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (dr == DialogResult.OK)
                    {
                        //点确定的代码
                        saveSetting2File(this.encodeSettingCB.Text);
                        readAllSettingsFromFiles();

                        for (int i = 0; i < this.fileListView.Items.Count; i++)
                        {
                            fileListView.Items[i].SubItems[1].Text = this.encodeSettingCB.Text;
                        }
                    }
                    else
                    {
                        //点取消的代码
                        return;
                    }
                }

                int             count = fileListView.Items.Count;
                filePathStorage q     = new filePathStorage(count);
                for (int i = 0; i < count; i++)
                {
                    if (!CheckSettingExist(fileListView.Items[i].SubItems[1].Text))
                    {
                        MessageBox.Show("一个或多个任务的预设已被删除,请检查编码设置!");
                        return;
                    }

                    // subitems[2]中保存着完整文件名
                    videoTask t = new videoTask(fileListView.Items[i].SubItems[2].Text, fileListView.Items[i].SubItems[1].Text);
                    q.add(t);
                }

                this.j = new Job(q);
                //this.j.ErrorEvent += DisposeJob;
                this.j.runJob(this.outputFilePathTB.Text);
            }
        }
コード例 #2
0
        private void addFileBtn_Click(object sender, EventArgs e)
        {
            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);  // 默认打开显示我的文档
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = false;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            // Insert code to read the stream here.
                            String fp = openFileDialog1.FileName;
                            fileListlB.Items.Add(fp);

                            Thread storageThread = new Thread(() =>
                            {
                                // TODO:
                                q.add(fp);
                            });
                            storageThread.Start();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }