예제 #1
0
        /* ----------------------------------------------------------------- */
        ///
        /// SetEncryption
        ///
        /// <summary>
        /// Sets the Encryption object.
        /// </summary>
        ///
        /// <param name="src">Facade object.</param>
        /// <param name="value">Encryption object.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem SetEncryption(this MainFacade src, Encryption value)
        {
            var prev = src.Bindable.Encryption;

            return(HistoryItem.CreateInvoke(
                       () => src.Bindable.Encryption = value,
                       () => src.Bindable.Encryption = prev
                       ));
        }
예제 #2
0
        /* ----------------------------------------------------------------- */
        ///
        /// SetMetadata
        ///
        /// <summary>
        /// Sets the Metadata object.
        /// </summary>
        ///
        /// <param name="src">Facade object.</param>
        /// <param name="value">Metadata object.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem SetMetadata(this MainFacade src, Metadata value)
        {
            var prev = src.Bindable.Metadata;

            return(HistoryItem.CreateInvoke(
                       () => src.Bindable.Metadata = value,
                       () => src.Bindable.Metadata = prev
                       ));
        }
예제 #3
0
        /* ----------------------------------------------------------------- */
        ///
        /// Rotate
        ///
        /// <summary>
        /// Rotates the selected images and regenerates them.
        /// </summary>
        ///
        /// <param name="src">Source collection.</param>
        /// <param name="degree">Rotation angle in degree unit.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem Rotate(this ImageCollection src, int degree)
        {
            var indices = GetCopiedIndices(src);

            return(HistoryItem.CreateInvoke(
                       () => src.Rotate(indices, degree),
                       () => src.Rotate(indices, -degree)
                       ));
        }
예제 #4
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),
                       () => items.Each(e => src.Insert(e.Key, new[] { e.Value }))
                       ));
        }
예제 #5
0
        /* ----------------------------------------------------------------- */
        ///
        /// Move
        ///
        /// <summary>
        /// Moves the selected images at the specfied distance.
        /// </summary>
        ///
        /// <param name="src">Source collection.</param>
        /// <param name="delta">Moving distance.</param>
        ///
        /// <returns>
        /// History item to execute undo and redo actions.
        /// </returns>
        ///
        /* ----------------------------------------------------------------- */
        public static HistoryItem Move(this ImageCollection src, int delta)
        {
            var indices = GetCopiedIndices(src);
            var cvt     = indices.Select(i => i + delta).ToList();

            return(HistoryItem.CreateInvoke(
                       () => src.Move(indices, delta),
                       () => src.Move(cvt, -delta)
                       ));
        }
예제 #6
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)
                       ));
        }