123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864 |
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the MIT license.
- // See the LICENSE file in the project root for more information.
- //
- // Purpose: Line annotation class.
- //
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Design;
- using System.Drawing.Drawing2D;
- using FastReport.DataVisualization.Charting.Utilities;
- namespace FastReport.DataVisualization.Charting
- {
- /// <summary>
- /// <b>LineAnnotation</b> is a class that represents a line annotation.
- /// </summary>
- [
- SRDescription("DescriptionAttributeLineAnnotation_LineAnnotation"),
- ]
- public class LineAnnotation : Annotation
- {
- #region Fields
- // Indicates that an infinitive line should be drawn through 2 specified points.
- private bool _isInfinitive = false;
- // Line start/end caps
- private LineAnchorCapStyle _startCap = LineAnchorCapStyle.None;
- private LineAnchorCapStyle _endCap = LineAnchorCapStyle.None;
- #endregion
- #region Construction and Initialization
- /// <summary>
- /// Default public constructor.
- /// </summary>
- public LineAnnotation()
- : base()
- {
- this.anchorAlignment = ContentAlignment.TopLeft;
- }
- #endregion
- #region Properties
- #region Line Visual Attributes
- /// <summary>
- /// Gets or sets a flag that indicates if an infinitive line should be drawn.
- /// </summary>
- /// <value>
- /// <b>True</b> if a line should be drawn infinitively through 2 points provided, <b>false</b> otherwise.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- DefaultValue(false),
- SRDescription("DescriptionAttributeDrawInfinitive"),
- ]
- virtual public bool IsInfinitive
- {
- get
- {
- return _isInfinitive;
- }
- set
- {
- _isInfinitive = value;
- Invalidate();
- }
- }
- /// <summary>
- /// Gets or sets a cap style used at the start of an annotation line.
- /// <seealso cref="EndCap"/>
- /// </summary>
- /// <value>
- /// A <see cref="LineAnchorCapStyle"/> value, used for a cap style used at the start of an annotation line.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- DefaultValue(LineAnchorCapStyle.None),
- SRDescription("DescriptionAttributeStartCap3"),
- ]
- virtual public LineAnchorCapStyle StartCap
- {
- get
- {
- return _startCap;
- }
- set
- {
- _startCap = value;
- Invalidate();
- }
- }
- /// <summary>
- /// Gets or sets a cap style used at the end of an annotation line.
- /// <seealso cref="StartCap"/>
- /// </summary>
- /// <value>
- /// A <see cref="LineAnchorCapStyle"/> value, used for a cap style used at the end of an annotation line.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- DefaultValue(LineAnchorCapStyle.None),
- SRDescription("DescriptionAttributeStartCap3"),
- ]
- virtual public LineAnchorCapStyle EndCap
- {
- get
- {
- return _endCap;
- }
- set
- {
- _endCap = value;
- Invalidate();
- }
- }
- #endregion
- #region Non Applicable Annotation Appearance Attributes (set as Non-Browsable)
- /// <summary>
- /// Not applicable to this annotation type.
- /// </summary>
- /// <value>
- /// A <see cref="ContentAlignment"/> value.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(typeof(ContentAlignment), "MiddleCenter"),
- ]
- override public ContentAlignment Alignment
- {
- get
- {
- return base.Alignment;
- }
- set
- {
- base.Alignment = value;
- }
- }
- /// <summary>
- /// Gets or sets an annotation's text style.
- /// <seealso cref="Font"/>
- /// <seealso cref="ForeColor"/>
- /// </summary>
- /// <value>
- /// A <see cref="TextStyle"/> value used to draw an annotation's text.
- /// </value>
- [Browsable(false)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override TextStyle TextStyle
- {
- get
- {
- return base.TextStyle;
- }
- set
- {
- base.TextStyle = value;
- }
- }
- /// <summary>
- /// Not applicable to this annotation type.
- /// <seealso cref="Font"/>
- /// </summary>
- /// <value>
- /// A <see cref="Color"/> value.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(typeof(Color), "Black"),
- SRDescription("DescriptionAttributeForeColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- override public Color ForeColor
- {
- get
- {
- return base.ForeColor;
- }
- set
- {
- base.ForeColor = value;
- }
- }
- /// <summary>
- /// Not applicable to this annotation type.
- /// <seealso cref="ForeColor"/>
- /// </summary>
- /// <value>
- /// A <see cref="Font"/> object.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"),
- ]
- override public Font Font
- {
- get
- {
- return base.Font;
- }
- set
- {
- base.Font = value;
- }
- }
- /// <summary>
- /// Not applicable to this annotation type.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(typeof(Color), ""),
- NotifyParentPropertyAttribute(true),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- override public Color BackColor
- {
- get
- {
- return base.BackColor;
- }
- set
- {
- base.BackColor = value;
- }
- }
- /// <summary>
- /// Not applicable to this annotation type.
- /// </summary>
- /// <value>
- /// A <see cref="ChartHatchStyle"/> value.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(ChartHatchStyle.None),
- NotifyParentPropertyAttribute(true),
- #if DESIGNER
- Editor(typeof(HatchStyleEditor), typeof(UITypeEditor))
- #endif
- ]
- override public ChartHatchStyle BackHatchStyle
- {
- get
- {
- return base.BackHatchStyle;
- }
- set
- {
- base.BackHatchStyle = value;
- }
- }
- /// <summary>
- /// Not applicable to this annotation type.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(GradientStyle.None),
- NotifyParentPropertyAttribute(true),
- #if DESIGNER
- Editor(typeof(GradientEditor), typeof(UITypeEditor))
- #endif
- ]
- override public GradientStyle BackGradientStyle
- {
- get
- {
- return base.BackGradientStyle;
- }
- set
- {
- base.BackGradientStyle = value;
- }
- }
- /// <summary>
- /// Not applicable to this annotation type.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Browsable(false),
- DefaultValue(typeof(Color), ""),
- NotifyParentPropertyAttribute(true),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- override public Color BackSecondaryColor
- {
- get
- {
- return base.BackSecondaryColor;
- }
- set
- {
- base.BackSecondaryColor = value;
- }
- }
- #endregion
- #region Position
- /// <summary>
- /// Gets or sets a flag that specifies whether the size of an annotation is always
- /// defined in relative chart coordinates.
- /// <seealso cref="Annotation.Width"/>
- /// <seealso cref="Annotation.Height"/>
- /// </summary>
- /// <value>
- /// <b>True</b> if an annotation's <see cref="Annotation.Width"/> and <see cref="Annotation.Height"/> are always
- /// in chart relative coordinates, <b>false</b> otherwise.
- /// </value>
- /// <remarks>
- /// An annotation's width and height may be set in relative chart or axes coordinates.
- /// By default, relative chart coordinates are used.
- /// <para>
- /// To use axes coordinates for size set the <b>IsSizeAlwaysRelative</b> property to
- /// <b>false</b> and either anchor the annotation to a data point or set the
- /// <see cref="Annotation.AxisX"/> or <see cref="Annotation.AxisY"/> properties.
- /// </para>
- /// </remarks>
- [
- SRCategory("CategoryAttributePosition"),
- DefaultValue(true),
- SRDescription("DescriptionAttributeSizeAlwaysRelative3"),
- ]
- override public bool IsSizeAlwaysRelative
- {
- get
- {
- return base.IsSizeAlwaysRelative;
- }
- set
- {
- base.IsSizeAlwaysRelative = value;
- }
- }
- #endregion // Position
- #region Anchor
- /// <summary>
- /// Gets or sets an annotation position's alignment to the anchor point.
- /// <seealso cref="Annotation.AnchorX"/>
- /// <seealso cref="Annotation.AnchorY"/>
- /// <seealso cref="Annotation.AnchorDataPoint"/>
- /// <seealso cref="Annotation.AnchorOffsetX"/>
- /// <seealso cref="Annotation.AnchorOffsetY"/>
- /// </summary>
- /// <value>
- /// A <see cref="ContentAlignment"/> value that represents the annotation's alignment to
- /// the anchor point.
- /// </value>
- /// <remarks>
- /// The annotation must be anchored using either <see cref="Annotation.AnchorDataPoint"/>, or the <see cref="Annotation.AnchorX"/>
- /// and <see cref="Annotation.AnchorY"/> properties. Its <see cref="Annotation.X"/> and <see cref="Annotation.Y"/>
- /// properties must be set to <b>Double.NaN</b>.
- /// </remarks>
- [
- SRCategory("CategoryAttributeAnchor"),
- Browsable(false),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DefaultValue(typeof(ContentAlignment), "TopLeft"),
- SRDescription("DescriptionAttributeAnchorAlignment"),
- ]
- override public ContentAlignment AnchorAlignment
- {
- get
- {
- return base.AnchorAlignment;
- }
- set
- {
- base.AnchorAlignment = value;
- }
- }
- #endregion // Anchoring
- #region Other
- /// <summary>
- /// Gets or sets an annotation's type name.
- /// </summary>
- /// <remarks>
- /// This property is used to get the name of each annotation type
- /// (e.g. Line, Rectangle, Ellipse).
- /// <para>
- /// This property is for internal use and is hidden at design and run time.
- /// </para>
- /// </remarks>
- [
- SRCategory("CategoryAttributeMisc"),
- Bindable(true),
- Browsable(false),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- SRDescription("DescriptionAttributeAnnotationType"),
- ]
- public override string AnnotationType
- {
- get
- {
- return "Line";
- }
- }
- /// <summary>
- /// Gets or sets an annotation's selection points style.
- /// </summary>
- /// <value>
- /// A <see cref="SelectionPointsStyle"/> value that represents the annotation
- /// selection style.
- /// </value>
- /// <remarks>
- /// This property is for internal use and is hidden at design and run time.
- /// </remarks>
- [
- SRCategory("CategoryAttributeAppearance"),
- DefaultValue(SelectionPointsStyle.Rectangle),
- ParenthesizePropertyNameAttribute(true),
- Browsable(false),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- SRDescription("DescriptionAttributeSelectionPointsStyle"),
- ]
- override internal SelectionPointsStyle SelectionPointsStyle
- {
- get
- {
- return SelectionPointsStyle.TwoPoints;
- }
- }
- #endregion
- #endregion
- #region Methods
- /// <summary>
- /// Adjusts the two coordinates of the line.
- /// </summary>
- /// <param name="point1">First line coordinate.</param>
- /// <param name="point2">Second line coordinate.</param>
- /// <param name="selectionRect">Selection rectangle.</param>
- virtual internal void AdjustLineCoordinates(ref PointF point1, ref PointF point2, ref RectangleF selectionRect)
- {
- // Adjust line points to draw infinitive line
- if(IsInfinitive)
- {
- if(Math.Round(point1.X , 3) == Math.Round(point2.X, 3))
- {
- point1.Y = (point1.Y < point2.Y) ? 0f : 100f;
- point2.Y = (point1.Y < point2.Y) ? 100f : 0f;
- }
- else if(Math.Round(point1.Y , 3) == Math.Round(point2.Y, 3))
- {
- point1.X = (point1.X < point2.X) ? 0f : 100f;
- point2.X = (point1.X < point2.X) ? 100f : 0f;
- }
- else
- {
- // Calculate intersection point of the line with two bounaries Y = 0 and Y = 100
- PointF intersectionPoint1 = PointF.Empty;
- intersectionPoint1.Y = 0f;
- intersectionPoint1.X = (0f - point1.Y) *
- (point2.X - point1.X) /
- (point2.Y - point1.Y) +
- point1.X;
- PointF intersectionPoint2 = PointF.Empty;
- intersectionPoint2.Y = 100f;
- intersectionPoint2.X = (100f - point1.Y) *
- (point2.X - point1.X) /
- (point2.Y - point1.Y) +
- point1.X;
- // Select point closect to the intersection
- point1 = (point1.Y < point2.Y) ? intersectionPoint1 : intersectionPoint2;
- point2 = (point1.Y < point2.Y) ? intersectionPoint2 : intersectionPoint1;
- }
- }
- }
- /// <summary>
- /// Paints an annotation object on the specified graphics.
- /// </summary>
- /// <param name="graphics">
- /// A <see cref="ChartGraphics"/> object, used to paint an annotation object.
- /// </param>
- /// <param name="chart">
- /// Reference to the <see cref="Chart"/> owner control.
- /// </param>
- override internal void Paint(Chart chart, ChartGraphics graphics)
- {
- // Get annotation position in relative coordinates
- PointF firstPoint = PointF.Empty;
- PointF anchorPoint = PointF.Empty;
- SizeF size = SizeF.Empty;
- GetRelativePosition(out firstPoint, out size, out anchorPoint);
- PointF secondPoint = new PointF(firstPoint.X + size.Width, firstPoint.Y + size.Height);
- // Create selection rectangle
- RectangleF selectionRect = new RectangleF(firstPoint, new SizeF(secondPoint.X - firstPoint.X, secondPoint.Y - firstPoint.Y));
- // Adjust coordinates
- AdjustLineCoordinates(ref firstPoint, ref secondPoint, ref selectionRect);
- // Check if text position is valid
- if( float.IsNaN(firstPoint.X) ||
- float.IsNaN(firstPoint.Y) ||
- float.IsNaN(secondPoint.X) ||
- float.IsNaN(secondPoint.Y) )
- {
- return;
- }
- // Set line caps
- bool capChanged = false;
- LineCap oldStartCap = LineCap.Flat;
- LineCap oldEndCap = LineCap.Flat;
- if(this._startCap != LineAnchorCapStyle.None ||
- this._endCap != LineAnchorCapStyle.None)
- {
- capChanged = true;
- oldStartCap = graphics.Pen.StartCap;
- oldEndCap = graphics.Pen.EndCap;
- // Apply anchor cap settings
- if(this._startCap == LineAnchorCapStyle.Arrow)
- {
- // Adjust arrow size for small line width
- if(this.LineWidth < 4)
- {
- int adjustment = 3 - this.LineWidth;
- graphics.Pen.StartCap = LineCap.Custom;
- graphics.Pen.CustomStartCap = new AdjustableArrowCap(
- this.LineWidth + adjustment,
- this.LineWidth + adjustment,
- true);
- }
- else
- {
- graphics.Pen.StartCap = LineCap.ArrowAnchor;
- }
- }
- else if(this._startCap == LineAnchorCapStyle.Diamond)
- {
- graphics.Pen.StartCap = LineCap.DiamondAnchor;
- }
- else if(this._startCap == LineAnchorCapStyle.Round)
- {
- graphics.Pen.StartCap = LineCap.RoundAnchor;
- }
- else if(this._startCap == LineAnchorCapStyle.Square)
- {
- graphics.Pen.StartCap = LineCap.SquareAnchor;
- }
- if(this._endCap == LineAnchorCapStyle.Arrow)
- {
- // Adjust arrow size for small line width
- if(this.LineWidth < 4)
- {
- int adjustment = 3 - this.LineWidth;
- graphics.Pen.EndCap = LineCap.Custom;
- graphics.Pen.CustomEndCap = new AdjustableArrowCap(
- this.LineWidth + adjustment,
- this.LineWidth + adjustment,
- true);
- }
- else
- {
- graphics.Pen.EndCap = LineCap.ArrowAnchor;
- }
- }
- else if(this._endCap == LineAnchorCapStyle.Diamond)
- {
- graphics.Pen.EndCap = LineCap.DiamondAnchor;
- }
- else if(this._endCap == LineAnchorCapStyle.Round)
- {
- graphics.Pen.EndCap = LineCap.RoundAnchor;
- }
- else if(this._endCap == LineAnchorCapStyle.Square)
- {
- graphics.Pen.EndCap = LineCap.SquareAnchor;
- }
- }
- if(this.Common.ProcessModePaint)
- {
- // Draw line
- graphics.DrawLineRel(
- this.LineColor,
- this.LineWidth,
- this.LineDashStyle,
- firstPoint,
- secondPoint,
- this.ShadowColor,
- this.ShadowOffset);
- }
- if(this.Common.ProcessModeRegions)
- {
- // Create line graphics path
- using (GraphicsPath path = new GraphicsPath())
- {
- path.AddLine(
- graphics.GetAbsolutePoint(firstPoint),
- graphics.GetAbsolutePoint(secondPoint));
- using (Pen pen = (Pen)graphics.Pen.Clone())
- {
- // Increase pen size by 2 pixels
- pen.DashStyle = DashStyle.Solid;
- pen.Width += 2;
- try
- {
- path.Widen(pen);
- }
- catch (OutOfMemoryException)
- {
- // GraphicsPath.Widen incorrectly throws OutOfMemoryException
- // catching here and reacting by not widening
- }
- catch (ArgumentException)
- {
- }
- }
- // Add hot region
- this.Common.HotRegionsList.AddHotRegion(
- graphics,
- path,
- false,
- ReplaceKeywords(this.ToolTip),
- String.Empty,
- String.Empty,
- String.Empty,
- this,
- ChartElementType.Annotation);
- }
- }
- // Restore line caps
- if(capChanged)
- {
- graphics.Pen.StartCap = oldStartCap;
- graphics.Pen.EndCap = oldEndCap;
- }
- // Paint selection handles
- PaintSelectionHandles(graphics, selectionRect, null);
- }
- #endregion
- }
- /// <summary>
- /// <b>VerticalLineAnnotation</b> is a class that represents a vertical line annotation.
- /// </summary>
- [
- SRDescription("DescriptionAttributeVerticalLineAnnotation_VerticalLineAnnotation"),
- ]
- public class VerticalLineAnnotation : LineAnnotation
- {
- #region Construction and Initialization
- /// <summary>
- /// Default public constructor.
- /// </summary>
- public VerticalLineAnnotation()
- : base()
- {
- }
- #endregion
- #region Properties
- /// <summary>
- /// Gets or sets an annotation's type name.
- /// </summary>
- /// <remarks>
- /// This property is used to get the name of each annotation type
- /// (e.g. Line, Rectangle, Ellipse).
- /// <para>
- /// This property is for internal use and is hidden at design and run time.
- /// </para>
- /// </remarks>
- [
- SRCategory("CategoryAttributeMisc"),
- Bindable(true),
- Browsable(false),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- SRDescription("DescriptionAttributeAnnotationType"),
- ]
- public override string AnnotationType
- {
- get
- {
- return "VerticalLine";
- }
- }
- #endregion
- #region Methods
- /// <summary>
- /// Adjusts the two coordinates of the line.
- /// </summary>
- /// <param name="point1">First line coordinate.</param>
- /// <param name="point2">Second line coordinate.</param>
- /// <param name="selectionRect">Selection rectangle.</param>
- override internal void AdjustLineCoordinates(ref PointF point1, ref PointF point2, ref RectangleF selectionRect)
- {
- // Make line vertical
- point2.X = point1.X;
- selectionRect.Width = 0f;
- // Call base class
- base.AdjustLineCoordinates(ref point1, ref point2, ref selectionRect);
- }
- #region Content Size
- /// <summary>
- /// Gets text annotation content size based on the text and font.
- /// </summary>
- /// <returns>Annotation content position.</returns>
- override internal RectangleF GetContentPosition()
- {
- return new RectangleF(float.NaN, float.NaN, 0f, float.NaN);
- }
- #endregion // Content Size
- #endregion
- }
- /// <summary>
- /// <b>HorizontalLineAnnotation</b> is a class that represents a horizontal line annotation.
- /// </summary>
- [
- SRDescription("DescriptionAttributeHorizontalLineAnnotation_HorizontalLineAnnotation"),
- ]
- public class HorizontalLineAnnotation : LineAnnotation
- {
- #region Construction and Initialization
- /// <summary>
- /// Default public constructor.
- /// </summary>
- public HorizontalLineAnnotation()
- : base()
- {
- }
- #endregion
- #region Properties
- /// <summary>
- /// Gets or sets an annotation's type name.
- /// </summary>
- /// <remarks>
- /// This property is used to get the name of each annotation type
- /// (e.g. Line, Rectangle, Ellipse).
- /// <para>
- /// This property is for internal use and is hidden at design and run time.
- /// </para>
- /// </remarks>
- [
- SRCategory("CategoryAttributeMisc"),
- Bindable(true),
- Browsable(false),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- SRDescription("DescriptionAttributeAnnotationType"),
- ]
- public override string AnnotationType
- {
- get
- {
- return "HorizontalLine";
- }
- }
- #endregion
- #region Methods
- /// <summary>
- /// Adjusts the two coordinates of the line.
- /// </summary>
- /// <param name="point1">First line coordinate.</param>
- /// <param name="point2">Second line coordinate.</param>
- /// <param name="selectionRect">Selection rectangle.</param>
- override internal void AdjustLineCoordinates(ref PointF point1, ref PointF point2, ref RectangleF selectionRect)
- {
- // Make line horizontal
- point2.Y = point1.Y;
- selectionRect.Height = 0f;
- // Call base class
- base.AdjustLineCoordinates(ref point1, ref point2, ref selectionRect);
- }
- #region Content Size
- /// <summary>
- /// Gets text annotation content size based on the text and font.
- /// </summary>
- /// <returns>Annotation content position.</returns>
- override internal RectangleF GetContentPosition()
- {
- return new RectangleF(float.NaN, float.NaN, float.NaN, 0f);
- }
- #endregion // Content Size
- #endregion
- }
- }
|