Exemplo n.º 1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (ds == null)
                {
                    MyCallback pVideo = new MyCallback(tbVideo, tbTime, tbElapsed, progressBar1);
                    MyCallback pAudio = new MyCallback(tbAudio);

                    // FPS, BPP, Width, Height
                    ds = new DESCombine(30, 24, 320, 240);

                    foreach (Chunk c in listBox1.Items)
                    {
                        if (c.sVideoFile == c.sAudioFile)
                        {
                            ds.AddAVFile(c.sVideoFile, c.lStart, c.lEnd);
                        }
                        else
                        {
                            if (c.sVideoFile != null)
                            {
                                ds.AddVideoFile(c.sVideoFile, c.lStart, c.lEnd);
                            }

                            if (c.sAudioFile != null)
                            {
                                ds.AddAudioFile(c.sAudioFile, c.lStart, c.lEnd);
                            }
                        }
                    }

                    if (rbToScreen.Checked)
                    {
                        ds.RenderToWindow(IntPtr.Zero, pVideo, pAudio);
                    }
                    else if (rbToAVI.Checked)
                    {
                        IBaseFilter ibfVideoCompressor = GetVideoCompressor(tbCompressor.Text);
                        ds.RenderToAVI(tbOutput.Text, ibfVideoCompressor, null, pVideo, pAudio);
                    }
                    else
                    {
                        MessageBox.Show("Programming error");
                    }

                    if (cbShowXML.Checked)
                    {
                        MessageBox.Show(ds.GetXML(), "XML representation of the DES graph");
                    }

                    ds.Completed     += new EventHandler(Completed);
                    ds.FileCompleted += new EventHandler(FileCompleted);

                    ds.StartRendering();

                    groupBox2.Enabled    = false;
                    progressBar1.Maximum = (int)(ds.MediaLength / (DESCombine.UNITS / 10));
                    progressBar1.Step    = progressBar1.Maximum / 20;
                    progressBar1.Value   = 0;
                    tbStatus.Text        = "Running";
                    button1.Text         = "Cancel";
                }
                else
                {
                    ds.Cancel();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ds.Dispose();
                ds = null;
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (ds == null)
                {
                    MyCallback pVideo = new MyCallback(tbVideo, tbTime, tbElapsed, progressBar1);
                    MyCallback pAudio = new MyCallback(tbAudio);

                    // FPS, BPP, Width, Height
                    ds = new DESCombine(30, 24, 320, 240);

                    foreach (Chunk c in listBox1.Items)
                    {
                        if (c.sVideoFile == c.sAudioFile)
                        {
                            ds.AddAVFile(c.sVideoFile, c.lStart, c.lEnd);
                        }
                        else
                        {
                            if (c.sVideoFile != null)
                            {
                                ds.AddVideoFile(c.sVideoFile, c.lStart, c.lEnd);
                            }

                            if (c.sAudioFile != null)
                            {
                                ds.AddAudioFile(c.sAudioFile, c.lStart, c.lEnd);
                            }
                        }
                    }

                    if (rbToScreen.Checked)
                    {
                        ds.RenderToWindow(IntPtr.Zero, pVideo, pAudio);
                    }
                    else if (rbToAVI.Checked)
                    {
                        IBaseFilter ibfVideoCompressor = GetVideoCompressor(tbCompressor.Text);
                        ds.RenderToAVI(tbOutput.Text, ibfVideoCompressor, null, pVideo, pAudio);
                    }
                    else
                    {
                        MessageBox.Show("Programming error");
                    }

                    if (cbShowXML.Checked)
                    {
                        MessageBox.Show(ds.GetXML(), "XML representation of the DES graph");
                    }

                    ds.Completed += new EventHandler(Completed);
                    ds.FileCompleted += new EventHandler(FileCompleted);

                    ds.StartRendering();

                    groupBox2.Enabled = false;
                    progressBar1.Maximum = (int)(ds.MediaLength / (DESCombine.UNITS / 10));
                    progressBar1.Step = progressBar1.Maximum / 20;
                    progressBar1.Value = 0;
                    tbStatus.Text = "Running";
                    button1.Text = "Cancel";
                }
                else
                {
                    ds.Cancel();
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ds.Dispose();
                ds = null;
            }
        }