/* ----------------------------------------------------------------- */ /// /// 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 )); }
/* ----------------------------------------------------------------- */ /// /// 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 )); }
/* ----------------------------------------------------------------- */ /// /// 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) )); }
/* ----------------------------------------------------------------- */ /// /// 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 })) )); }
/* ----------------------------------------------------------------- */ /// /// 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) )); }
/* ----------------------------------------------------------------- */ /// /// 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) )); }