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); } } }
private static bool IsShutterTooSmall(IGraphic shutterGraphic) { shutterGraphic.CoordinateSystem = CoordinateSystem.Destination; try { RectangleF boundingBox = shutterGraphic.BoundingBox; return(boundingBox.Width < 50 || boundingBox.Height < 50); } finally { shutterGraphic.ResetCoordinateSystem(); } }
private static bool IsShutterTooSmall(IGraphic shutterGraphic) { shutterGraphic.CoordinateSystem = CoordinateSystem.Destination; try { RectangleF boundingBox = shutterGraphic.BoundingBox; return (boundingBox.Width < 50 || boundingBox.Height < 50); } finally { shutterGraphic.ResetCoordinateSystem(); } }
public override bool Stop(IMouseInformation mouseInformation) { if (!Enabled) { return(false); } if (_graphicBuilder != null && _graphicBuilder.Stop(mouseInformation)) { _primitiveGraphic.Draw(); return(true); } if (_graphicBuilder == null && _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); DrawableUndoableCommand command = new DrawableUndoableCommand(shuttersGraphic); command.Name = SR.CommandDrawShutter; command.Enqueue(new AddGeometricShutterUndoableCommand(shuttersGraphic, shutter)); command.Execute(); base.ImageViewer.CommandHistory.AddCommand(command); } } return(false); }