Index: ImageViewer/Graphics/InvariantTextPrimitive.cs =================================================================== --- ImageViewer/Graphics/InvariantTextPrimitive.cs (revision 10063) +++ ImageViewer/Graphics/InvariantTextPrimitive.cs (working copy) @@ -51,6 +51,7 @@ [DicomSerializableGraphicAnnotation(typeof (TextGraphicAnnotationSerializer))] public class InvariantTextPrimitive : InvariantPrimitive, ITextGraphic { + private TextAnchorMode _textAnchorMode; private string _text; private float _sizeInPoints; private string _font; @@ -64,6 +65,7 @@ { this.SizeInPoints = 10; this.Font = "Arial"; + this.AnchorRelative = TextAnchorMode.Center; } /// @@ -76,6 +78,25 @@ _text = text; } + /// + /// Gets or sets the mode for the anchor relative to the text. + /// + public TextAnchorMode AnchorRelative + { + get + { + return _textAnchorMode; + } + set + { + if (_textAnchorMode != value) + { + _textAnchorMode = value; + base.NotifyPropertyChanged("AnchorRelative"); + } + } + } + /// /// Gets or sets the text. /// @@ -166,10 +187,25 @@ { get { - float halfWidth = this.Dimensions.Width / 2F; - float halfHeight = this.Dimensions.Height / 2F; + float xOffset = 0; + float yOffset = 0; - return RectangleF.FromLTRB(this.Location.X - halfWidth, this.Location.Y - halfHeight, this.Location.X + halfWidth, this.Location.Y + halfHeight); + switch (AnchorRelative) + { + case TextAnchorMode.TopLeftCorner: + xOffset = this.Dimensions.Width / 2F; + yOffset = this.Dimensions.Height / 2F; + break; + + case TextAnchorMode.Center: + xOffset = yOffset = 0; + break; + } + return RectangleF.FromLTRB( this.Location.X - xOffset + , this.Location.Y - yOffset + , this.Location.X + this.Dimensions.Width - xOffset + , this.Location.Y + this.Dimensions.Height - yOffset + ); } } Index: ImageViewer/Graphics/ITextGraphic.cs =================================================================== --- ImageViewer/Graphics/ITextGraphic.cs (revision 10063) +++ ImageViewer/Graphics/ITextGraphic.cs (working copy) @@ -33,6 +33,24 @@ namespace ClearCanvas.ImageViewer.Graphics { + /// + /// This enum set defines the various modes of location that an anchor can take + /// relative to the block of text. + /// + public enum TextAnchorMode + { + /// + /// Identifies the anchor is to be set relative to the center of the text. + /// + Center, + + /// + /// Identifies the anchor is to be set relative to the top left corner of the text. + /// + TopLeftCorner + } + + /// /// Defines an that contains some dynamic, formattable text content. /// @@ -74,5 +92,13 @@ /// This property is in either source or destination coordinates depending on the value of . /// PointF Location { get; set; } + + /// + /// Gets or sets the mode for the anchor relative to the text. + /// + /// + /// Default value is Center, to remain consistent with previous behavior. + /// + TextAnchorMode AnchorRelative { get; set; } } } \ No newline at end of file Index: ImageViewer/InteractiveGraphics/CalloutGraphic.cs =================================================================== --- ImageViewer/InteractiveGraphics/CalloutGraphic.cs (revision 10063) +++ ImageViewer/InteractiveGraphics/CalloutGraphic.cs (working copy) @@ -436,6 +436,18 @@ get { return this.BoundingBox.Size; } } + /// + /// Gets or sets the mode for the anchor relative to the text. + /// + /// + /// only the defalt value, Center, is supported by this object. + public TextAnchorMode AnchorRelative + { + get { return TextAnchorMode.Center; } + set { throw new NotSupportedException(); } + } + + #endregion } } \ No newline at end of file Index: ImageViewer/InteractiveGraphics/TextEditControlGraphic.cs =================================================================== --- ImageViewer/InteractiveGraphics/TextEditControlGraphic.cs (revision 10063) +++ ImageViewer/InteractiveGraphics/TextEditControlGraphic.cs (working copy) @@ -275,6 +275,16 @@ set { this.Subject.LineStyle = value; } } + + /// + /// Gets or sets the mode for the anchor relative to the text. + /// + public TextAnchorMode AnchorRelative + { + get { return this.Subject.AnchorRelative; } + set { this.Subject.AnchorRelative = value; } + } + #endregion #region IMemorable Members