Ejemplo n.º 1
0
        private void convertFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();

            save.Title  = "Save as";
            save.Filter = "Media file|*.mp4";

            DialogResult rst = save.ShowDialog(this);

            if (rst == DialogResult.OK)
            {
                FileInfo file = new FileInfo(save.FileName);
                bool     err  = false;
                if (file.Exists)
                {
                    if (file.FullName.Equals(this.wmp.URL, StringComparison.OrdinalIgnoreCase))
                    {
                        // cannot save as playing file
                        err = true;
                    }
                }
                if (!err)
                {
                    this.convertFileToolStripMenuItem.Enabled = false;

                    // start convert file
                    this.convertor            = new MediaConvert();
                    this.convertor.Completed += new CompleteEventHandler(convert_Completed);
                    this.convertor.Progress  += new ProgressEventHandler(convert_Progress);
                    this.convertor.Convert(new FileInfo(this.wmp.currentMedia.sourceURL), file);

                    // show progress window
                    frmConvert frm = new frmConvert();
                    frm.FormClosing += new FormClosingEventHandler(frmConvertClosing);
                    Point p = this.wmp.PointToScreen(this.wmp.Location);
                    frm.Top   = p.Y;
                    frm.Left  = p.X;
                    frm.Owner = this;
                    frm.Show();
                    this.progresswindow = frm;
                }
            }
        }
Ejemplo n.º 2
0
        private void convert_Completed(object sender, bool success)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action <object, bool>(convert_Completed), sender, success);
                return;
            }
            this.Text      = Properties.Resources.title;
            this.convertor = null;
            this.convertFileToolStripMenuItem.Enabled = true;

            if (this.progresswindow != null)
            {
                this.progresswindow.FormClosing -= frmConvertClosing;
                this.progresswindow.Close();
                this.progresswindow = null;
            }

            if (!success)
            {
                MessageBox.Show(this, Properties.Resources.err_msg_convert, Properties.Resources.err_title_convert, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }