public override bool Start(IMouseInformation mouseInformation) { base.Start(mouseInformation); if (_graphicBuilder != null) return _graphicBuilder.Start(mouseInformation); if (!CanStart(mouseInformation.Tile.PresentationImage)) return false; RoiGraphic roiGraphic = CreateRoiGraphic(); _graphicBuilder = CreateGraphicBuilder(roiGraphic.Subject); _graphicBuilder.GraphicComplete += OnGraphicBuilderComplete; _graphicBuilder.GraphicCancelled += OnGraphicBuilderCancelled; AddRoiGraphic( mouseInformation.Tile.PresentationImage, roiGraphic, (IOverlayGraphicsProvider)mouseInformation.Tile.PresentationImage); roiGraphic.Suspend(); try { if (_graphicBuilder.Start(mouseInformation)) return true; } finally { roiGraphic.Resume(true); } this.Cancel(); return false; }
private void OnGraphicCancelled(object sender, GraphicEventArgs e) { _graphicBuilder.GraphicCancelled -= OnGraphicCancelled; _graphicBuilder.GraphicComplete -= OnGraphicComplete; _graphicBuilder = null; }
private void AddDrawShutterGraphic(IDicomPresentationImage image) { switch (_selectedShutterType) { case ShutterType.Polygon: { _primitiveGraphic = new PolylineGraphic(); image.OverlayGraphics.Add(_primitiveGraphic); _graphicBuilder = InteractiveShutterGraphicBuilders.CreatePolygonalShutterBuilder((PolylineGraphic)_primitiveGraphic); break; } case ShutterType.Circle: { _primitiveGraphic = new EllipsePrimitive(); image.OverlayGraphics.Add(_primitiveGraphic); _graphicBuilder = InteractiveShutterGraphicBuilders.CreateCircularShutterBuilder((EllipsePrimitive)_primitiveGraphic); break; } default: { _primitiveGraphic = new RectanglePrimitive(); image.OverlayGraphics.Add(_primitiveGraphic); _graphicBuilder = InteractiveShutterGraphicBuilders.CreateRectangularShutterBuilder((RectanglePrimitive)_primitiveGraphic); break; } } _graphicBuilder.GraphicCancelled += OnGraphicCancelled; _graphicBuilder.GraphicComplete += OnGraphicComplete; }
public override void Cancel() { if (_graphicBuilder != null) { _graphicBuilder.Cancel(); _graphicBuilder = null; } if (_primitiveGraphic != null) { IPresentationImage image = _primitiveGraphic.ParentPresentationImage; RemoveDrawShutterGraphic(); image.Draw(); } }
private void OnGraphicComplete(object sender, GraphicEventArgs e) { _graphicBuilder.GraphicCancelled -= OnGraphicCancelled; _graphicBuilder.GraphicComplete -= OnGraphicComplete; _graphicBuilder = null; if (_primitiveGraphic != null) { bool boundingBoxTooSmall = false; _primitiveGraphic.CoordinateSystem = CoordinateSystem.Destination; if (_primitiveGraphic.BoundingBox.Width < 50 || _primitiveGraphic.BoundingBox.Height < 50) boundingBoxTooSmall = true; _primitiveGraphic.ResetCoordinateSystem(); if (boundingBoxTooSmall) { RemoveDrawShutterGraphic(); base.SelectedPresentationImage.Draw(); } else { GeometricShutter shutter = ConvertToGeometricShutter(); GeometricShuttersGraphic shuttersGraphic = GetGeometricShuttersGraphic((IDicomPresentationImage) base.SelectedPresentationImage, true); DrawableUndoableCommand command = new DrawableUndoableCommand(shuttersGraphic); command.Name = SR.CommandDrawShutter; command.Enqueue(new AddGeometricShutterUndoableCommand(shuttersGraphic, shutter)); command.Execute(); base.ImageViewer.CommandHistory.AddCommand(command); } } }
public override bool Stop(IMouseInformation mouseInformation) { if (_graphicBuilder == null) return false; if (_graphicBuilder.Stop(mouseInformation)) return true; _graphicBuilder = null; _undoableCommand = null; return false; }
private void OnGraphicBuilderCancelled(object sender, GraphicEventArgs e) { _graphicBuilder.GraphicComplete -= OnGraphicBuilderComplete; _graphicBuilder.GraphicCancelled -= OnGraphicBuilderCancelled; _undoableCommand.Unexecute(); _undoableCommand = null; _graphicBuilder = null; }
private void OnGraphicBuilderComplete(object sender, GraphicEventArgs e) { _graphicBuilder.GraphicComplete -= OnGraphicBuilderComplete; _graphicBuilder.GraphicCancelled -= OnGraphicBuilderCancelled; _graphicBuilder.Graphic.ImageViewer.CommandHistory.AddCommand(_undoableCommand); _graphicBuilder.Graphic.Draw(); _undoableCommand = null; _graphicBuilder = null; }