Exemplo n.º 1
0
 /// <summary>
 /// Method called to notify the plotting operation was finished
 /// </summary>
 /// <param name="pixelHistory">The pixel history tracker containing the information about the pixels that were modified during the operation</param>
 public void OperationFinished(PixelHistoryTracker pixelHistory)
 {
     if (pixelHistory != null && !_registerPixels)
     {
         UndoTask = new PerPixelUndoTask(_bitmap, _description, pixelHistory);
     }
 }
Exemplo n.º 2
0
        public void TestPixelRegistering()
        {
            // Create the tracker
            PixelHistoryTracker tracker = new PixelHistoryTracker(true, 12);

            // Add the pixels
            tracker.RegisterPixel(5, 5, 0xFF, 0x1F);

            var undo = tracker.PixelUndoForPixel(5, 5);

            Assert.IsTrue(undo != null && undo.Value.OldColor == 0xFF, "The returned PixelUndo does not contains the undo color that was expected");
        }
Exemplo n.º 3
0
        public void TestPixelCount()
        {
            // Create the tracker
            PixelHistoryTracker tracker = new PixelHistoryTracker(false, 12);

            // Add the pixels
            tracker.RegisterPixel(5, 5, 0xFF, 0x1F);
            tracker.RegisterPixel(6, 5, 0xEF, 0x2F);
            tracker.RegisterPixel(7, 5, 0xCF, 0x3F);

            Assert.AreEqual(3, tracker.PixelCount, "After consecutive calls to RegisterPixel, the pixel count must match the number of unique pixels provided");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Finishes this pencil paint operation
        /// </summary>
        public override void FinishOperation()
        {
            base.FinishOperation();

            if (useFastBitmap)
            {
                fastBitmap.Unlock();
                fastBitmap.Dispose();
            }

            // Send notifications
            Notifier?.OperationFinished(pixelsDrawn);

            pixelsDrawn = null;
        }
Exemplo n.º 5
0
        public void TestDuplicatedPixelUncheckedRegisteringReplaceOriginal()
        {
            // Create the tracker
            PixelHistoryTracker tracker = new PixelHistoryTracker(false, 12);

            // Add the pixels
            tracker.RegisterUncheckedPixel(5, 5, 0xFF, 0x1F);
            tracker.RegisterUncheckedPixel(5, 5, 0xEF, 0x2F);
            tracker.RegisterUncheckedPixel(5, 5, 0xCF, 0x3F);

            var undo = tracker.PixelUndoForPixel(5, 5);

            Assert.IsTrue(undo != null && undo.Value.OldColor == 0xCF,
                          "The returned PixelUndo does not contains the undo color that was expected. The pixel color must match the color of the last pixel registered RegisterPixel");
        }
Exemplo n.º 6
0
        public void TestClearing()
        {
            // Create the tracker
            PixelHistoryTracker tracker = new PixelHistoryTracker(false, 12);

            // Add the pixels
            tracker.RegisterPixel(5, 5, 0xFF, 0x1F);
            tracker.RegisterPixel(6, 5, 0xEF, 0x2F);
            tracker.RegisterPixel(7, 5, 0xCF, 0x3F);

            tracker.Clear();

            var undo = tracker.PixelUndoForPixel(5, 5);

            Assert.IsNull(undo, "After a call to .Clear(), all pixels that were previously stored must be cleared off the PixelHistoryTracker");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Starts this pencil paint operation, specifying whethe to accumulate the alpha of the pixels
        /// </summary>
        /// <param name="accumulateAlpha">Whether to accumulate the trasparency of the pixels as the pencil draws over them repeatedly</param>
        public void StartOpertaion(bool accumulateAlpha)
        {
            base.StartOpertaion();

            if (useFastBitmap)
            {
                fastBitmap = new FastBitmap(targetBitmap);
                fastBitmap.Lock();
            }

            // Ignore alpha accumulation if the color has no transparency
            AccumulateAlpha = (accumulateAlpha && Color.A != 255);

            if (!AccumulateAlpha)
            {
                pixelsDrawn = new PixelHistoryTracker(true, targetBitmap.Width);
            }

            Notifier?.OperationStarted(AccumulateAlpha);
        }