private static void OnBookmarkObjectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MangaArchiveInformationObject _this = (d as MangaArchiveInformationObject);

            if (!_this.Empty())
            {
                if (BookmarkObject.Equals(_this.BookmarkObject, null))
                {
                    d.SetValue(ResumeChapterObjectPropertyKey, null);
                }
                else
                {
                    d.SetValue(ResumeChapterObjectPropertyKey, _this.MangaObject.ChapterObjectOfBookmarkObject(_this.BookmarkObject));
                }

                if (ChapterObject.Equals(_this.ResumeChapterObject, null))
                {
                    d.SetValue(HasMoreToReadPropertyKey, false);
                }
                else
                {
                    Int32 ResumeChapterObjectIndex = _this.MangaObject.IndexOfChapterObject(_this.ResumeChapterObject) + 1;
                    d.SetValue(HasMoreToReadPropertyKey, ResumeChapterObjectIndex < _this.MangaObject.Chapters.Count);
                }
            }
        }
Esempio n. 2
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            MangaObject   manga_object   = values.FirstOrDefault(o => o is MangaObject) as MangaObject;
            ChapterObject chapter_object = values.FirstOrDefault(o => o is ChapterObject) as ChapterObject;

            if (!MangaObject.Equals(manga_object, null))
            {
                if (!ChapterObject.Equals(chapter_object, null))
                {
                    return(chapter_object.IsLocal(System.IO.Path.Combine(App.CORE.CHAPTER_ARCHIVE_DIRECTORY, manga_object.MangaFileName()), App.CORE.CHAPTER_ARCHIVE_EXTENSION));
                }
                return(manga_object.IsLocal(App.CORE.MANGA_ARCHIVE_DIRECTORY, App.CORE.MANGA_ARCHIVE_EXTENSION));
            }
            return(false);
        }
Esempio n. 3
0
        public static ChapterObject ChapterObjectOfBookmarkObject(this MangaObject value, BookmarkObject bookmark_object)
        {
            ChapterObject rVal = value.Chapters.Find(c => c.Volume == bookmark_object.Volume && c.Chapter == bookmark_object.Chapter && c.SubChapter == bookmark_object.SubChapter);

            if (!ChapterObject.Equals(rVal, null))
            {
                return(rVal);                                   // Return Bookmark of VCS
            }
            rVal = value.Chapters.Find(c => c.Chapter == bookmark_object.Chapter && c.SubChapter == bookmark_object.SubChapter);
            if (!ChapterObject.Equals(rVal, null))
            {
                return(rVal);                                   // Return Bookmark of CS
            }
            rVal = value.Chapters.Find(c => c.Chapter == bookmark_object.Chapter);
            if (!ChapterObject.Equals(rVal, null))
            {
                return(rVal);               // Return Bookmark of C
            }
            return(value.Chapters.First()); // Return Bookmark of C or null
        }
