Example #1
0
        public IEnumerable <int> AltDeinterleave(IEnumerable <int> selectedIndices)
        {
            lock (this)
            {
                // Duplicate the list
                int count  = Images.Count;
                int split  = (count + 1) / 2;
                var images = Images.ToList();

                // Rebuild the image list, even-indexed images first (odd-indexed images in reverse order)
                Images.Clear();
                for (int i = 0; i < split; ++i)
                {
                    Images.Add(images[i * 2]);
                }

                for (int i = count - split - 1; i >= 0; --i)
                {
                    Images.Add(images[i * 2 + 1]);
                }

                RecoveryImage.Refresh(Images);

                // Clear the selection (may be changed in the future to maintain it, but not necessary)
                return(Enumerable.Empty <int>());
            }
        }
Example #2
0
        public IEnumerable <int> Deinterleave(IEnumerable <int> selection)
        {
            lock (this)
            {
                // Duplicate the list
                var count  = Images.Count;
                var split  = (count + 1) / 2;
                var images = Images.ToList();

                // Rebuild the image list, even-indexed images first
                Images.Clear();
                for (var i = 0; i < split; ++i)
                {
                    Images.Add(images[i * 2]);
                }

                for (var i = 0; i < (count - split); ++i)
                {
                    Images.Add(images[i * 2 + 1]);
                }

                RecoveryImage.Refresh(Images);

                // Clear the selection (may be changed in the future to maintain it, but not necessary)
                return(Enumerable.Empty <int>());
            }
        }
Example #3
0
        public IEnumerable <int> Reverse(IEnumerable <int> selection)
        {
            var selectionList = selection.ToList();
            int pairCount     = selectionList.Count / 2;

            // Swap pairs in the selection, excluding the middle element (if the total count is odd)
            for (int i = 0; i < pairCount; i++)
            {
                int x    = selectionList[i];
                int y    = selectionList[selectionList.Count - i - 1];
                var temp = Images[x];
                Images[x] = Images[y];
                Images[y] = temp;
            }

            RecoveryImage.Refresh(Images);

            // Selection stays the same, so is easy to maintain
            return(selectionList);
        }
Example #4
0
        public IEnumerable <int> AltInterleave(IEnumerable <int> selectedIndices)
        {
            // Partition the image list in two
            int count = Images.Count;
            int split = (count + 1) / 2;
            var p1    = Images.Take(split).ToList();
            var p2    = Images.Skip(split).ToList();

            // Rebuild the image list, taking alternating images from each the partitions (the latter in reverse order)
            Images.Clear();
            for (int i = 0; i < count; ++i)
            {
                Images.Add(i % 2 == 0 ? p1[i / 2] : p2[p2.Count - 1 - i / 2]);
            }

            RecoveryImage.Refresh(Images);

            // Clear the selection (may be changed in the future to maintain it, but not necessary)
            return(Enumerable.Empty <int>());
        }
Example #5
0
        public IEnumerable <int> DividedScanBooklet(IEnumerable <int> selection)
        {
            lock (this)
            {
                var original = Images.ToList();
                var max      = original.Count;
                var middle   = max / 2;

                Images.Clear();
                for (int i = 0; i < original.Count; ++i)
                {
                    Images.Add(original[GetScanIndexForDividedBookletByLogicalPage(i, max, middle)]);
                }

                RecoveryImage.Refresh(Images);

                // Clear the selection (may be changed in the future to maintain it, but not necessary)
                return(Enumerable.Empty <int>());
            }
        }
Example #6
0
        public IEnumerable <int> Interleave(IEnumerable <int> selection)
        {
            lock (this)
            {
                // Partition the image list in two
                var count = Images.Count;
                var split = (count + 1) / 2;
                var p1    = Images.Take(split).ToList();
                var p2    = Images.Skip(split).ToList();

                // Rebuild the image list, taking alternating images from each the partitions
                Images.Clear();
                for (var i = 0; i < count; ++i)
                {
                    Images.Add(i % 2 == 0 ? p1[i / 2] : p2[i / 2]);
                }

                RecoveryImage.Refresh(Images);

                // Clear the selection (may be changed in the future to maintain it, but not necessary)
                return(Enumerable.Empty <int>());
            }
        }