Beispiel #1
0
        public override bool Start(IMouseInformation mouseInformation)
        {
            base.Start(mouseInformation);

            if (_graphicBuilder != null)
            {
                return(_graphicBuilder.Start(mouseInformation));
            }

            IPresentationImage image = mouseInformation.Tile.PresentationImage;

            if (!CanStart(image))
            {
                return(false);
            }

            var             provider = (IOverlayGraphicsProvider)image;
            IControlGraphic graphic  = _graphicDelegateCreatorDelegate();

            _graphicBuilder = _interactiveGraphicBuilderDelegate(graphic);
            _graphicBuilder.GraphicComplete       += OnGraphicBuilderInitiallyDone;
            _graphicBuilder.GraphicCancelled      += OnGraphicBuilderInitiallyDone;
            _graphicBuilder.GraphicFinalComplete  += OnGraphicFinalComplete;
            _graphicBuilder.GraphicFinalCancelled += OnGraphicFinalCancelled;

            AddGraphic(image, graphic, provider);

            if (_graphicBuilder.Start(mouseInformation))
            {
                return(true);
            }

            this.Cancel();
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Fired when the graphic builder is also done setting text in the graphic, and thus we can decide if we want to unexecute
        /// the insert or save the command into the history.
        /// </summary>
        private void OnGraphicFinalCancelled(object sender, GraphicEventArgs e)
        {
            InteractiveTextGraphicBuilder graphicBuilder = sender as InteractiveTextGraphicBuilder;

            if (graphicBuilder != null)
            {
                graphicBuilder.GraphicFinalComplete  -= OnGraphicFinalComplete;
                graphicBuilder.GraphicFinalCancelled -= OnGraphicFinalCancelled;
            }

            _undoableCommand.Unexecute();
            _undoableCommand = null;
        }
Beispiel #3
0
        /// <summary>
        /// Fired when the graphic builder is also done setting text in the graphic, and thus we can decide if we want to unexecute
        /// the insert or save the command into the history.
        /// </summary>
        private void OnGraphicFinalComplete(object sender, GraphicEventArgs e)
        {
            // fired
            InteractiveTextGraphicBuilder graphicBuilder = sender as InteractiveTextGraphicBuilder;

            if (graphicBuilder != null)
            {
                graphicBuilder.GraphicFinalComplete  -= OnGraphicFinalComplete;
                graphicBuilder.GraphicFinalCancelled -= OnGraphicFinalCancelled;
            }

            e.Graphic.ImageViewer.CommandHistory.AddCommand(_undoableCommand);
            _undoableCommand = null;
        }
Beispiel #4
0
        public override bool Stop(IMouseInformation mouseInformation)
        {
            if (_graphicBuilder == null)
            {
                return(false);
            }

            if (_graphicBuilder.Stop(mouseInformation))
            {
                return(true);
            }

            _graphicBuilder.Graphic.ImageViewer.CommandHistory.AddCommand(_undoableCommand);
            _graphicBuilder  = null;
            _undoableCommand = null;
            return(false);
        }
Beispiel #5
0
 /// <summary>
 /// Fired when the graphic builder is done placing the graphic, and hence does not need mouse capture anymore, but in the
 /// text graphic is not technically complete yet and thus we do not insert into the command history yet.
 /// </summary>
 private void OnGraphicBuilderInitiallyDone(object sender, GraphicEventArgs e)
 {
     _graphicBuilder.GraphicComplete  -= OnGraphicBuilderInitiallyDone;
     _graphicBuilder.GraphicCancelled -= OnGraphicBuilderInitiallyDone;
     _graphicBuilder = null;
 }