Esempio n. 1
0
        public void InitializePages()
        {
            RedoChangeList.Clear();
            UndoChangeList.Clear();
            CurrentSignatures.Clear();


            var bigImageHeight = 0;

            foreach (var b in Images)
            {
                bigImageHeight += b.PixelHeight;
            }


            CurrentCropsAndSkips = new CropsAndSkips(new List <int>(), new List <Skip>());
            var positionY = 0;
            var first     = true;

            while (positionY + MaxCropHeight < bigImageHeight)
            {
                var page = CreateNewPage(null);
                page.CropShift = positionY;
                positionY     += page.CropHeight;
                CurrentCropsAndSkips.Crops.Add(page.CropHeight);
                Pages.Add(page);
                if (first)
                {
                    MaxCropHeight = page.MaxCropHeight;
                    first         = false;
                }
            }

            // add last crop
            var lastPage = CreateNewPage(null);

            lastPage.CropShift  = positionY;
            lastPage.CropHeight = bigImageHeight - positionY;
            CurrentCropsAndSkips.Crops.Add(bigImageHeight - positionY);
            Pages.Add(lastPage);

            var document = new FixedDocument();

            foreach (var p in Pages)
            {
                document.Pages.Add(p.Page);
            }
            Document = document;
        }
Esempio n. 2
0
        public void DeleteArea(int pageToEdit, double _start, double _end)
        {
            var start = CalculatePixelPosY_WholeImage(_start, pageToEdit);
            var end   = CalculatePixelPosY_WholeImage(_end, pageToEdit);

            var newCropsAndSkips = CurrentCropsAndSkips.Copy();

            newCropsAndSkips.Crops[pageToEdit] = newCropsAndSkips.Crops[pageToEdit] - (Pages[pageToEdit].CalculatePixelPosY(_end) - Pages[pageToEdit].CalculatePixelPosY(_start));
            newCropsAndSkips.InsertSkip(new Skip()
            {
                SkipType = SkipType.Y, SkipStart = start, SkipEnd = end
            });

            UndoChangeList.Add(CurrentCropsAndSkips);
            CurrentCropsAndSkips = newCropsAndSkips;
            UpdatePages();
        }
Esempio n. 3
0
        public void MergePages(int from, int to)
        {
            var newCropsAndSkips = CurrentCropsAndSkips.Copy();

            var newCropHeight = CurrentCropsAndSkips.Crops[from];

            for (int i = to; i > from; i--)
            {
                newCropHeight += CurrentCropsAndSkips.Crops[i];
                newCropsAndSkips.Crops.RemoveAt(i);
            }
            newCropsAndSkips.Crops[from] = newCropHeight;

            UndoChangeList.Add(CurrentCropsAndSkips);
            CurrentCropsAndSkips = newCropsAndSkips;
            UpdatePages();
        }
Esempio n. 4
0
        public void UndoChange()
        {
            if (UndoChangeList.Count > 0)
            {
                if (UndoChangeList[UndoChangeList.Count - 1] is CropsAndSkips cropsAndSkips)
                {
                    CurrentCropsAndSkips = cropsAndSkips;
                    UpdatePages();
                }
                else if (UndoChangeList[UndoChangeList.Count - 1] is SignatureChanges signatureChanges)
                {
                    ProcessSignatureChanges(signatureChanges, true);
                }

                RedoChangeList.Add(UndoChangeList[UndoChangeList.Count - 1]);
                UndoChangeList.RemoveAt(UndoChangeList.Count - 1);
            }
        }
Esempio n. 5
0
        public void SkipPage(int pageToSkip)
        {
            if (Pages.Count > 1)
            {
                var newCropsAndSkips = CurrentCropsAndSkips.Copy();

                newCropsAndSkips.Crops.RemoveAt(pageToSkip);
                var skipStart = CalculatePixelPosY_WholeImage(0, pageToSkip);
                var skipEnd   = CalculatePixelPosY_WholeImage(CurrentCropsAndSkips.Crops[pageToSkip], pageToSkip);
                newCropsAndSkips.InsertSkip(new Skip()
                {
                    SkipType = SkipType.Y, SkipStart = skipStart, SkipEnd = skipEnd
                });

                UndoChangeList.Add(CurrentCropsAndSkips);
                CurrentCropsAndSkips = newCropsAndSkips;
                UpdatePages();
            }
        }
Esempio n. 6
0
        public void RedoChange()
        {
            if (RedoChangeList.Count > 0)
            {
                if (RedoChangeList[RedoChangeList.Count - 1] is CropsAndSkips cropsAndSkips)
                {
                    UndoChangeList.Add(CurrentCropsAndSkips);
                    CurrentCropsAndSkips = cropsAndSkips;
                    UpdatePages();
                }
                else if (RedoChangeList[RedoChangeList.Count - 1] is SignatureChanges signatureChanges)
                {
                    ProcessSignatureChanges(signatureChanges, false);
                }

                UndoChangeList.Add(RedoChangeList[RedoChangeList.Count - 1]);
                RedoChangeList.RemoveAt(RedoChangeList.Count - 1);
            }
        }
Esempio n. 7
0
        /// <param name="percentage">the vertical position percentage relative to the page (with margin)</param>
        public void SplitPageAt(int pageToEdit, double percentage)
        {
            var splitAt = Pages[pageToEdit].CalculatePixelPosY(percentage);

            if (splitAt != Pages[pageToEdit].CropHeight)
            {
                var newCropsAndSkips = CurrentCropsAndSkips.Copy();

                if (newCropsAndSkips.Crops.Count - 1 > pageToEdit)
                {
                    newCropsAndSkips.Crops[pageToEdit + 1] = CurrentCropsAndSkips.Crops[pageToEdit + 1] + (CurrentCropsAndSkips.Crops[pageToEdit] - splitAt);
                }
                else
                {
                    newCropsAndSkips.Crops.Add(CurrentCropsAndSkips.Crops[pageToEdit] - splitAt);
                }
                newCropsAndSkips.Crops[pageToEdit] = splitAt;

                UndoChangeList.Add(CurrentCropsAndSkips);
                CurrentCropsAndSkips = newCropsAndSkips;
                UpdatePages();
            }
        }