private EncoderInfo [] ReadGridInfo() { Int32 RowIndex = 0; string FileName = null; ArrayList List = new ArrayList(); do { FileName = (string)dataGridView1.Rows[RowIndex].Cells[0].Value; if (!(FileName == "" || FileName == null)) { EncoderInfo Info = new EncoderInfo(); Info.FileNameAndPath = FileName; Info.FilePath = Path.GetDirectoryName(Info.FileNameAndPath) + @"\"; Info.FileName = Path.GetFileName(Info.FileNameAndPath); Info.FileNameNoExtension = Path.GetFileNameWithoutExtension(Info.FileNameAndPath); Info.MessageTitle = (string)dataGridView1.Rows[RowIndex].Cells[1].Value; Info.Description = (string)dataGridView1.Rows[RowIndex].Cells[2].Value; Info.Author = (string)dataGridView1.Rows[RowIndex].Cells[3].Value; List.Add(Info); RowIndex++; } } while (!(FileName == "" || FileName == null)); EncoderInfo [] FileInfo = (EncoderInfo[] )List.ToArray(typeof(EncoderInfo)); return(FileInfo); }
private void CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { if (e.ColumnIndex == 0) { EncoderInfo Info = new EncoderInfo(); GetFileName(ref Info); dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Info.FileNameAndPath; } }
private void EncodeFile(EncodingProfileEnum Profile, EncoderInfo Info) { try { m_CurrentInfo = Info; DateTime Now = DateTime.Now; lblStatus.Text = " Starting to encode " + m_CurrentProfile.ToString() + " Starting time = " + Now.ToLongTimeString(); m_EncodingDone = false; // Create a WMEncoder object. m_Encoder = new WMEncoder(); m_Encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler( OnStateChange); // Retrieve the source group collection. IWMEncSourceGroupCollection SrcGrpColl = m_Encoder.SourceGroupCollection; // Add a source group to the collection. IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1"); // Add a video and audio source to the source group. IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput(Info.FileNameAndPath, "", ""); // Specify a file object in which to save encoded content. SetOutputFileName(Info.FileNameNoExtension); SelectProfile(SrcGrp); // Fill in the description object members. IWMEncDisplayInfo Descr = m_Encoder.DisplayInfo; Descr.Author = Info.Author; Descr.Copyright = "Valley Bible Church @2005"; Descr.Description = Info.Description; Descr.Rating = "All Audiences"; Descr.Title = Info.MessageTitle; // Add an attribute to the collection. IWMEncAttributes Attr = m_Encoder.Attributes; Attr.Add("URL", "IP address"); // Start the encoding process. // Wait until the encoding process stops before exiting the application. m_Encoder.PrepareToEncode(true); m_Encoder.Start(); } catch (Exception e) { lblError.Text = e.ToString(); Debug.WriteLine(e.ToString()); m_CurrentInfo = null; } }
private void GetFileName(ref EncoderInfo Info) { OpenFileDialog FileDialog1 = new OpenFileDialog(); FileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; FileDialog1.FilterIndex = 2; FileDialog1.RestoreDirectory = true; if (FileDialog1.ShowDialog() == DialogResult.OK) { Info.FileNameAndPath = FileDialog1.FileName; Info.FilePath = Path.GetDirectoryName(Info.FileNameAndPath) + @"\"; Info.FileName = Path.GetFileName(Info.FileNameAndPath); Info.FileNameNoExtension = Path.GetFileNameWithoutExtension(Info.FileNameAndPath); } else { Info.FileNameAndPath = ""; } }