Esempio n. 4
0
        public static void Merge(this MangaObject mangaObject, IEnumerable <MangaObject> list)
        {
            if (list.Count() > 0)
            {
                // Name
                if (String.IsNullOrWhiteSpace(mangaObject.Name))
                {
                    MangaObject FoD_Obj = list.FirstOrDefault(mO => !String.IsNullOrWhiteSpace(mO.Name));
                    if (FoD_Obj != null)
                    {
                        mangaObject.Name = FoD_Obj.Name;
                    }
                }

                // Released
                if (mangaObject.Released.Equals(DateTime.MinValue))
                {
                    MangaObject FoD_Obj = list.FirstOrDefault(mO => mO.Released > DateTime.MinValue);
                    if (FoD_Obj != null)
                    {
                        mangaObject.Released = FoD_Obj.Released;
                    }
                }

                // Rating
                if (mangaObject.Rating < 0)
                {
                    MangaObject FoD_Obj = list.FirstOrDefault(mO => mO.Rating >= 0);
                    if (FoD_Obj != null)
                    {
                        mangaObject.Rating = FoD_Obj.Rating;
                    }
                }

                // Description
                if (String.IsNullOrWhiteSpace(mangaObject.Description))
                {
                    MangaObject FoD_Obj = list.FirstOrDefault(mO => !String.IsNullOrWhiteSpace(mO.Description));
                    if (FoD_Obj != null)
                    {
                        mangaObject.Description = FoD_Obj.Description;
                    }
                }

                // MangaType & PageFlowDirection
                if (mangaObject.MangaType == Enums.MangaObjectType.Unknown)
                {
                    MangaObject FoD_Obj = list.FirstOrDefault(mO => mO.MangaType != Enums.MangaObjectType.Unknown);
                    if (FoD_Obj != null)
                    {
                        mangaObject.MangaType         = FoD_Obj.MangaType;
                        mangaObject.PageFlowDirection = FoD_Obj.PageFlowDirection;
                    }
                }

                // Locations
                foreach (List <LocationObject> Locations in (from MangaObject obj in list where obj != null select obj.Locations))
                {
                    foreach (LocationObject Location in Locations)
                    {
                        if (!mangaObject.Locations.Any(o => o.ExtensionName == Location.ExtensionName))
                        {
                            mangaObject.Locations.Add(Location);
                        }
                        else
                        {
                            // Update existing location url
                            Int32 idx = mangaObject.Locations.FindIndex(o => o.ExtensionName == Location.ExtensionName);
                            mangaObject.Locations.RemoveAt(idx);
                            mangaObject.Locations.Insert(idx, Location);
                        }
                    }
                }

                // DatabaseLocations
                foreach (List <LocationObject> DatabaseLocations in (from MangaObject obj in list where obj != null select obj.DatabaseLocations))
                {
                    foreach (LocationObject DatabaseLocation in DatabaseLocations)
                    {
                        if (!mangaObject.DatabaseLocations.Any(o => o.ExtensionName == DatabaseLocation.ExtensionName))
                        {
                            mangaObject.DatabaseLocations.Add(DatabaseLocation);
                        }
                    }
                }

                // Artists
                foreach (List <String> Artists in (from MangaObject obj in list where obj != null select obj.Artists))
                {
                    foreach (String Artist in Artists)
                    {
                        if (Artist != null &&
                            !mangaObject.Artists.Any(o => o.ToLower() == Artist.ToLower()))
                        {
                            mangaObject.Artists.Add(Artist);
                        }
                    }
                }

                // Authors
                foreach (List <String> Authors in (from MangaObject obj in list where obj != null select obj.Authors))
                {
                    foreach (String Author in Authors)
                    {
                        if (Author != null &&
                            !mangaObject.Authors.Any(o => o.ToLower() == Author.ToLower()))
                        {
                            mangaObject.Authors.Add(Author);
                        }
                    }
                }

                // Covers
                foreach (List <LocationObject> Covers in (from MangaObject obj in list where obj != null select obj.CoverLocations))
                {
                    foreach (LocationObject Cover in Covers)
                    {
                        if (Cover != null &&
                            !mangaObject.CoverLocations.Any(o => Equals(o.Url, Cover.Url)))
                        {
                            mangaObject.CoverLocations.Add(Cover);
                        }
                    }
                }
                mangaObject.CoverLocations.RemoveAll(c => String.IsNullOrWhiteSpace(c.Url));

                // AlternateNames
                foreach (String Name in (from MangaObject obj in list where obj != null select obj.Name))
                {
                    if (!mangaObject.AlternateNames.Any(o => o.ToLower() == Name.ToLower()) && Name != null)
                    {
                        mangaObject.AlternateNames.Add(Name);
                    }
                }
                foreach (List <String> AlternateNames in (from MangaObject obj in list where obj != null select obj.AlternateNames))
                {
                    foreach (String AlternateName in AlternateNames)
                    {
                        if (AlternateName != null && !mangaObject.AlternateNames.Any(o => o.ToLower() == AlternateName.ToLower()))
                        {
                            mangaObject.AlternateNames.Add(AlternateName);
                        }
                    }
                }

                // Genres
                foreach (List <String> Genres in (from MangaObject obj in list where obj != null select obj.Genres))
                {
                    foreach (String Genre in Genres)
                    {
                        if (Genre != null && !mangaObject.Genres.Any(o => o.ToLower() == Genre.ToLower()))
                        {
                            mangaObject.Genres.Add(Genre);
                        }
                    }
                }

                // Chapters
                foreach (List <ChapterObject> Chapters in (from MangaObject obj in list where obj != null select obj.Chapters))
                {
                    foreach (ChapterObject Chapter in Chapters)
                    {
                        if (Chapter != null)
                        {
                            ChapterObject chapterObject = mangaObject.Chapters.FirstOrDefault(o =>
                            {
                                if (!Int32.Equals(o.Chapter, Chapter.Chapter))
                                {
                                    return(false);
                                }
                                if (!Int32.Equals(o.SubChapter, Chapter.SubChapter))
                                {
                                    return(false);
                                }
                                return(true);
                            });
                            if (ChapterObject.Equals(chapterObject, null))
                            {
                                mangaObject.Chapters.Add(Chapter);
                            }
                            else
                            {
                                chapterObject.Merge(Chapter);
                            }
                        }
                    }
                }

                mangaObject.SortChapters();
            }
        }