private void LoadOGM(String filename) { StreamReader sr = new StreamReader(filename); //Empty the chapter list chapterList.Clear(); //Define a chapter object VideoChapter chap = null; while (!sr.EndOfStream) { String line = sr.ReadLine(); if (line != String.Empty) { if (line.Contains(":")) { chap = new VideoChapter(); String[] elements = line.Split(new String[] { "=" }, StringSplitOptions.None); chap.StartTime = elements[1].Trim(); } else { String[] elements = line.Split(new String[] { "=" }, StringSplitOptions.None); chap.Name = elements[1].Trim(); chapterList.Add(chap); chap = null; } } } //Close the file sr.Close(); }
private void listChapters_SelectedIndexChanged(object sender, EventArgs e) { try { //Ensure a valid item is selected if (lstChapters.SelectedIndex >= 0) { //First clear the details clearDetails(false); //Now fill the form with the data read _TempChapter = _ChapterEditor.ChapterList[lstChapters.SelectedIndex]; txtStartTime.Text = _TempChapter.StartTime; txtEndTime.Text = _TempChapter.EndTime; txtName.Text = _TempChapter.Name; txtUID.Text = _TempChapter.UID; chkEnabled.Checked = _TempChapter.Enabled; chkHidden.Checked = _TempChapter.Hidden; refreshLanguageList(); //Set tooltip Tooltip.SetToolTip(lstChapters, _TempChapter.ToString()); //Set flag _IsLoaded = true; } } catch (Exception ex) { ShowExceptionMessage(ex); } }
private void btnUpdateChapter_Click(object sender, EventArgs e) { try { //Check if an existing chapter is selected if (lstChapters.SelectedIndex >= 0) { VideoChapter chap = _ChapterEditor.ChapterList[lstChapters.SelectedIndex]; chap.Enabled = chkEnabled.Checked; chap.EndTime = txtEndTime.Text; chap.Hidden = chkHidden.Checked; chap.Name = txtName.Text; chap.StartTime = txtStartTime.Text; chap.UID = txtUID.Text; //Set Display list chap.DisplayList = _TempChapter.DisplayList; //Clear all the form fields and the Temp object clearDetails(true); //Refresh the chapter list refreshChapterList(); _IsLoaded = false; ShowSuccessMessage("Chapter was updated properly!"); } } catch (Exception ex) { ShowExceptionMessage(ex); } }
private void btnAddChapter_Click(object sender, EventArgs e) { try { //Create the chapter VideoChapter chap = new VideoChapter(); chap.Enabled = chkEnabled.Checked; chap.EndTime = txtEndTime.Text; chap.Hidden = chkHidden.Checked; chap.Name = txtName.Text; chap.StartTime = txtStartTime.Text; chap.UID = txtUID.Text; //Set Display list if (_IsLoaded) { chap.DisplayList = _TempChapter.CloneDisplayList(); } else { chap.DisplayList = _TempChapter.DisplayList; } //Add it to the Chapter Editor _ChapterEditor.AddChapter(chap); //Clears all the form fields and the Temp object clearDetails(true); //Refresh the chapter list refreshChapterList(); //Set the flag _IsLoaded = false; } catch (Exception ex) { ShowExceptionMessage(ex); } }
private void clearDetails(Boolean cleanTempObject) { txtEndTime.Text = ""; txtName.Text = ""; txtNameLanguage.Text = ""; txtStartTime.Text = ""; txtUID.Text = ""; cmbCountry.SelectedIndex = -1; cmbLanguage.SelectedIndex = -1; lstLanguages.Items.Clear(); chkEnabled.Checked = true; chkHidden.Checked = false; if (cleanTempObject) { _TempChapter = new VideoChapter(); } }
public void RemoveChapter(VideoChapter chap) { chapterList.Remove(chap); }
public void AddChapter(VideoChapter chap) { chapterList.Add(chap); }
public void CreateFromSections(String sectionsFile, String chaptersFile, Decimal frameRate, Boolean useChapters, Boolean isTrimFile) { //clear chapters chapterList.Clear(); //If use chapters, load chapter file if (useChapters) { if (AcHelper.GetFilename(chaptersFile, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "xml") { Load(ChapterType.XML, chaptersFile); } else if (AcHelper.GetFilename(chaptersFile, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).ToLowerInvariant() == "txt") { Load(ChapterType.OGM, chaptersFile); } } //Create a Videoframelist vfl = new VideoFrameList(); //Load the sections file SectionParser.ParseSections(sectionsFile, vfl); //Sanity check if (useChapters && vfl.CountSections != chapterList.Count) { throw new AcException("Error creating chapters! Sections count is different from the chapters count!"); } if (isTrimFile) { Int32 framesToDelete = 0; for (Int32 i = 0; i < vfl.CountSections; i++) { //If no chapters are loaded if (!useChapters) { //Create new empty chapter VideoChapter chap = new VideoChapter(); chapterList.Add(chap); } if (i == 0) { Int32 start = 0; Int32 end = vfl.FrameSections[i].FrameEnd; framesToDelete = vfl.FrameSections[0].FrameStart; end -= framesToDelete; chapterList[i].StartTime = VideoFrame.FrameTimeFromFrameNumber(start, frameRate, FrameFromType.FromFrameRate); chapterList[i].EndTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(end) + 0.5m, frameRate, FrameFromType.FromFrameRate); } else { Int32 start = vfl.FrameSections[i].FrameStart; Int32 end = vfl.FrameSections[i].FrameEnd; Int32 prevEnd = vfl.FrameSections[i - 1].FrameEnd; framesToDelete += start - prevEnd - 1; start -= framesToDelete; end -= framesToDelete; chapterList[i].StartTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(start) + 0.5m, frameRate, FrameFromType.FromFrameRate); chapterList[i].EndTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(end) + 0.5m, frameRate, FrameFromType.FromFrameRate); } } } else { for (Int32 i = 0; i < vfl.CountSections; i++) { //If no chapters are loaded if (!useChapters) { //Create new empty chapter VideoChapter chap = new VideoChapter(); chapterList.Add(chap); } Int32 start = vfl.FrameSections[i].FrameStart; Int32 end = vfl.FrameSections[i].FrameEnd; chapterList[i].StartTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(start) + 0.5m, frameRate, FrameFromType.FromFrameRate); chapterList[i].EndTime = VideoFrame.FrameTimeFromFrameNumber(Convert.ToDecimal(end) + 0.5m, frameRate, FrameFromType.FromFrameRate); } } }
private void LoadXML(String filename) { //Create the Xml Document XmlDocument doc = new XmlDocument(); //Read the Xml file doc.Load(filename); //Clear the chapter list chapterList.Clear(); XmlNodeList chapters = doc.GetElementsByTagName("ChapterAtom"); foreach (XmlNode node in chapters) { //Create a new chapter object VideoChapter chap = new VideoChapter(); //Get the values foreach (XmlNode cNode in node.ChildNodes) { if (cNode.Name == "ChapterUID") { chap.UID = cNode.FirstChild.Value; } else if (cNode.Name == "ChapterFlagHidden") { chap.Hidden = cNode.FirstChild.Value == "1" ? true : false; } else if (cNode.Name == "ChapterFlagEnabled") { chap.Enabled = cNode.FirstChild.Value == "1" ? true : false; } else if (cNode.Name == "ChapterTimeStart") { chap.StartTime = cNode.FirstChild.Value; } else if (cNode.Name == "ChapterTimeEnd") { chap.EndTime = cNode.FirstChild.Value; } else if (cNode.Name == "ChapterDisplay") { VideoChapterDisplay chapDisp = new VideoChapterDisplay(); foreach (XmlNode dNode in cNode.ChildNodes) { if (dNode.Name == "ChapterString") { chapDisp.Name = dNode.FirstChild.Value; } else if (dNode.Name == "ChapterLanguage") { chapDisp.Language = dNode.FirstChild.Value; } else if (dNode.Name == "ChapterCountry") { chapDisp.Country = dNode.FirstChild.Value; } } chap.DisplayList.Add(chapDisp); chap.Name = chapDisp.Name; } } //Add the chapter to the list chapterList.Add(chap); } }