public AddGraphicCommand(IGraphic graphic, GraphicCollection parentCollection)
        {
            Platform.CheckForNullReference(graphic, "graphic");
            Platform.CheckForNullReference(parentCollection, "parentCollection");

            _parentCollection = parentCollection;
            _graphic          = graphic;
        }
        public InsertGraphicCommand(IGraphic graphic, GraphicCollection parentCollection, int index)
        {
            Platform.CheckForNullReference(graphic, "graphic");
            Platform.CheckForNullReference(parentCollection, "parentCollection");
            Platform.CheckTrue(index >= 0, "Insert index positive");

            _parentCollection = parentCollection;
            _graphic          = graphic;
            _index            = index;
        }
        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;
        }
Exemple #4
0
        public override void Execute()
        {
            if (_undoCommand != null)
            {
                throw new InvalidOperationException("The command has already been executed.");
            }

            Validate();

            GraphicCollection parentCollection = ((CompositeGraphic)_graphic.ParentGraphic).Graphics;
            int restoreIndex = parentCollection.IndexOf(_graphic);

            parentCollection.Remove(_graphic);

            _undoCommand = new InsertGraphicCommand(_graphic, parentCollection, restoreIndex);
            _graphic     = null;
        }
Exemple #5
0
        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);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public AddGraphicUndoableCommand(IGraphic graphic, GraphicCollection parentCollection)
 {
     _command = new AddGraphicCommand(graphic, parentCollection);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 public InsertGraphicUndoableCommand(IGraphic graphic, GraphicCollection parentCollection, int index)
 {
     _command = new InsertGraphicCommand(graphic, parentCollection, index);
 }