示例#1
0
        private ChapterDBAccess.ChapterSet ReCalcBase(ChapterDBAccess.ChapterSet chapterSet, int index)
        {
            //Recalculate all the chapters times with the index chapter as base (00:00)
            //Get the difference in time all chapters should be adjusted
            TimeSpan diff = chapterSet.Chapters[index].Time;

            //Then subtract that difference from all chapters
            foreach (ChapterDBAccess.Chapter t in chapterSet.Chapters)
            {
                t.Time = t.Time.Subtract(diff);
            }

            //Return the modified chapterSet
            return chapterSet;
        }
        public string CreateChapterFile(ChapterDBAccess.ChapterSet chapterSet, string path, bool overwrite)
        {
            WriteLog("Creating chapterfile");

            if (Path.GetExtension(path) != ".xml")
            {
                path += "\\chapters.xml";
            }

            if (File.Exists(path))
            {
                //If the there already exists a file with the same name as the specified, check if we should overwrite
                if (!overwrite)
                {
                    //If we shouldn't overwrite, exit
                    return null;
                }

                //Delete the existing file
                File.Delete(path);
            }

            var xwrite = new XmlTextWriter(path, Encoding.UTF8);

            xwrite.WriteStartDocument();
            xwrite.Formatting = Formatting.Indented;
            xwrite.Indentation = 2;
            xwrite.WriteDocType("Tags", null, "matroskatags.dtd", null);
            xwrite.WriteStartElement("Chapters");
            xwrite.WriteStartElement("EditionEntry");

            foreach (ChapterDBAccess.Chapter chapter in chapterSet.Chapters)
            {
                xwrite.WriteStartElement("ChapterAtom");
                xwrite.WriteElementString("ChapterTimeStart", string.Format("{0:00}:{1:00}:{2:00}.000000000", chapter.Time.Hours, chapter.Time.Minutes, chapter.Time.Seconds));
                xwrite.WriteStartElement("ChapterDisplay");
                xwrite.WriteElementString("ChapterString", chapter.Name);
                xwrite.WriteEndElement();
                xwrite.WriteEndElement();
            }

            xwrite.WriteEndElement();
            xwrite.WriteEndElement();
            xwrite.Close();

            return path;
        }
示例#3
0
        private void LoadChapters(ChapterDBAccess.ChapterSet chapterSet)
        {
            LoadedChapterSet = chapterSet;
            lviewChapters.Items.Clear();

            foreach (ChapterDBAccess.Chapter chapter in chapterSet)
            {
                string time = chapter.Time.ToString();

                if (chapter.Time.ToString().Length >= 12)
                {
                    time = time.Remove(12);
                }

                lviewChapters.Items.Add(new ListViewItem(new string[] {chapter.Name, time}));
            }

            lblSelected.Text = string.Format("You have selected {0} chapters", chapterSet.Chapters.Count);
        }
 public string CreateChapterFile(ChapterDBAccess.ChapterSet chapterSet, string path)
 {
     return CreateChapterFile(chapterSet, path, true);
 }