public int InsertPaddingChapters() { int chCount = Chapters.Count; if (chCount == 0) { return(0); } var ch = Chapters.First(); if (ch.Time.Begin > TimeSpan.Zero && !ch.IsPaddingChapter) { var preChapter = new Chapter(ch.Time.Begin) { IsPaddingChapter = true }; Chapters.Insert(0, preChapter); } ch = Chapters.Last(); if (ch.Time.End < this.Duration && !ch.IsPaddingChapter) { var postChapter = new Chapter(ch.Time.End, this.Duration) { IsPaddingChapter = true }; Chapters.Add(postChapter); } return(Chapters.Count - chCount); }
private void terminateChapter() { if (!(_chapter is null)) { Chapters.Add(_chapter); _chapter = null; } }
public ChapterSelectorViewModel(IManga manga, List <IChapter> selectedMangaChapters) { Manga = manga; Chapters.Clear(); foreach (var chapter in selectedMangaChapters) { Chapters.Add(chapter); } }
public void AddChapter(Chapter chapter) { if (Chapters.Any(v => v.Title == chapter.Title)) { return; } Chapters.Add(chapter); }
public void AddChapters(Chapter chapter) { if (Chapters.Any(c => c.Title == chapter.Title)) { return; } Chapters.Add(chapter); }
public Book(XElement bookTag, Bible bible, int bookNumber, Book previous) : base(bookNumber, previous) { Name = bookTag.Attribute("bname").Value; ShortName = bookTag.Attribute("bsname").Value; foreach (var chapterTag in bookTag.Descendants("CHAPTER")) { var prevChapter = Chapters.Count > 0 ? Chapters[Chapters.Count - 1] : previous?.Chapters[previous.Chapters.Count - 1]; Chapters.Add(new Chapter(chapterTag, this, Chapters.Count + 1, prevChapter)); } }
private void SaveChapter(object chapterObject) { ChapterViewModel chapter = chapterObject as ChapterViewModel; if (chapter != null && chapter.IsValid) { chapter.IsCreated = true; Chapters.Add(chapter); App.Database2.SaveItem(chapter.Chapter); } Back(); }
void _truyen_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "CurrentChapters") { if (_truyen.CurrentChapters != null) { foreach (var chapter in _truyen.CurrentChapters) { Chapters.Add(chapter); } } OnPropertyChanged("Chapters"); } }
void addChapter(XmlNode chapter) { Chapter c = new Chapter(); foreach (XmlNode node in chapter.ChildNodes) { switch (node.Name) { case "ID": c.ID = Convert.ToInt32(node.InnerText); break; case "Title": c.Title = node.InnerText; break; case "Desc": c.Description = node.InnerText; break; case "SortOrder": c.SortID = Convert.ToInt32(node.InnerText); break; case "Unused": c.Unused = node.InnerText == "-1"; break; case "Type": c.Type = (Chapter.ChType)Convert.ToInt32(node.InnerText); break; case "Scenes": foreach (XmlNode scene in node.ChildNodes) { int id = Convert.ToInt32(scene.InnerText); Scene s = Scenes[id - 1] as Scene; c.Scenes.Add(s); s.Parent = c; } break; } } Chapters.Add(c); }
private void CreateChapters() { Chapters.Clear(); int i = 0; foreach (var group in _data) { if (group.IsSelected) // expand { Chapters.Add(group); } else // collapse { Chapters.Add(new ChapterGroup(group.GroupName, group.GroupPath)); } i++; } }
public bool OpenStage(Stage stage) { //是否有当前章节 UserChapter uc = null; foreach (var c in Chapters) { if (c.ChapterId == stage.ChapterId) { uc = c; break; } } if (uc != null) { foreach (var s in uc.Stages) { if (stage.StageId == s.StageId) { return(false); } } } else { UserChapter nuc = new UserChapter(); nuc.Stages = new List <UserStage>(); nuc.ChapterId = stage.ChapterId; uc = nuc; Chapters.Add(uc); } UserStage us = new UserStage(); us.StageId = stage.StageId; us.Star = 0; us.Completed = false; uc.Stages.Add(us); DBManager.WriteUserData(); return(true); }
private void ParseItems(XElement root, int level, XNamespace ns, EpubPath path) { foreach (XElement navPoint in root.Elements(ns + "navPoint")) { XElement text = navPoint.Elements(ns + "navLabel").Elements(ns + "text").FirstOrDefault(); if (text == null) { continue; } XAttribute srcAttr = navPoint.Elements(ns + "content").Attributes("src").FirstOrDefault(); if (srcAttr == null) { continue; } string cleanSource = srcAttr.Value; int length = srcAttr.Value.IndexOf("#", StringComparison.Ordinal); length = length > -1 ? length : cleanSource.Length; cleanSource = cleanSource.Substring(0, length); string key = path + cleanSource; if (Anchors.ContainsKey(key)) { int num = Anchors[key]; var item = new BookChapter { Level = level, Title = CleanText(text.Value), TokenID = num }; Chapters.Add(item); ParseItems(navPoint, level + 1, ns, path); } } }
/// <summary> /// Proper recusion for adding chapters. /// </summary> private void SetChaptersHelper(IList <EpubChapter> chapters, int level) { if (chapters == null || chapters.Count == 0) { return; // not an error, just a fact. If there are no chapters, don't add them. } foreach (var chapter in chapters) { Chapters.Add(new EpubChapterData(chapter, level)); if (chapter.SubChapters != null && chapter.SubChapters.Count > 0) { if (level >= MAX_CHAPTER_DEPTH) { Logger.Log($"ChapterDisplay:SetChapter: too many levels under chapter {chapter.Title}"); } else { SetChaptersHelper(chapter.SubChapters, level + 1); } } } }
public override async Task HandleNavigation(IReadOnlyDictionary <string, object> parameters = null) { try { if (parameters is null) { return; } if (parameters.TryGetValue("work", out var work) && work is Work) { var result = await _worksService.GetWork(((Work)work).WorkId); if (!await _historyService.CheckHistory(result.WorkId)) { await _historyService.InitializeHistory(result); } var history = await _historyService.GetWorkHistory(result.WorkId); Work = work.getAs <WorkIndexing>(); Work.Tags.ForEach(tag => Tags.Add(new Tag { Name = tag })); result.Chapters.ForEach(chapter => { var ch = chapter.getAs <ChapterListingView>(); ch.ChapterRead = history.ChapterRead[ch.Id]; Chapters.Add(ch); }); WorkFavorited = await _favoriteService.CheckFavorites(work.getAs <Work>()); } } finally { FinishedLoad = false; } }
private void ffMpegAsyncHandlerActivation(object sendingProcess, DataReceivedEventArgs outLine) { onCancel(); if (outLine.Data is null) { return; } #if TRACE && EXTRA Trace.WriteLine(outLine.Data); #endif Log(4, this, () => ID + outLine.Data.SubstitUser()); Match match = null; if (!Chapters.IsNull() && !_listComplete) { match = _rgxChapter.Match(outLine.Data); if (match.Success) { var chapter = new Chapter(); Chapters.Add(chapter); chapter.Time.Begin = tryParseSeconds(match); chapter.Time.End = tryParseSeconds(match, 2); return; } else { match = _rgxAnyStream.Match(outLine.Data); if (match.Success) { _listComplete = true; } else { var chapter = Chapters.LastOrDefault(); if (!chapter.IsNull()) { match = _rgxChapterMeta.Match(outLine.Data); if (match.Success) { chapter.Name = string.Empty; return; } else { if (chapter.Name == string.Empty) { match = _rgxChapterTitle.Match(outLine.Data); if (match.Success) { chapter.Name = match.Groups[1].Value; } return; } } } } } } match = _rgxErrorHeader.Match(outLine.Data); if (match.Success) { _success = false; } else { match = _rgxErrorActivationOption.Match(outLine.Data); if (match.Success) { _success = false; } else { match = _rgxInvalid.Match(outLine.Data); if (match.Success) { _success = false; } else { match = _rgxNoActivatonOpt.Match(outLine.Data); if (match.Success) { HasNoActivation = true; } else { match = _rgxAudioStream.Match(outLine.Data); if (match.Success) { string format = match.Groups[1].Value; IsMp3Stream = format.ToLowerInvariant() == "mp3"; } else { match = _rgxAaFile.Match(outLine.Data); if (match.Success) { IsAaFile = true; } else { match = _rgxAaxFile.Match(outLine.Data); if (match.Success) { IsAaxFile = true; } } } } } } } }
/// <summary> /// Adds new Chapter /// </summary> /// <param name="chapter">Chapter to add</param> public void Add(Chapter chapter) { Chapters.Add(chapter); }
private void ExtractInfo(string filePath, string pathToDll, NumberFormatInfo providerNumber) { using (var mediaInfo = new MediaInfo(pathToDll)) { Version = mediaInfo.Option("Info_Version"); mediaInfo.Open(filePath); var streamNumber = 0; // Setup videos for (var i = 0; i < mediaInfo.CountGet(StreamKind.Video); ++i) { VideoStreams.Add(new VideoStreamBuilder(mediaInfo, streamNumber++, i).Build()); } if (VideoDuration == 0) { double duration; double.TryParse( mediaInfo.Get(StreamKind.Video, 0, "Duration"), NumberStyles.AllowDecimalPoint, providerNumber, out duration); VideoDuration = (int)duration; } // Setup audios for (var i = 0; i < mediaInfo.CountGet(StreamKind.Audio); ++i) { AudioStreams.Add(new AudioStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup subtitles for (var i = 0; i < mediaInfo.CountGet(StreamKind.Text); ++i) { Subtitles.Add(new SubtitleStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup chapters for (var i = 0; i < mediaInfo.CountGet(StreamKind.Other); ++i) { Chapters.Add(new ChapterStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup menus for (var i = 0; i < mediaInfo.CountGet(StreamKind.Menu); ++i) { MenuStreams.Add(new MenuStreamBuilder(mediaInfo, streamNumber++, i).Build()); } MediaInfoNotloaded = VideoStreams.Count == 0 && AudioStreams.Count == 0 && Subtitles.Count == 0; // Produce copability properties if (MediaInfoNotloaded) { SetPropertiesDefault(); } else { SetupProperties(mediaInfo); } } }
static void ReadMetaData() { lock (MediaTracks) { MediaTracks.Clear(); string path = get_property_string("path"); if (File.Exists(path)) { using (MediaInfo mi = new MediaInfo(path)) { int count = mi.GetCount(MediaInfoStreamKind.Video); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); Add(track, mi.GetVideo(i, "Format")); Add(track, mi.GetVideo(i, "Format_Profile")); Add(track, mi.GetVideo(i, "Width") + "x" + mi.GetVideo(i, "Height")); Add(track, mi.GetVideo(i, "FrameRate") + " FPS"); Add(track, mi.GetVideo(i, "Language/String")); Add(track, mi.GetVideo(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetVideo(i, "Default") == "Yes" ? "Default" : ""); Add(track, mi.GetVideo(i, "Title")); track.Text = "V: " + track.Text.Trim(' ', ','); track.Type = "v"; track.ID = i + 1; MediaTracks.Add(track); } count = mi.GetCount(MediaInfoStreamKind.Audio); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); Add(track, mi.GetAudio(i, "Language/String")); Add(track, mi.GetAudio(i, "Format")); Add(track, mi.GetAudio(i, "Format_Profile")); Add(track, mi.GetAudio(i, "BitRate/String")); Add(track, mi.GetAudio(i, "Channel(s)/String")); Add(track, mi.GetAudio(i, "SamplingRate/String")); Add(track, mi.GetAudio(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetAudio(i, "Default") == "Yes" ? "Default" : ""); Add(track, mi.GetAudio(i, "Title")); track.Text = "A: " + track.Text.Trim(' ', ','); track.Type = "a"; track.ID = i + 1; MediaTracks.Add(track); } count = mi.GetCount(MediaInfoStreamKind.Text); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); Add(track, mi.GetText(i, "Language/String")); Add(track, mi.GetText(i, "Format")); Add(track, mi.GetText(i, "Format_Profile")); Add(track, mi.GetText(i, "Forced") == "Yes" ? "Forced" : ""); Add(track, mi.GetText(i, "Default") == "Yes" ? "Default" : ""); Add(track, mi.GetText(i, "Title")); track.Text = "S: " + track.Text.Trim(' ', ','); track.Type = "s"; track.ID = i + 1; MediaTracks.Add(track); } count = get_property_int("edition-list/count"); for (int i = 0; i < count; i++) { MediaTrack track = new MediaTrack(); track.Text = "E: " + get_property_string($"edition-list/{i}/title"); track.Type = "e"; track.ID = i; MediaTracks.Add(track); } void Add(MediaTrack track, string val) { if (!string.IsNullOrEmpty(val) && !(track.Text != null && track.Text.Contains(val))) { track.Text += " " + val + ","; } } } } } lock (Chapters) { Chapters.Clear(); int count = get_property_int("chapter-list/count"); for (int x = 0; x < count; x++) { string text = get_property_string($"chapter-list/{x}/title"); double time = get_property_number($"chapter-list/{x}/time"); Chapters.Add(new KeyValuePair <string, double>(text, time)); } } }
private void ExtractInfo(string filePath, NumberFormatInfo providerNumber) #endif { #if (NET40 || NET45) using (var mediaInfo = new MediaInfo(pathToDll)) #else using (var mediaInfo = new MediaInfo()) #endif { if (mediaInfo.Handle == IntPtr.Zero) { MediaInfoNotloaded = true; _logger.LogWarning("MediaInfo library was not loaded!"); return; } else { Version = mediaInfo.Option("Info_Version"); _logger.LogDebug($"MediaInfo library was loaded. Handle={mediaInfo.Handle} Version is {Version}"); } var filePricessingHandle = mediaInfo.Open(filePath); if (filePricessingHandle == IntPtr.Zero) { MediaInfoNotloaded = true; _logger.LogWarning($"MediaInfo library has not been opened media {filePath}"); return; } else { _logger.LogDebug($"MediaInfo library successfully opened {filePath}. Handle={filePricessingHandle}"); } var streamNumber = 0; Tags = new AudioTagBuilder(mediaInfo, 0).Build(); // Setup videos for (var i = 0; i < mediaInfo.CountGet(StreamKind.Video); ++i) { VideoStreams.Add(new VideoStreamBuilder(mediaInfo, streamNumber++, i).Build()); } if (Duration == 0) { double.TryParse( mediaInfo.Get(StreamKind.Video, 0, (int)NativeMethods.Video.Video_Duration), NumberStyles.AllowDecimalPoint, providerNumber, out var duration); Duration = (int)duration; } // Fix 3D for some containers if (VideoStreams.Count == 1 && Tags.GeneralTags.TryGetValue((NativeMethods.General) 1000, out var isStereo)) { var video = VideoStreams.First(); if (Tags.GeneralTags.TryGetValue((NativeMethods.General) 1001, out var stereoMode)) { video.Stereoscopic = (StereoMode)stereoMode; } else { video.Stereoscopic = (bool)isStereo ? StereoMode.Stereo : StereoMode.Mono; } } // Setup audios for (var i = 0; i < mediaInfo.CountGet(StreamKind.Audio); ++i) { AudioStreams.Add(new AudioStreamBuilder(mediaInfo, streamNumber++, i).Build()); } if (Duration == 0) { double.TryParse( mediaInfo.Get(StreamKind.Audio, 0, (int)NativeMethods.Audio.Audio_Duration), NumberStyles.AllowDecimalPoint, providerNumber, out var duration); Duration = (int)duration; } // Setup subtitles for (var i = 0; i < mediaInfo.CountGet(StreamKind.Text); ++i) { Subtitles.Add(new SubtitleStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup chapters for (var i = 0; i < mediaInfo.CountGet(StreamKind.Other); ++i) { Chapters.Add(new ChapterStreamBuilder(mediaInfo, streamNumber++, i).Build()); } // Setup menus for (var i = 0; i < mediaInfo.CountGet(StreamKind.Menu); ++i) { MenuStreams.Add(new MenuStreamBuilder(mediaInfo, streamNumber++, i).Build()); } MediaInfoNotloaded = VideoStreams.Count == 0 && AudioStreams.Count == 0 && Subtitles.Count == 0; // Produce capability properties if (MediaInfoNotloaded) { SetPropertiesDefault(); } else { SetupProperties(mediaInfo); } } }