/// <summary> /// Initializes a new instance of the <see cref="HistoryItem"/> class. /// </summary> /// <param name="file">The backing file.</param> /// <param name="historyCanvas">The history canvas.</param> /// <param name="currentImage">The current image.</param> public HistoryItem(string file, CanvasHistoryState historyCanvas, BitmapSource currentImage) { backingFile = file; state = HistoryItemState.Memory; chunk = new HistoryChunk(historyCanvas, currentImage); ToDisk(); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (!disposed) { disposed = true; if (canvas != null) { canvas.Dispose(); canvas = null; } } }
/// <summary> /// Adds the history item to the undo stack. /// </summary> /// <param name="historyState">The current <see cref="HostTest.CanvasHistoryState"/>.</param> /// <param name="image">The current destination image.</param> public void AddHistoryItem(CanvasHistoryState historyState, BitmapSource image) { if (index < (historyList.Count - 1)) { historyList.RemoveRange(index + 1, (historyList.Count - 1) - index); } historyList.Add(new HistoryItem(tempDirectory.GetRandomFileName(), historyState, image)); index = historyList.Count - 1; OnHistoryChanged(); }
private HistoryChunk(SerializationInfo info, StreamingContext context) { canvas = (CanvasHistoryState)info.GetValue("canvas", typeof(CanvasHistoryState)); byte[] temp = (byte[])info.GetValue("image", typeof(byte[])); using (MemoryStream stream = new MemoryStream(temp)) { BitmapFrame frame = BitmapFrame.Create(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); image = new WriteableBitmap(frame); // Copy the frame using a WriteableBitmap to fix the threading issue with the BitmapFrameDecoder. image.Freeze(); } }
public HistoryChunk(CanvasHistoryState canvasHistory, BitmapSource source) { canvas = canvasHistory; image = source; disposed = false; }
/// <summary> /// Copies the CanvasHistoryState data to the canvas. /// </summary> /// <param name="historyState">The CanvasHistoryState to copy.</param> public void CopyFromHistoryState(CanvasHistoryState historyState) { Surface = historyState.Image; RenderSelection(path, false); }