コード例 #1
0
        public FreeviewHandler(Manga manga, MangaPage currentPage)
        {
            this.CurrentPage = currentPage;
            this.Manga = manga;

            Refresh(null);
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Url,Width,Height,PageNumber,MangaId,Id")] MangaPage mangaPage)
        {
            if (id != mangaPage.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mangaPage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MangaPageExists(mangaPage.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MangaId"] = new SelectList(_context.Mangas, "Id", "Id", mangaPage.MangaId);
            return(View(mangaPage));
        }
コード例 #3
0
 public void Previous()
 {
     if (CurrentPage.HasPrevious)
     {
         CurrentPage = CurrentPage.Previous;
         Raise(PreviousPageDisplay);
     }
 }
コード例 #4
0
 public void Next()
 {
     if (CurrentPage.HasNext)
     {
         CurrentPage = CurrentPage.Next;
         Raise(NextPageDisplay);
     }
 }
コード例 #5
0
        //Output format(Per face Single - 3 items, Double 2 items)
        //      * MUST have faces for both sides (full pages)
        //      * Front side first, Left face first -> LTR (a->b) a,b while RTL (a->b) b,a
        //  S,M,B / D,M / S,M,M / S,M,E / ....

        public static void TestResult(string inputMangaChapters, string outputPrintFaces,
                                      bool startPage, bool endPage, int antiSpoiler = 0)
        {
            // ------------ MOCK INPUT --------------

            List <MangaChapter> allChapters = new List <MangaChapter>();

            string [] iCs = inputMangaChapters.Replace(" ", "").Split('/');
            foreach (string iC in iCs)
            {
                MangaChapter mc = new MangaChapter();
                mc.Pages = new System.Collections.ObjectModel.ObservableCollection <MangaPage>();
                mc.IsRTL = (iC[0] == 'R');

                string[] pages = iC.Substring(1).Split(',');
                foreach (string stringpage in pages)
                {
                    MangaPage mp = new MangaPage();
                    mp.IsDouble = (stringpage == "1") ? false : true;
                    mc.Pages.Add(mp);
                }

                allChapters.Add(mc);
            }

            // ------------ REAL OUTPUT --------------

            List <PrintPage> resultPages =
                (new Core.ChapterBuilders.DuplexBuilder()).Build(allChapters, startPage, endPage, antiSpoiler);

            List <PrintFace>
            resultFaces = resultPages.SelectMany <PrintPage, PrintFace>((p) => new[] { p.Front, p.Back }).ToList();

            List <string> quickLookArr = new List <string>();

            foreach (PrintFace face in resultFaces)
            {
                string isRTL = (face.IsRTL ? "R" : "L") + ">";
                if (face.PrintFaceType == FaceType.SINGLES)
                {
                    quickLookArr.Add(isRTL + "S," + reverseSide(face.Left.SideType) + "," + reverseSide(face.Right.SideType));
                }
                else
                {
                    quickLookArr.Add(isRTL + "D," + reverseSide(face.Left.SideType));
                }
            }

            // ------------ COMPARE --------------

            string resultOutputString = string.Join("/", quickLookArr).ToUpper();
            string testOutputString   = outputPrintFaces.Replace(" ", "").ToUpper();

            Console.WriteLine(resultOutputString);

            Assert.AreEqual(testOutputString, resultOutputString);
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Url,Width,Height,PageNumber,MangaId,Id")] MangaPage mangaPage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mangaPage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MangaId"] = new SelectList(_context.Mangas, "Id", "Id", mangaPage.MangaId);
            return(View(mangaPage));
        }
コード例 #7
0
 public void Previous()
 {
     if (ViewTop <= 0)
     {
         if (CurrentPage.HasPrevious)
         {
             CurrentPage = CurrentPage.Previous;
             updateSettings();
             ViewTop = PageHeight - ViewHeight;
             Raise(PreviousPageDisplay);
         }
     }
     else
     {
         ViewTop = Math.Max(ViewTop - ViewHeight / 4, 0);
         Raise(Display);
     }
 }
コード例 #8
0
 public void Next()
 {
     if (ViewTop + ViewHeight >= PageHeight)
     {
         if (CurrentPage.HasNext)
         {
             CurrentPage = CurrentPage.Next;
             updateSettings();
             ViewTop = 0;
             Raise(NextPageDisplay);
         }
     }
     else
     {
         ViewTop = Math.Min(ViewTop + ViewHeight / 4, PageHeight - ViewHeight);
         Raise(Display);
     }
 }
コード例 #9
0
        public void Previous()
        {
            if (targetIndex == 0)
            {
                if (!CurrentPage.HasPrevious) return;

                CurrentPage = CurrentPage.Previous;
                updateTargets();
                targetIndex = targets.Count - 1;

                Raise(PreviousPageDisplay);
            }
            else
            {
                targetIndex = targetIndex - 1;
                Raise(Display);
            }

            if (CurrentPage.HasPrevious) CurrentPage.Previous.ComputeReadingAsync();
        }
コード例 #10
0
        public void Next()
        {
            if (targetIndex == targets.Count - 1)
            {
                if (!CurrentPage.HasNext) return;

                CurrentPage = CurrentPage.Next;
                updateTargets();
                targetIndex = 0;

                Raise(NextPageDisplay);
            }
            else
            {
                targetIndex = targetIndex + 1;
                Raise(Display);
            }

            if (CurrentPage.HasNext) CurrentPage.Next.ComputeReadingAsync();
        }
コード例 #11
0
 public void AddRecent(MangaPage page, Rectangle view)
 {
     updateRecentState(buildState(page, view, false));
 }
コード例 #12
0
 private MangaState buildState(MangaPage page, Rectangle view, bool pinned)
 {
     return new MangaState(page.Path, view, page.Manga.Configuration, pinned);
 }
コード例 #13
0
        private static void HandleFace(ref bool isFirst, List <PrintFace> Faces, MangaChapter ch, MangaPage p, SingleSideType sideType = SingleSideType.MANGA)
        {
            if (isFirst && !p.IsDouble)
            {
                PrintFace face = new PrintFace()
                {
                    PrintFaceType = FaceType.SINGLES, IsRTL = ch.IsRTL
                };
                Faces.Add(face);

                PrintSide side = null;
                if (sideType == SingleSideType.MANGA)
                {
                    side = new PrintSide()
                    {
                        SideType            = SingleSideType.MANGA,
                        MangaPageSource     = p,
                        MangaPageSourceType = SideMangaPageType.ALL
                    };
                }
                else
                {
                    side = new PrintSide()
                    {
                        MangaPageSource = p,
                        SideType        = sideType,
                    };
                }

                if (ch.IsRTL)
                {
                    face.Right = side;
                }
                else
                {
                    face.Left = side;
                }

                isFirst = false;
            }
            else if (isFirst && p.IsDouble)
            {
                PrintFace face = new PrintFace()
                {
                    PrintFaceType = FaceType.DOUBLE, IsRTL = ch.IsRTL
                };
                Faces.Add(face);

                PrintSide side = new PrintSide()
                {
                    SideType            = SingleSideType.MANGA,
                    MangaPageSource     = p,
                    MangaPageSourceType = SideMangaPageType.ALL // only in booklet we need to know right\left
                };

                face.Left = face.Right = side;

                isFirst = true;
            }
            else if (!isFirst && !p.IsDouble)
            {
                PrintFace face = Faces.Last();

                PrintSide side = null;
                if (sideType == SingleSideType.MANGA)
                {
                    side = new PrintSide()
                    {
                        SideType            = SingleSideType.MANGA,
                        MangaPageSource     = p,
                        MangaPageSourceType = SideMangaPageType.ALL
                    };
                }
                else
                {
                    side = new PrintSide()
                    {
                        SideType        = sideType,
                        MangaPageSource = p,
                    };
                }

                if (ch.IsRTL)
                {
                    face.Left = side;
                }
                else
                {
                    face.Right = side;
                }

                isFirst = true;
            }
            else if (!isFirst && p.IsDouble)
            {
                // Add FILLER
                PrintFace face = Faces.Last();

                PrintSide side = new PrintSide()
                {
                    SideType = SingleSideType.BEFORE_DOUBLE,
                };

                if (ch.IsRTL)
                {
                    face.Left = side;
                }
                else
                {
                    face.Right = side;
                }

                // Add Double
                face = new PrintFace()
                {
                    PrintFaceType = FaceType.DOUBLE, IsRTL = ch.IsRTL
                };
                Faces.Add(face);

                side = new PrintSide()
                {
                    SideType            = SingleSideType.MANGA,
                    MangaPageSource     = p,
                    MangaPageSourceType = SideMangaPageType.ALL // only in booklet we need to know right\left
                };

                face.Left = face.Right = side;
                isFirst   = true;
            }
        }
コード例 #14
0
        public List <PrintPage> Build(List <MangaChapter> chapters, bool addStartPage, bool addEndPage, int addAntiSpoiler = 0, bool parentFolder = true)
        {
            // For loop from 1 to end and add pages as necessary.
            // Double Template should have 0px between 2 pages.

            List <PrintPage> pc = new List <PrintPage>();


            bool             isFirst = true; // Starting page
            List <PrintFace> Faces   = new List <PrintFace>();

            foreach (MangaChapter ch in chapters)
            {
                MangaPage SinglePageNULL = new MangaPage()
                {
                    IsDouble = false, Chapter = ch
                };

                if (addStartPage)
                {
                    HandleFace(ref isFirst, Faces, ch, SinglePageNULL, SingleSideType.INTRO);
                }

                foreach (MangaPage p in ch.Pages)
                {
                    HandleFace(ref isFirst, Faces, ch, p);
                }

                if (addEndPage)
                {
                    HandleFace(ref isFirst, Faces, ch, SinglePageNULL, SingleSideType.OUTRO);
                }

                if (isFirst)
                {
                    // ignore empty side
                }
                else
                {
                    PrintFace face = Faces.Last();

                    PrintSide side = new PrintSide()
                    {
                        SideType = SingleSideType.MAKE_EVEN,
                    };

                    if (ch.IsRTL)
                    {
                        face.Left = side;
                    }
                    else
                    {
                        face.Right = side;
                    }

                    isFirst = true;
                }
            }

            // ----------- Anti Spoiler
            if (addAntiSpoiler > 1)
            {
                int faceIndex = 0;
                while (faceIndex < Faces.Count)
                {
                    PrintSide s = new PrintSide()
                    {
                        SideType = SingleSideType.ANTI_SPOILER
                    };
                    PrintFace f = new PrintFace()
                    {
                        PrintFaceType = FaceType.DOUBLE, IsRTL = true
                    };                                                                               // RTL not important
                    f.Left = f.Right = s;
                    Faces.Insert(faceIndex, f);
                    if (faceIndex == 0)
                    {
                        if (Faces.Count > 1)
                        {
                            f.IsRTL = Faces[1].IsRTL;
                        }
                    }
                    else
                    {
                        f.IsRTL = Faces[faceIndex - 1].IsRTL;
                    }
                    faceIndex += addAntiSpoiler * 2;
                }

                if (Faces.Count > 1)
                {
                    // Add spoiler to the last page:
                    PrintSide _s = new PrintSide()
                    {
                        SideType = SingleSideType.ANTI_SPOILER
                    };
                    PrintFace _f = new PrintFace()
                    {
                        PrintFaceType = FaceType.DOUBLE, IsRTL = true
                    };                                                                                // RTL not important
                    _f.Left = _f.Right = _s;
                    Faces.Add(_f);
                    _f.IsRTL = Faces[Faces.Count - 1 - 1].IsRTL;
                }
            }

            if (Faces.Count % 2 == 1)
            {
                // Add a face for even faces to occupy entire double-sided pages.
                PrintFace face = new PrintFace()
                {
                    PrintFaceType = FaceType.SINGLES, IsRTL = true
                };
                Faces.Add(face);

                // but add as 2 singels because there is no template for double make_even
                PrintSide sideLeft = new PrintSide()
                {
                    SideType = SingleSideType.MAKE_EVEN
                };

                PrintSide sideRight = new PrintSide()
                {
                    SideType = SingleSideType.MAKE_EVEN
                };

                face.Left  = sideLeft;
                face.Right = sideRight;
            }

            int pageIndex   = 1;
            int sideCounter = 1;

            for (int i = 0; i < Faces.Count; i += 2)
            {
                for (int j = 0; j < 2; j++)
                {
                    Faces[i + j].BatchPaperNumber = (addAntiSpoiler > 0) ? ((i / 2) % addAntiSpoiler) : -1;

                    if (Faces[i + j].Right == Faces[i + j].Left)//double
                    {
                        Faces[i + j].Right.SideNumber = sideCounter++;
                        sideCounter++; // count another for double
                    }
                    else
                    {
                        if (Faces[i + j].IsRTL)
                        {
                            Faces[i + j].Right.SideNumber = sideCounter++;
                            Faces[i + j].Left.SideNumber  = sideCounter++;
                        }
                        else
                        {
                            Faces[i + j].Left.SideNumber  = sideCounter++;
                            Faces[i + j].Right.SideNumber = sideCounter++;
                        }
                    }
                }
                PrintPage pp = new PrintPage()
                {
                    PageNumber = pageIndex++,
                    Front      = Faces[i],
                    Back       = Faces[i + 1]
                };
                pp.Front.FaceNumber = (i) + 1; // not stating from zero
                pp.Back.FaceNumber  = (i + 1) + 1;
                pc.Add(pp);
            }

            return(pc);
        }
コード例 #15
0
ファイル: ViewHandler.cs プロジェクト: fpicalausa/mangareader
 public DisplayEventArgs(Rectangle rectangle, MangaPage page)
 {
     this.Rectangle = rectangle;
     this.Page = page;
 }
コード例 #16
0
 private static void LoadPage(MangaPage page, Image target, bool visible = true)
 {
     if (visible)
     {
         target.Source = page.Source;
         target.Source.Freeze();
     }
     target.Visibility = visible.toVisibility();
 }
コード例 #17
0
 private void SetCurrentPage(MangaPage page)
 {
     currentMangaPage = page;
     btnTranslate.IsEnabled = page.HasTranslation;
 }
コード例 #18
0
        private void ShowNextPage(MangaPage newPage)
        {
            MangaPage Next = newPage;
            MangaPage NextNext = Next.Next;
            double size_factor = GetSizeFactor();

            StopAnimatePages();

            ShiftPages(PlaceholderPage, PreviousPage, CurrentPage, NextPage);

            LoadPage(NextNext, NextPage, Next.HasNext);
            MoveAfter(NextPage, size_factor, CurrentPage.Rectangle(), null);
            this.placeholderBefore = true;

            SetCurrentPage(Next);
        }
コード例 #19
0
        private void ShowPreviousPage(MangaPage newPage)
        {
            MangaPage Prev = newPage;
            MangaPage PrevPrev = Prev.Previous;
            double size_factor = GetSizeFactor();

            StopAnimatePages();

            ShiftPages(PlaceholderPage, NextPage, CurrentPage, PreviousPage);
            LoadPage(PrevPrev, PreviousPage, Prev.HasPrevious);
            MoveBefore(PreviousPage, size_factor, CurrentPage.Rectangle(), null);
            this.placeholderBefore = false;

            SetCurrentPage(Prev);
        }
コード例 #20
0
 public FullPageViewHandler(MangaPage CurrentPage)
 {
     this.CurrentPage = CurrentPage;
 }
コード例 #21
0
        private IReadOnlyList<Rectangle> targets; // The rectangles to be displayed

        #endregion Fields

        #region Constructors

        public ParsedViewHandler(MangaPage initialPage)
        {
            CurrentPage = initialPage;
        }
コード例 #22
0
ファイル: Manga.cs プロジェクト: fpicalausa/mangareader
        /// <summary>
        /// Retrieves the manga page corresponding to the specified 0-based index.
        /// </summary>
        /// <param name="pageNumber">The index of the page to be retrieved.</param>
        /// <returns>The manga page at the specified index.</returns>
        public MangaPage GetPage(int pageNumber)
        {
            MangaPage result = null;
            WeakReference<MangaPage> cached;
            if (pagesCache.TryGetValue(pageNumber, out cached))
            {
                cached.TryGetTarget(out result);
            }

            if (result == null)
            {
                result = new MangaPage(this, viewer, directory.GetPagePath(pageNumber), pageNumber);
                cached = new WeakReference<MangaPage>(result);
                pagesCache[pageNumber] = cached;
            }

            return result;
        }