MovedTo() public méthode

public MovedTo ( int index ) : void
index int
Résultat void
Exemple #1
0
        public IEnumerable <int> MoveDown(IEnumerable <int> selection)
        {
            lock (this)
            {
                var newSelection = new int[selection.Count()];
                int upperBound   = Images.Count - 1;
                int j            = 0;
                foreach (int i in selection.OrderByDescending(x => x))
                {
                    if (i != upperBound--)
                    {
                        ScannedImage img = Images[i];
                        Images.RemoveAt(i);
                        Images.Insert(i + 1, img);
                        img.MovedTo(i + 1);
                        newSelection[j++] = i + 1;
                    }
                    else
                    {
                        newSelection[j++] = i;
                    }
                }

                return(newSelection);
            }
        }
Exemple #2
0
        public IEnumerable <int> MoveTo(IEnumerable <int> selection, int index)
        {
            var selList = selection.ToList();
            var bottom  = selList.Where(x => x < index).OrderByDescending(x => x).ToList();
            var top     = selList.Where(x => x >= index).OrderBy(x => x).ToList();

            int offset = 1;

            foreach (int i in bottom)
            {
                ScannedImage img = Images[i];
                Images.RemoveAt(i);
                Images.Insert(index - offset, img);
                img.MovedTo(index - offset);
                offset++;
            }

            offset = 0;
            foreach (int i in top)
            {
                ScannedImage img = Images[i];
                Images.RemoveAt(i);
                Images.Insert(index + offset, img);
                img.MovedTo(index + offset);
                offset++;
            }

            return(Enumerable.Range(index - bottom.Count, selList.Count));
        }
Exemple #3
0
        public IEnumerable <int> MoveUp(IEnumerable <int> selection)
        {
            lock (this)
            {
                var newSelection = new int[selection.Count()];
                int lowerBound   = 0;
                int j            = 0;
                foreach (int i in selection.OrderBy(x => x))
                {
                    if (i != lowerBound++)
                    {
                        ScannedImage img = Images[i];
                        Images.RemoveAt(i);
                        Images.Insert(i - 1, img);
                        img.MovedTo(i - 1);
                        newSelection[j++] = i - 1;
                    }
                    else
                    {
                        newSelection[j++] = i;
                    }
                }

                return(newSelection);
            }
        }