示例#1
0
        /// <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();
        }
示例#2
0
 /// <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;
         }
     }
 }
示例#3
0
        /// <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();
        }
示例#4
0
            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();
                }
            }
示例#5
0
 public HistoryChunk(CanvasHistoryState canvasHistory, BitmapSource source)
 {
     canvas   = canvasHistory;
     image    = source;
     disposed = false;
 }
示例#6
0
        /// <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);
        }