Пример #1
0
        /* ----------------------------------------------------------------- */
        ///
        /// RemoveAt
        ///
        /// <summary>
        /// Removes the specified images.
        /// </summary>
        ///
        /// <param name="src">Source collection.</param>
        /// <param name="indices">Collection to be removed.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem RemoveAt(this ImageCollection src, IEnumerable <int> indices)
        {
            var items = GetPair(src, indices.OrderBy(i => i));

            return(HistoryItem.Invoke(
                       () => src.Remove(indices),
                       () => items.Each(e => src.Insert(e.Key, new[] { e.Value }))
                       ));
        }
Пример #2
0
        /* ----------------------------------------------------------------- */
        ///
        /// InsertAt
        ///
        /// <summary>
        /// Inserts the specified items behind the specified index.
        /// </summary>
        ///
        /// <param name="src">Source collection.</param>
        /// <param name="index">Insertion index.</param>
        /// <param name="items">Insertion items.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem InsertAt(this ImageCollection src, int index, IEnumerable <Page> items)
        {
            var copy    = items.ToList();
            var indices = Enumerable.Range(index, copy.Count);

            return(HistoryItem.CreateInvoke(
                       () => src.Insert(index, copy),
                       () => src.Remove(indices)
                       ));
        }
Пример #3
0
        /* ----------------------------------------------------------------- */
        ///
        /// RemoveAt
        ///
        /// <summary>
        /// Removes the specified images.
        /// </summary>
        ///
        /// <param name="src">Source collection.</param>
        /// <param name="indices">Collection to be removed.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem RemoveAt(this ImageCollection src, IEnumerable <int> indices)
        {
            var items = GetPair(src, indices.OrderBy(i => i));

            return(HistoryItem.CreateInvoke(
                       () => src.Remove(indices),
                       () => { foreach (var kv in items)
                               {
                                   src.Insert(kv.Key, new[] { kv.Value });
                               }
                       }
                       ));
        }