1 //-------------------------------------------------------------
2 // <copyright company=
\92Microsoft Corporation
\92>
3 // Copyright © Microsoft Corporation. All Rights Reserved.
5 //-------------------------------------------------------------
6 // @owner=alexgor, deliant
7 //=================================================================
8 // File: TextAnnotation.cs
10 // Namespace: System.Web.UI.WebControls[Windows.Forms].Charting
12 // Classes: TextAnnotation, AnnotationSmartLabelStyle
14 // Purpose: Text annotation class.
18 //===================================================================
20 #region Used namespace
22 using System.Collections;
23 using System.Collections.Specialized;
24 using System.ComponentModel;
25 using System.ComponentModel.Design;
28 using System.Drawing.Design;
29 using System.Drawing.Text;
30 using System.Drawing.Drawing2D;
31 using System.Security;
34 using System.Windows.Forms;
35 using System.Windows.Forms.DataVisualization.Charting;
36 using System.Windows.Forms.DataVisualization.Charting.Data;
37 using System.Windows.Forms.DataVisualization.Charting.ChartTypes;
38 using System.Windows.Forms.DataVisualization.Charting.Utilities;
39 using System.Windows.Forms.DataVisualization.Charting.Borders3D;
43 using System.Web.UI.DataVisualization.Charting;
44 using System.Web.UI.DataVisualization.Charting.Data;
45 using System.Web.UI.DataVisualization.Charting.Utilities;
52 namespace System.Windows.Forms.DataVisualization.Charting
54 namespace System.Web.UI.DataVisualization.Charting
59 /// <b>TextAnnotation</b> is a class that represents a text annotation.
62 /// Note that other annotations do display inner text (e.g. rectangle,
63 /// ellipse annotations.).
66 SRDescription("DescriptionAttributeTextAnnotation_TextAnnotation"),
69 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
70 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
72 public class TextAnnotation : Annotation
77 private string _text = "";
79 // Indicates multiline text
80 private bool _isMultiline = false;
82 // Current content size
83 internal SizeF contentSize = SizeF.Empty;
85 // Indicates that annotion is an ellipse
86 internal bool isEllipse = false;
90 // Control used to edit text
91 private TextBox _editTextBox = null;
93 #endif // Microsoft_CONTROL
97 #region Construction and Initialization
100 /// Default public constructor.
102 public TextAnnotation()
111 #region Text Visual Attributes
114 /// Annotation's text.
117 SRCategory("CategoryAttributeAppearance"),
119 SRDescription("DescriptionAttributeText"),
121 virtual public string Text
132 // Reset content size to empty
133 contentSize = SizeF.Empty;
138 /// Indicates whether the annotation text is multiline.
141 SRCategory("CategoryAttributeAppearance"),
143 SRDescription("DescriptionAttributeMultiline"),
145 virtual public bool IsMultiline
153 _isMultiline = value;
159 /// Gets or sets the font of an annotation's text.
160 /// <seealso cref="Annotation.ForeColor"/>
163 /// A <see cref="Font"/> object used for an annotation's text.
166 SRCategory("CategoryAttributeAppearance"),
167 DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"),
168 SRDescription("DescriptionAttributeTextFont4"),
170 override public Font Font
180 // Reset content size to empty
181 contentSize = SizeF.Empty;
187 #region Non Applicable Annotation Appearance Attributes (set as Non-Browsable)
190 /// Not applicable to this annotation type.
193 SRCategory("CategoryAttributeAppearance"),
195 DefaultValue(typeof(Color), "Black"),
196 TypeConverter(typeof(ColorConverter)),
197 Editor(Editors.ChartColorEditor.Editor, Editors.ChartColorEditor.Base)
199 override public Color LineColor
203 return base.LineColor;
207 base.LineColor = value;
212 /// Not applicable to this annotation type.
215 SRCategory("CategoryAttributeAppearance"),
218 SRDescription("DescriptionAttributeLineWidth"),
220 override public int LineWidth
224 return base.LineWidth;
228 base.LineWidth = value;
234 /// Not applicable to this annotation type.
237 SRCategory("CategoryAttributeAppearance"),
239 DefaultValue(ChartDashStyle.Solid),
241 override public ChartDashStyle LineDashStyle
245 return base.LineDashStyle;
249 base.LineDashStyle = value;
254 /// Not applicable to this annotation type.
257 SRCategory("CategoryAttributeAppearance"),
259 DefaultValue(typeof(Color), ""),
260 NotifyParentPropertyAttribute(true),
261 TypeConverter(typeof(ColorConverter)),
262 Editor(Editors.ChartColorEditor.Editor, Editors.ChartColorEditor.Base)
264 override public Color BackColor
268 return base.BackColor;
272 base.BackColor = value;
277 /// Not applicable to this annotation type.
280 SRCategory("CategoryAttributeAppearance"),
282 DefaultValue(ChartHatchStyle.None),
283 NotifyParentPropertyAttribute(true),
284 Editor(Editors.HatchStyleEditor.Editor, Editors.HatchStyleEditor.Base)
286 override public ChartHatchStyle BackHatchStyle
290 return base.BackHatchStyle;
294 base.BackHatchStyle = value;
299 /// Not applicable to this annotation type.
302 SRCategory("CategoryAttributeAppearance"),
304 DefaultValue(GradientStyle.None),
305 NotifyParentPropertyAttribute(true),
306 Editor(Editors.GradientEditor.Editor, Editors.GradientEditor.Base)
308 override public GradientStyle BackGradientStyle
312 return base.BackGradientStyle;
316 base.BackGradientStyle = value;
321 /// Not applicable to this annotation type.
324 SRCategory("CategoryAttributeAppearance"),
326 DefaultValue(typeof(Color), ""),
327 NotifyParentPropertyAttribute(true),
328 TypeConverter(typeof(ColorConverter)),
329 Editor(Editors.ChartColorEditor.Editor, Editors.ChartColorEditor.Base)
331 override public Color BackSecondaryColor
335 return base.BackSecondaryColor;
339 base.BackSecondaryColor = value;
348 /// Gets or sets an annotation's type name.
351 /// This property is used to get the name of each annotation type
352 /// (e.g. Line, Rectangle, Ellipse).
354 /// This property is for internal use and is hidden at design and run time.
358 SRCategory("CategoryAttributeMisc"),
361 EditorBrowsableAttribute(EditorBrowsableState.Never),
362 DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
363 SerializationVisibilityAttribute(SerializationVisibility.Hidden),
364 SRDescription("DescriptionAttributeTextAnnotation_AnnotationType"),
366 public override string AnnotationType
375 /// Annotation selection points style.
378 SRCategory("CategoryAttributeAppearance"),
379 DefaultValue(SelectionPointsStyle.Rectangle),
380 ParenthesizePropertyNameAttribute(true),
382 EditorBrowsableAttribute(EditorBrowsableState.Never),
383 DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
384 SerializationVisibilityAttribute(SerializationVisibility.Hidden),
385 SRDescription("DescriptionAttributeSelectionPointsStyle"),
387 override internal SelectionPointsStyle SelectionPointsStyle
391 return SelectionPointsStyle.Rectangle;
404 /// Paints an annotation object on the specified graphics.
406 /// <param name="graphics">
407 /// A <see cref="ChartGraphics"/> object, used to paint an annotation object.
409 /// <param name="chart">
410 /// Reference to the <see cref="Chart"/> owner control.
412 override internal void Paint(Chart chart, ChartGraphics graphics)
414 // Get annotation position in relative coordinates
415 PointF firstPoint = PointF.Empty;
416 PointF anchorPoint = PointF.Empty;
417 SizeF size = SizeF.Empty;
418 GetRelativePosition(out firstPoint, out size, out anchorPoint);
419 PointF secondPoint = new PointF(firstPoint.X + size.Width, firstPoint.Y + size.Height);
421 // Create selection rectangle
422 RectangleF selectionRect = new RectangleF(firstPoint, new SizeF(secondPoint.X - firstPoint.X, secondPoint.Y - firstPoint.Y));
425 RectangleF textPosition = new RectangleF(selectionRect.Location, selectionRect.Size);
426 if(textPosition.Width < 0)
428 textPosition.X = textPosition.Right;
429 textPosition.Width = -textPosition.Width;
431 if(textPosition.Height < 0)
433 textPosition.Y = textPosition.Bottom;
434 textPosition.Height = -textPosition.Height;
437 // Check if text position is valid
438 if( textPosition.IsEmpty ||
439 float.IsNaN(textPosition.X) ||
440 float.IsNaN(textPosition.Y) ||
441 float.IsNaN(textPosition.Right) ||
442 float.IsNaN(textPosition.Bottom) )
447 if(this.Common.ProcessModePaint)
449 DrawText(graphics, textPosition, false, false);
452 if(this.Common.ProcessModeRegions)
457 using (GraphicsPath ellipsePath = new GraphicsPath())
459 ellipsePath.AddEllipse(textPosition);
460 this.Common.HotRegionsList.AddHotRegion(
464 ReplaceKeywords(this.ToolTip),
465 #if Microsoft_CONTROL
469 #else // Microsoft_CONTROL
470 ReplaceKeywords(this.Url),
471 ReplaceKeywords(this.MapAreaAttributes),
472 ReplaceKeywords(this.PostBackValue),
473 #endif // Microsoft_CONTROL
475 ChartElementType.Annotation);
480 this.Common.HotRegionsList.AddHotRegion(
482 ReplaceKeywords(this.ToolTip),
483 #if Microsoft_CONTROL
487 #else // Microsoft_CONTROL
488 ReplaceKeywords(this.Url),
489 ReplaceKeywords(this.MapAreaAttributes),
490 ReplaceKeywords(this.PostBackValue),
491 #endif // Microsoft_CONTROL
493 ChartElementType.Annotation,
498 // Paint selection handles
499 PaintSelectionHandles(graphics, selectionRect, null);
503 /// Draws text in specified rectangle.
505 /// <param name="graphics">Chart graphics.</param>
506 /// <param name="textPosition">Text position.</param>
507 /// <param name="noSpacingForCenteredText">True if text allowed to be outside of position when centered.</param>
508 /// <param name="getTextPosition">True if position text must be returned by the method.</param>
509 /// <returns>Text actual position if required.</returns>
510 internal RectangleF DrawText(ChartGraphics graphics, RectangleF textPosition, bool noSpacingForCenteredText, bool getTextPosition)
512 RectangleF textActualPosition = RectangleF.Empty;
514 //***************************************************************
515 //** Adjust text position uing text spacing
516 //***************************************************************
517 bool annotationRelative = false;
518 RectangleF textSpacing = GetTextSpacing(out annotationRelative);
519 float spacingScaleX = 1f;
520 float spacingScaleY = 1f;
521 if(annotationRelative)
523 if(textPosition.Width > 25f)
525 spacingScaleX = textPosition.Width / 50f;
526 spacingScaleX = Math.Max(1f, spacingScaleX);
528 if(textPosition.Height > 25f)
530 spacingScaleY = textPosition.Height / 50f;
531 spacingScaleY = Math.Max(1f, spacingScaleY);
535 RectangleF textPositionWithSpacing = new RectangleF(textPosition.Location, textPosition.Size);
536 textPositionWithSpacing.Width -= (textSpacing.Width + textSpacing.X) * spacingScaleX;
537 textPositionWithSpacing.X += textSpacing.X * spacingScaleX;
538 textPositionWithSpacing.Height -= (textSpacing.Height + textSpacing.Y) * spacingScaleY;
539 textPositionWithSpacing.Y += textSpacing.Y * spacingScaleY;
541 //***************************************************************
542 //** Replace new line characters
543 //***************************************************************
544 string titleText = this.ReplaceKeywords(this.Text.Replace("\\n", "\n"));
546 //***************************************************************
547 //** Check if centered text require spacing.
548 //** Use only half of the spacing required.
549 //** Apply only for 1 line of text.
550 //***************************************************************
551 if(noSpacingForCenteredText &&
552 titleText.IndexOf('\n') == -1)
554 if(this.Alignment == ContentAlignment.MiddleCenter ||
555 this.Alignment == ContentAlignment.MiddleLeft ||
556 this.Alignment == ContentAlignment.MiddleRight)
558 textPositionWithSpacing.Y = textPosition.Y;
559 textPositionWithSpacing.Height = textPosition.Height;
560 textPositionWithSpacing.Height -= textSpacing.Height/2f + textSpacing.Y / 2f;
561 textPositionWithSpacing.Y += textSpacing.Y / 2f;
563 if(this.Alignment == ContentAlignment.BottomCenter ||
564 this.Alignment == ContentAlignment.MiddleCenter ||
565 this.Alignment == ContentAlignment.TopCenter)
567 textPositionWithSpacing.X = textPosition.X;
568 textPositionWithSpacing.Width = textPosition.Width;
569 textPositionWithSpacing.Width -= textSpacing.Width/2f + textSpacing.X / 2f;
570 textPositionWithSpacing.X += textSpacing.X / 2f;
575 using( Brush textBrush = new SolidBrush(this.ForeColor) )
577 using (StringFormat format = new StringFormat(StringFormat.GenericTypographic))
579 //***************************************************************
581 //***************************************************************
582 format.FormatFlags = format.FormatFlags ^ StringFormatFlags.LineLimit;
583 format.Trimming = StringTrimming.EllipsisCharacter;
584 if (this.Alignment == ContentAlignment.BottomRight ||
585 this.Alignment == ContentAlignment.MiddleRight ||
586 this.Alignment == ContentAlignment.TopRight)
588 format.Alignment = StringAlignment.Far;
590 if (this.Alignment == ContentAlignment.BottomCenter ||
591 this.Alignment == ContentAlignment.MiddleCenter ||
592 this.Alignment == ContentAlignment.TopCenter)
594 format.Alignment = StringAlignment.Center;
596 if (this.Alignment == ContentAlignment.BottomCenter ||
597 this.Alignment == ContentAlignment.BottomLeft ||
598 this.Alignment == ContentAlignment.BottomRight)
600 format.LineAlignment = StringAlignment.Far;
602 if (this.Alignment == ContentAlignment.MiddleCenter ||
603 this.Alignment == ContentAlignment.MiddleLeft ||
604 this.Alignment == ContentAlignment.MiddleRight)
606 format.LineAlignment = StringAlignment.Center;
609 //***************************************************************
610 //** Set shadow color and offset
611 //***************************************************************
612 Color textShadowColor = ChartGraphics.GetGradientColor(this.ForeColor, Color.Black, 0.8);
613 int textShadowOffset = 1;
614 TextStyle textStyle = this.TextStyle;
615 if (textStyle == TextStyle.Shadow &&
618 // Draw shadowed text
619 textShadowColor = ShadowColor;
620 textShadowOffset = ShadowOffset;
623 if (textStyle == TextStyle.Shadow)
625 textShadowColor = (textShadowColor.A != 255) ? textShadowColor : Color.FromArgb(textShadowColor.A / 2, textShadowColor);
628 //***************************************************************
629 //** Get text actual position
630 //***************************************************************
634 SizeF textSize = graphics.MeasureStringRel(
635 this.ReplaceKeywords(_text.Replace("\\n", "\n")),
637 textPositionWithSpacing.Size,
641 textActualPosition = new RectangleF(textPositionWithSpacing.Location, textSize);
642 if (this.Alignment == ContentAlignment.BottomRight ||
643 this.Alignment == ContentAlignment.MiddleRight ||
644 this.Alignment == ContentAlignment.TopRight)
646 textActualPosition.X += textPositionWithSpacing.Width - textSize.Width;
648 if (this.Alignment == ContentAlignment.BottomCenter ||
649 this.Alignment == ContentAlignment.MiddleCenter ||
650 this.Alignment == ContentAlignment.TopCenter)
652 textActualPosition.X += (textPositionWithSpacing.Width - textSize.Width) / 2f;
654 if (this.Alignment == ContentAlignment.BottomCenter ||
655 this.Alignment == ContentAlignment.BottomLeft ||
656 this.Alignment == ContentAlignment.BottomRight)
658 textActualPosition.Y += textPositionWithSpacing.Height - textSize.Height;
660 if (this.Alignment == ContentAlignment.MiddleCenter ||
661 this.Alignment == ContentAlignment.MiddleLeft ||
662 this.Alignment == ContentAlignment.MiddleRight)
664 textActualPosition.Y += (textPositionWithSpacing.Height - textSize.Height) / 2f;
667 // Do not allow text to go outside annotation position
668 textActualPosition.Intersect(textPositionWithSpacing);
671 RectangleF absPosition = graphics.GetAbsoluteRectangle(textPositionWithSpacing);
672 Title.DrawStringWithStyle(
687 return textActualPosition;
690 #endregion // Painting
694 #if Microsoft_CONTROL
697 /// Stops editing of the annotation text.
698 /// <seealso cref="BeginTextEditing"/>
701 /// Call this method to cancel text editing, which was started via a call to
702 /// the <see cref="BeginTextEditing"/> method, or after the end-user double-clicks
703 /// on the annotation.
705 public void StopTextEditing()
707 // Check if text is currently edited
708 if(_editTextBox != null)
710 // Set annotation text
711 this.Text = _editTextBox.Text;
713 // Remove and dispose the text box
716 _editTextBox.KeyDown -= new KeyEventHandler(OnTextBoxKeyDown);
717 _editTextBox.LostFocus -= new EventHandler(OnTextBoxLostFocus);
719 catch(SecurityException)
721 // Ignore security issues
724 if(this.Chart.Controls.Contains(_editTextBox))
726 TextBox tempControl = null;
729 // NOTE: Workaround .Net bug. Issue with appplication closing if
730 // active control is removed.
731 Form parentForm = this.Chart.FindForm();
732 if(parentForm != null)
734 tempControl = new TextBox();
735 tempControl.Visible = false;
737 // Add temp. control as active
738 parentForm.Controls.Add(tempControl);
739 parentForm.ActiveControl = tempControl;
742 catch(SecurityException)
744 // Ignore security issues
747 // Remove text editor
748 this.Chart.Controls.Remove(_editTextBox);
750 // Dispose temp. text box
751 if(tempControl != null)
753 tempControl.Dispose();
758 _editTextBox.Dispose();
761 // Raise notification event
762 if(this.Chart != null)
764 this.Chart.OnAnnotationTextChanged(this);
768 if(this.Chart != null)
770 this.Chart.Invalidate();
778 /// Handles event when focus is lost by the text editing control.
780 /// <param name="sender">Event sender.</param>
781 /// <param name="e">Event arguments.</param>
782 private void OnTextBoxLostFocus(object sender, EventArgs e)
788 /// Handles event when key is pressed in the text editing control.
790 /// <param name="sender">Event sender.</param>
791 /// <param name="e">Event arguments.</param>
792 private void OnTextBoxKeyDown(object sender, KeyEventArgs e)
794 if(e.KeyCode == Keys.Escape)
796 // Reset text and stop editing
797 _editTextBox.Text = this.Text;
800 else if(e.KeyCode == Keys.Enter &&
801 this.IsMultiline == false)
809 /// Begins editing the annotation's text by an end user.
810 /// <seealso cref="StopTextEditing"/>
813 /// After calling this method, the annotation displays an editing box which allows
814 /// for editing of the annotation's text.
816 /// Call the <see cref="StopTextEditing"/> method to cancel this mode programatically.
817 /// Note that editing ends when the end-user hits the <c>Enter</c> key if multi-line
818 /// is false, or when the end-user clicks outside of the editing box if multi-line is true.
821 public void BeginTextEditing()
824 if(this.Chart != null && this.AllowTextEditing)
826 // Dispose previous text box
827 if(_editTextBox != null)
829 if(this.Chart.Controls.Contains(_editTextBox))
831 this.Chart.Controls.Remove(_editTextBox);
833 _editTextBox.Dispose();
837 // Create a text box inside the chart
838 _editTextBox = new TextBox();
839 _editTextBox.Text = this.Text;
840 _editTextBox.Multiline = this.IsMultiline;
841 _editTextBox.Font = this.Font;
842 _editTextBox.BorderStyle = BorderStyle.FixedSingle;
843 _editTextBox.BackColor = Color.FromArgb(255, (this.BackColor.IsEmpty) ? Color.White : this.BackColor);
844 _editTextBox.ForeColor = Color.FromArgb(255, this.ForeColor);
846 // Calculate text position in relative coordinates
847 PointF firstPoint = PointF.Empty;
848 PointF anchorPoint = PointF.Empty;
849 SizeF size = SizeF.Empty;
850 GetRelativePosition(out firstPoint, out size, out anchorPoint);
851 PointF secondPoint = new PointF(firstPoint.X + size.Width, firstPoint.Y + size.Height);
852 RectangleF textPosition = new RectangleF(firstPoint, new SizeF(secondPoint.X - firstPoint.X, secondPoint.Y - firstPoint.Y));
853 if(textPosition.Width < 0)
855 textPosition.X = textPosition.Right;
856 textPosition.Width = -textPosition.Width;
858 if(textPosition.Height < 0)
860 textPosition.Y = textPosition.Bottom;
861 textPosition.Height = -textPosition.Height;
864 // Set text control position in pixels
865 if(GetGraphics() != null)
867 // Convert point to relative coordinates
868 textPosition = GetGraphics().GetAbsoluteRectangle(textPosition);
871 // Adjust Location and Size
876 textPosition.Width += 2;
877 textPosition.Height += 2;
881 textPosition.Y += textPosition.Height / 2f - _editTextBox.Size.Height / 2f;
883 _editTextBox.Location = Point.Round(textPosition.Location);
884 _editTextBox.Size = Size.Round(textPosition.Size);
886 // Add control to the chart
887 this.Chart.Controls.Add(_editTextBox);
890 _editTextBox.SelectAll();
891 _editTextBox.Focus();
893 catch(SecurityException)
895 // Ignore security issues
900 // Set text box event hanlers
901 _editTextBox.KeyDown += new KeyEventHandler(OnTextBoxKeyDown);
902 _editTextBox.LostFocus += new EventHandler(OnTextBoxLostFocus);
904 catch(SecurityException)
906 // Ignore security issues
911 #endif // Microsoft_CONTROL
913 #endregion // Text Editing
918 /// Gets text annotation content size based on the text and font.
920 /// <returns>Annotation content position.</returns>
921 override internal RectangleF GetContentPosition()
923 // Return pre calculated value
924 if(!contentSize.IsEmpty)
926 return new RectangleF(float.NaN, float.NaN, contentSize.Width, contentSize.Height);
929 // Create temporary bitmap based chart graphics if chart was not
930 // rendered yet and the graphics was not created.
931 // NOTE: Fix for issue #3978.
932 Graphics graphics = null;
933 System.Drawing.Image graphicsImage = null;
934 ChartGraphics tempChartGraph = null;
935 if(GetGraphics() == null && this.Common != null)
937 graphicsImage = new System.Drawing.Bitmap(Common.ChartPicture.Width, Common.ChartPicture.Height);
938 graphics = Graphics.FromImage( graphicsImage );
939 tempChartGraph = new ChartGraphics( Common );
940 tempChartGraph.Graphics = graphics;
941 tempChartGraph.SetPictureSize( Common.ChartPicture.Width, Common.ChartPicture.Height );
942 this.Common.graph = tempChartGraph;
945 // Calculate content size
946 RectangleF result = RectangleF.Empty;
947 if(GetGraphics() != null && this.Text.Trim().Length > 0)
949 // Measure text using current font and slightly increase it
950 contentSize = GetGraphics().MeasureString(
951 "W" + this.ReplaceKeywords(this.Text.Replace("\\n", "\n")),
953 new SizeF(2000, 2000),
954 StringFormat.GenericTypographic);
956 contentSize.Height *= 1.04f;
958 // Convert to relative coordinates
959 contentSize = GetGraphics().GetRelativeSize(contentSize);
962 bool annotationRelative = false;
963 RectangleF textSpacing = GetTextSpacing(out annotationRelative);
964 float spacingScaleX = 1f;
965 float spacingScaleY = 1f;
966 if(annotationRelative)
968 if(contentSize.Width > 25f)
970 spacingScaleX = contentSize.Width / 25f;
971 spacingScaleX = Math.Max(1f, spacingScaleX);
973 if(contentSize.Height > 25f)
975 spacingScaleY = contentSize.Height / 25f;
976 spacingScaleY = Math.Max(1f, spacingScaleY);
980 contentSize.Width += (textSpacing.X + textSpacing.Width) * spacingScaleX;
981 contentSize.Height += (textSpacing.Y + textSpacing.Height) * spacingScaleY;
983 result = new RectangleF(float.NaN, float.NaN, contentSize.Width, contentSize.Height);
986 // Dispose temporary chart graphics
987 if(tempChartGraph != null)
989 tempChartGraph.Dispose();
991 graphicsImage.Dispose();
992 this.Common.graph = null;
999 /// Gets text spacing on four different sides in relative coordinates.
1001 /// <param name="annotationRelative">Indicates that spacing is in annotation relative coordinates.</param>
1002 /// <returns>Rectangle with text spacing values.</returns>
1003 internal virtual RectangleF GetTextSpacing(out bool annotationRelative)
1005 annotationRelative = false;
1006 RectangleF rect = new RectangleF(3f, 3f, 3f, 3f);
1007 if(GetGraphics() != null)
1009 rect = GetGraphics().GetRelativeRectangle(rect);
1016 #region Placement Methods
1018 #if Microsoft_CONTROL
1021 /// Ends user placement of an annotation.
1024 /// Ends an annotation placement operation previously started by a
1025 /// <see cref="Annotation.BeginPlacement"/> method call.
1027 /// Calling this method is not required, since placement will automatically
1028 /// end when an end user enters all required points. However, it is useful when an annotation
1029 /// placement operation needs to be aborted for some reason.
1032 override public void EndPlacement()
1034 // Check if text editing is allowed
1035 // Maybe changed later in the EndPlacement method.
1036 bool allowTextEditing = this.AllowTextEditing;
1039 base.EndPlacement();
1041 // Begin text editing
1042 if(this.Chart != null)
1044 this.Chart.Annotations.lastClickedAnnotation = this;
1045 if(allowTextEditing)
1052 #endif // Microsoft_CONTROL
1054 #endregion // Placement Methods
1056 #endregion // Methods
1060 /// The <b>AnnotationSmartLabelStyle</b> class is used to store an annotation's smart
1061 /// labels properties.
1062 /// <seealso cref="Annotation.SmartLabelStyle"/>
1065 /// This class is derived from the <b>SmartLabelStyle</b> class
1066 /// used for <b>Series</b> objects.
1069 DefaultProperty("Enabled"),
1070 SRDescription("DescriptionAttributeAnnotationSmartLabelsStyle_AnnotationSmartLabelsStyle"),
1071 TypeConverter(typeof(NoNameExpandableObjectConverter)),
1074 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
1075 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
1077 public class AnnotationSmartLabelStyle : SmartLabelStyle
1079 #region Constructors and initialization
1082 /// Default public constructor.
1084 public AnnotationSmartLabelStyle()
1086 this.chartElement = null;
1092 /// <param name="chartElement">
1093 /// Chart element this style belongs to.
1095 public AnnotationSmartLabelStyle(Object chartElement) : base(chartElement)
1101 #region Non Applicable Appearance Attributes (set as Non-Browsable)
1105 /// Callout style of the repositioned smart labels.
1108 /// This method is for internal use and is hidden at design time and runtime.
1111 SRCategory("CategoryAttributeMisc"),
1113 EditorBrowsableAttribute(EditorBrowsableState.Never),
1114 DefaultValue(LabelCalloutStyle.Underlined),
1115 SRDescription("DescriptionAttributeCalloutStyle3"),
1117 override public LabelCalloutStyle CalloutStyle
1121 return base.CalloutStyle;
1125 base.CalloutStyle = value;
1130 /// Label callout line color.
1133 /// This method is for internal use and is hidden at design and run time.
1136 SRCategory("CategoryAttributeAppearance"),
1138 EditorBrowsableAttribute(EditorBrowsableState.Never),
1139 DefaultValue(typeof(Color), "Black"),
1140 SRDescription("DescriptionAttributeCalloutLineColor"),
1141 TypeConverter(typeof(ColorConverter)),
1142 Editor(Editors.ChartColorEditor.Editor, Editors.ChartColorEditor.Base)
1144 override public Color CalloutLineColor
1148 return base.CalloutLineColor;
1152 base.CalloutLineColor = value;
1157 /// Label callout line style.
1160 /// This method is for internal use and is hidden at design and run time.
1163 SRCategory("CategoryAttributeAppearance"),
1165 EditorBrowsableAttribute(EditorBrowsableState.Never),
1166 DefaultValue(ChartDashStyle.Solid),
1167 SRDescription("DescriptionAttributeLineDashStyle"),
1168 #if !Microsoft_CONTROL
1169 PersistenceMode(PersistenceMode.Attribute)
1172 override public ChartDashStyle CalloutLineDashStyle
1176 return base.CalloutLineDashStyle;
1180 base.CalloutLineDashStyle = value;
1185 /// Label callout back color. Applies to the Box style only.
1188 /// This method is for internal use and is hidden at design and run time.
1191 SRCategory("CategoryAttributeAppearance"),
1193 EditorBrowsableAttribute(EditorBrowsableState.Never),
1194 DefaultValue(typeof(Color), "Transparent"),
1195 SRDescription("DescriptionAttributeCalloutBackColor"),
1196 TypeConverter(typeof(ColorConverter)),
1197 Editor(Editors.ChartColorEditor.Editor, Editors.ChartColorEditor.Base)
1199 override public Color CalloutBackColor
1203 return base.CalloutBackColor;
1207 base.CalloutBackColor = value;
1212 /// Label callout line width.
1215 /// This method is for internal use and is hidden at design and run time.
1218 SRCategory("CategoryAttributeAppearance"),
1220 EditorBrowsableAttribute(EditorBrowsableState.Never),
1222 SRDescription("DescriptionAttributeLineWidth"),
1224 override public int CalloutLineWidth
1228 return base.CalloutLineWidth;
1232 base.CalloutLineWidth = value;
1237 /// Label callout line anchor cap.
1240 /// This method is for internal use and is hidden at design and run time.
1243 SRCategory("CategoryAttributeAppearance"),
1245 EditorBrowsableAttribute(EditorBrowsableState.Never),
1246 DefaultValue(LineAnchorCapStyle.Arrow),
1247 SRDescription("DescriptionAttributeCalloutLineAnchorCapStyle"),
1249 override public LineAnchorCapStyle CalloutLineAnchorCapStyle
1253 return base.CalloutLineAnchorCapStyle;
1257 base.CalloutLineAnchorCapStyle = value;