Пример #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);
        }