コード例 #1
0
ファイル: GamanDatabase.cs プロジェクト: Zoltanar/GamanReader
        public MangaInfo GetOrCreateMangaInfo(string containerPath, RecentItemList <IMangaItem> lastAddedCollection, bool saveToDatabase)
        {
            var item = GetByPath(containerPath);

            if (item != null)
            {
                return(item);
            }
            item = MangaInfo.Create(containerPath, saveToDatabase);
            if (!saveToDatabase)
            {
                return(item);
            }
            CheckCrcMatches(item);
            Items.Add(item);
            SaveChanges();
            lastAddedCollection?.Add(item);
            return(item);

            MangaInfo GetByPath(string path)
            {
                var items = Items.Where(x => path.EndsWith(x.SubPath)).ToArray();

                return(items.FirstOrDefault(x => x.FilePath == path));
            }
        }
コード例 #2
0
ファイル: GamanDatabase.cs プロジェクト: Zoltanar/GamanReader
 public void DeleteMangaInfo(MangaInfo item, bool addToDeletedItems)
 {
     if (addToDeletedItems)
     {
         var deleted = new DeletedMangaInfo(item);
         DeletedItems.Add(deleted);
     }
     Items.Remove(item);
     SaveChanges();
 }
コード例 #3
0
 public DeletedMangaInfo(MangaInfo item)
 {
     Id          = item.Id;
     Name        = item.Name;
     DateAdded   = item.DateAdded;
     DateDeleted = DateTime.Now;
     IsFolder    = item.IsFolder;
     CRC32       = item.CRC32;
     SizeMb      = item.SizeMb;
     FilePath    = item.FilePath;
     FileCount   = item.FileCount;
 }
コード例 #4
0
ファイル: GamanDatabase.cs プロジェクト: Zoltanar/GamanReader
        /// <summary>
        /// Returns true if CRC should stop being checked.
        /// </summary>
        public bool CheckCrcMatches(MangaInfo preSavedItem)
        {
            var crcMatch = Items.FirstOrDefault(i => i.CRC32 == preSavedItem.CRC32);

            if (crcMatch != null)
            {
                var result = MessageBox.Show(
                    @$ "Found a CRC32 Match
This: {preSavedItem}
Match: {crcMatch}
Press Yes to delete this and open match.
Press No add this item to database.
Press cancel to skip this message (will default to adding).",