public override void Execute()
        {
            if (_undoCommand != null)
            {
                throw new InvalidOperationException("The command has already been executed.");
            }

            _parentCollection.Add(_graphic);
            _undoCommand = new RemoveGraphicCommand(_graphic);

            _parentCollection = null;
            _graphic          = null;
        }
        private void DoFlash(IPresentationImage image, SynchronizationContext syncContext)
        {
            if (!(image is IOverlayGraphicsProvider))
            {
                return;
            }

            GraphicCollection overlayGraphics = ((IOverlayGraphicsProvider)image).OverlayGraphics;
            //Prevent multiple flash graphics per image.
            var existing = overlayGraphics.OfType <FlashOverlayGraphic>().Where(g => g.Controller == this).FirstOrDefault();

            if (existing != null)
            {
                return;
            }

            //Very little utility in flashing if nobody's looking at it.
            if (syncContext == null)
            {
                return;
            }

            var flashOverlayGraphic = new FlashOverlayGraphic(this);

            overlayGraphics.Add(flashOverlayGraphic);
            image.Draw();

            ThreadPool.QueueUserWorkItem(
                delegate
            {
                Thread.Sleep(FlashSpeed);
                syncContext.Post(delegate
                {
                    if (flashOverlayGraphic.IsDisposed)
                    {
                        return;
                    }

                    overlayGraphics.Remove(flashOverlayGraphic);
                    image.Draw();
                }, null);
            }, null);
        }