GroupAnnotation.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. //
  5. // Purpose: Annotation group class.
  6. //
  7. using System;
  8. using System.ComponentModel;
  9. using System.Drawing;
  10. using System.Drawing.Design;
  11. using FastReport.DataVisualization.Charting.Utilities;
  12. namespace FastReport.DataVisualization.Charting
  13. {
  14. /// <summary>
  15. /// <b>AnnotationGroup</b> is a class that represents an annotation group.
  16. /// </summary>
  17. /// <remarks>
  18. /// This class is a collection of annotations, and can be used
  19. /// to manipulate annotations relative to each other.
  20. /// </remarks>
  21. [
  22. SRDescription("DescriptionAttributeAnnotationGroup_AnnotationGroup"),
  23. ]
  24. public class AnnotationGroup : Annotation
  25. {
  26. #region Fields
  27. // Collection of annotations in the group
  28. internal AnnotationCollection annotations = null;
  29. #endregion
  30. #region Construction and Initialization
  31. /// <summary>
  32. /// Default public constructor.
  33. /// </summary>
  34. public AnnotationGroup()
  35. : base()
  36. {
  37. annotations = new AnnotationCollection(this);
  38. annotations.AnnotationGroup = this;
  39. }
  40. #endregion
  41. #region Miscellaneous Properties
  42. /// <summary>
  43. /// Gets or sets the name of the chart area which an annotation is clipped to.
  44. /// </summary>
  45. /// <value>
  46. /// A string which represents the name of an existing chart area.
  47. /// </value>
  48. /// <remarks>
  49. /// If the chart area name is specified, an annotation will only be drawn inside the
  50. /// plotting area of the chart area specified. All parts of the annotation
  51. /// outside of the plotting area will be clipped.
  52. /// <para>
  53. /// To disable chart area clipping, set the property to "NotSet" or an empty string.
  54. /// </para>
  55. /// </remarks>
  56. [
  57. SRCategory("CategoryAttributeMisc"),
  58. DefaultValue(Constants.NotSetValue),
  59. SRDescription("DescriptionAttributeAnnotationGroup_ClipToChartArea"),
  60. TypeConverter(typeof(LegendAreaNameConverter)),
  61. Browsable(false),
  62. ]
  63. override public string ClipToChartArea
  64. {
  65. get
  66. {
  67. return base.ClipToChartArea;
  68. }
  69. set
  70. {
  71. base.ClipToChartArea = value;
  72. foreach(Annotation annotation in this.annotations)
  73. {
  74. annotation.ClipToChartArea = value;
  75. }
  76. }
  77. }
  78. #endregion
  79. #region Position Properties
  80. /// <summary>
  81. /// Gets or sets a flag that specifies whether the size of an annotation is always
  82. /// defined in relative chart coordinates.
  83. /// <seealso cref="Annotation.Width"/>
  84. /// <seealso cref="Annotation.Height"/>
  85. /// </summary>
  86. /// <value>
  87. /// <b>True</b> if an annotation's <see cref="Annotation.Width"/> and <see cref="Annotation.Height"/> are always
  88. /// in chart relative coordinates, <b>false</b> otherwise.
  89. /// </value>
  90. /// <remarks>
  91. /// An annotation's width and height may be set in relative chart or axes coordinates.
  92. /// By default, relative chart coordinates are used.
  93. /// <para>
  94. /// To use axes coordinates for size set the <b>IsSizeAlwaysRelative</b> property to
  95. /// <b>false</b> and either anchor the annotation to a data point or set the
  96. /// <see cref="Annotation.AxisX"/> or <see cref="Annotation.AxisY"/> properties.
  97. /// </para>
  98. /// </remarks>
  99. [
  100. SRCategory("CategoryAttributePosition"),
  101. DefaultValue(true),
  102. SRDescription("DescriptionAttributeAnnotationGroup_SizeAlwaysRelative"),
  103. ]
  104. override public bool IsSizeAlwaysRelative
  105. {
  106. get
  107. {
  108. return base.IsSizeAlwaysRelative;
  109. }
  110. set
  111. {
  112. base.IsSizeAlwaysRelative = value;
  113. }
  114. }
  115. #endregion
  116. #region Visual Properties
  117. /// <summary>
  118. /// Gets or sets a flag that determines if an annotation is selected.
  119. /// <seealso cref="Annotation.AllowSelecting"/>
  120. /// </summary>
  121. /// <value>
  122. /// <b>True</b> if the annotation is selected, <b>false</b> otherwise.
  123. /// </value>
  124. [
  125. SRCategory("CategoryAttributeAppearance"),
  126. DefaultValue(false),
  127. Browsable(false),
  128. SRDescription("DescriptionAttributeAnnotationGroup_Selected"),
  129. ]
  130. override public bool IsSelected
  131. {
  132. get
  133. {
  134. return base.IsSelected;
  135. }
  136. set
  137. {
  138. base.IsSelected = value;
  139. // Clear selection for all annotations in the group
  140. foreach(Annotation annotation in this.annotations)
  141. {
  142. annotation.IsSelected = false;
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// Gets or sets a flag that specifies whether an annotation is visible.
  148. /// </summary>
  149. /// <value>
  150. /// <b>True</b> if the annotation is visible, <b>false</b> otherwise.
  151. /// </value>
  152. [
  153. SRCategory("CategoryAttributeAppearance"),
  154. DefaultValue(true),
  155. SRDescription("DescriptionAttributeAnnotationGroup_Visible"),
  156. ParenthesizePropertyNameAttribute(true),
  157. ]
  158. override public bool Visible
  159. {
  160. get
  161. {
  162. return base.Visible;
  163. }
  164. set
  165. {
  166. base.Visible = value;
  167. }
  168. }
  169. /// <summary>
  170. /// Gets or sets an annotation's content alignment.
  171. /// </summary>
  172. /// <value>
  173. /// A <see cref="ContentAlignment"/> value that represents the content alignment.
  174. /// </value>
  175. /// <remarks>
  176. /// This property is used to align text for <see cref="TextAnnotation"/>, <see cref="RectangleAnnotation"/>,
  177. /// <see cref="EllipseAnnotation"/> and <see cref="CalloutAnnotation"/> objects, and to align
  178. /// a non-scaled image inside an <see cref="ImageAnnotation"/> object.
  179. /// </remarks>
  180. [
  181. SRCategory("CategoryAttributeAppearance"),
  182. DefaultValue(typeof(ContentAlignment), "MiddleCenter"),
  183. SRDescription("DescriptionAttributeAlignment"),
  184. Browsable(false),
  185. ]
  186. override public ContentAlignment Alignment
  187. {
  188. get
  189. {
  190. return base.Alignment;
  191. }
  192. set
  193. {
  194. base.Alignment = value;
  195. foreach(Annotation annotation in this.annotations)
  196. {
  197. annotation.Alignment = value;
  198. }
  199. }
  200. }
  201. /// <summary>
  202. /// Gets or sets an annotation's text style.
  203. /// <seealso cref="Font"/>
  204. /// <seealso cref="ForeColor"/>
  205. /// </summary>
  206. /// <value>
  207. /// A <see cref="TextStyle"/> value used to draw an annotation's text.
  208. /// </value>
  209. [Browsable(false)]
  210. [EditorBrowsable(EditorBrowsableState.Never)]
  211. public override TextStyle TextStyle
  212. {
  213. get
  214. {
  215. return base.TextStyle;
  216. }
  217. set
  218. {
  219. base.TextStyle = value;
  220. }
  221. }
  222. /// <summary>
  223. /// Gets or sets the text color of an annotation.
  224. /// <seealso cref="Font"/>
  225. /// </summary>
  226. /// <value>
  227. /// A <see cref="Color"/> value used for the text color of an annotation.
  228. /// </value>
  229. [
  230. SRCategory("CategoryAttributeAppearance"),
  231. DefaultValue(typeof(Color), "Black"),
  232. SRDescription("DescriptionAttributeForeColor"),
  233. TypeConverter(typeof(ColorConverter)),
  234. #if DESIGNER
  235. Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
  236. #endif
  237. Browsable(false),
  238. ]
  239. override public Color ForeColor
  240. {
  241. get
  242. {
  243. return base.ForeColor;
  244. }
  245. set
  246. {
  247. base.ForeColor = value;
  248. foreach(Annotation annotation in this.annotations)
  249. {
  250. annotation.ForeColor = value;
  251. }
  252. }
  253. }
  254. /// <summary>
  255. /// Gets or sets the font of an annotation's text.
  256. /// <seealso cref="ForeColor"/>
  257. /// </summary>
  258. /// <value>
  259. /// A <see cref="Font"/> object used for an annotation's text.
  260. /// </value>
  261. [
  262. SRCategory("CategoryAttributeAppearance"),
  263. DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"),
  264. SRDescription("DescriptionAttributeTextFont"),
  265. Browsable(false),
  266. ]
  267. override public Font Font
  268. {
  269. get
  270. {
  271. return base.Font;
  272. }
  273. set
  274. {
  275. base.Font = value;
  276. foreach(Annotation annotation in this.annotations)
  277. {
  278. annotation.Font = value;
  279. }
  280. }
  281. }
  282. /// <summary>
  283. /// Gets or sets the color of an annotation line.
  284. /// <seealso cref="LineWidth"/>
  285. /// <seealso cref="LineDashStyle"/>
  286. /// </summary>
  287. /// <value>
  288. /// A <see cref="Color"/> value used to draw an annotation line.
  289. /// </value>
  290. [
  291. SRCategory("CategoryAttributeAppearance"),
  292. DefaultValue(typeof(Color), "Black"),
  293. SRDescription("DescriptionAttributeLineColor"),
  294. TypeConverter(typeof(ColorConverter)),
  295. #if DESIGNER
  296. Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
  297. #endif
  298. Browsable(false),
  299. ]
  300. override public Color LineColor
  301. {
  302. get
  303. {
  304. return base.LineColor;
  305. }
  306. set
  307. {
  308. base.LineColor = value;
  309. foreach(Annotation annotation in this.annotations)
  310. {
  311. annotation.LineColor = value;
  312. }
  313. }
  314. }
  315. /// <summary>
  316. /// Gets or sets the width of an annotation line.
  317. /// <seealso cref="LineColor"/>
  318. /// <seealso cref="LineDashStyle"/>
  319. /// </summary>
  320. /// <value>
  321. /// An integer value defining the width of an annotation line in pixels.
  322. /// </value>
  323. [
  324. SRCategory("CategoryAttributeAppearance"),
  325. DefaultValue(1),
  326. SRDescription("DescriptionAttributeLineWidth"),
  327. Browsable(false),
  328. ]
  329. override public int LineWidth
  330. {
  331. get
  332. {
  333. return base.LineWidth;
  334. }
  335. set
  336. {
  337. base.LineWidth = value;
  338. foreach(Annotation annotation in this.annotations)
  339. {
  340. annotation.LineWidth = value;
  341. }
  342. }
  343. }
  344. /// <summary>
  345. /// Gets or sets the style of an annotation line.
  346. /// <seealso cref="LineWidth"/>
  347. /// <seealso cref="LineColor"/>
  348. /// </summary>
  349. /// <value>
  350. /// A <see cref="ChartDashStyle"/> value used to draw an annotation line.
  351. /// </value>
  352. [
  353. SRCategory("CategoryAttributeAppearance"),
  354. DefaultValue(ChartDashStyle.Solid),
  355. SRDescription("DescriptionAttributeLineDashStyle"),
  356. Browsable(false),
  357. ]
  358. override public ChartDashStyle LineDashStyle
  359. {
  360. get
  361. {
  362. return base.LineDashStyle;
  363. }
  364. set
  365. {
  366. base.LineDashStyle = value;
  367. foreach(Annotation annotation in this.annotations)
  368. {
  369. annotation.LineDashStyle = value;
  370. }
  371. }
  372. }
  373. /// <summary>
  374. /// Gets or sets the background color of an annotation.
  375. /// <seealso cref="BackSecondaryColor"/>
  376. /// <seealso cref="BackHatchStyle"/>
  377. /// <seealso cref="BackGradientStyle"/>
  378. /// </summary>
  379. /// <value>
  380. /// A <see cref="Color"/> value used for the background of an annotation.
  381. /// </value>
  382. [
  383. SRCategory("CategoryAttributeAppearance"),
  384. DefaultValue(typeof(Color), ""),
  385. SRDescription("DescriptionAttributeBackColor"),
  386. NotifyParentPropertyAttribute(true),
  387. TypeConverter(typeof(ColorConverter)),
  388. #if DESIGNER
  389. Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
  390. #endif
  391. Browsable(false),
  392. ]
  393. override public Color BackColor
  394. {
  395. get
  396. {
  397. return base.BackColor;
  398. }
  399. set
  400. {
  401. base.BackColor = value;
  402. foreach(Annotation annotation in this.annotations)
  403. {
  404. annotation.BackColor = value;
  405. }
  406. }
  407. }
  408. /// <summary>
  409. /// Gets or sets the background hatch style of an annotation.
  410. /// <seealso cref="BackSecondaryColor"/>
  411. /// <seealso cref="BackColor"/>
  412. /// <seealso cref="BackGradientStyle"/>
  413. /// </summary>
  414. /// <value>
  415. /// A <see cref="ChartHatchStyle"/> value used for the background of an annotation.
  416. /// </value>
  417. /// <remarks>
  418. /// Two colors are used to draw the hatching, <see cref="BackColor"/> and <see cref="BackSecondaryColor"/>.
  419. /// </remarks>
  420. [
  421. SRCategory("CategoryAttributeAppearance"),
  422. DefaultValue(ChartHatchStyle.None),
  423. NotifyParentPropertyAttribute(true),
  424. SRDescription("DescriptionAttributeBackHatchStyle"),
  425. #if DESIGNER
  426. Editor(typeof(HatchStyleEditor), typeof(UITypeEditor)),
  427. #endif
  428. Browsable(false),
  429. ]
  430. override public ChartHatchStyle BackHatchStyle
  431. {
  432. get
  433. {
  434. return base.BackHatchStyle;
  435. }
  436. set
  437. {
  438. base.BackHatchStyle = value;
  439. foreach(Annotation annotation in this.annotations)
  440. {
  441. annotation.BackHatchStyle = value;
  442. }
  443. }
  444. }
  445. /// <summary>
  446. /// Gets or sets the background gradient style of an annotation.
  447. /// <seealso cref="BackSecondaryColor"/>
  448. /// <seealso cref="BackColor"/>
  449. /// <seealso cref="BackHatchStyle"/>
  450. /// </summary>
  451. /// <value>
  452. /// A <see cref="GradientStyle"/> value used for the background of an annotation.
  453. /// </value>
  454. /// <remarks>
  455. /// Two colors are used to draw the gradient, <see cref="BackColor"/> and <see cref="BackSecondaryColor"/>.
  456. /// </remarks>
  457. [
  458. SRCategory("CategoryAttributeAppearance"),
  459. DefaultValue(GradientStyle.None),
  460. NotifyParentPropertyAttribute(true),
  461. SRDescription("DescriptionAttributeBackGradientStyle"),
  462. #if DESIGNER
  463. Editor(typeof(GradientEditor), typeof(UITypeEditor))
  464. #endif
  465. Browsable(false),
  466. ]
  467. override public GradientStyle BackGradientStyle
  468. {
  469. get
  470. {
  471. return base.BackGradientStyle;
  472. }
  473. set
  474. {
  475. base.BackGradientStyle = value;
  476. foreach(Annotation annotation in this.annotations)
  477. {
  478. annotation.BackGradientStyle = value;
  479. }
  480. }
  481. }
  482. /// <summary>
  483. /// Gets or sets the secondary background color of an annotation.
  484. /// <seealso cref="BackColor"/>
  485. /// <seealso cref="BackHatchStyle"/>
  486. /// <seealso cref="BackGradientStyle"/>
  487. /// </summary>
  488. /// <value>
  489. /// A <see cref="Color"/> value used for the secondary color of an annotation background with
  490. /// hatching or gradient fill.
  491. /// </value>
  492. /// <remarks>
  493. /// This color is used with <see cref="BackColor"/> when <see cref="BackHatchStyle"/> or
  494. /// <see cref="BackGradientStyle"/> are used.
  495. /// </remarks>
  496. [
  497. SRCategory("CategoryAttributeAppearance"),
  498. DefaultValue(typeof(Color), ""),
  499. NotifyParentPropertyAttribute(true),
  500. SRDescription("DescriptionAttributeBackSecondaryColor"),
  501. TypeConverter(typeof(ColorConverter)),
  502. #if DESIGNER
  503. Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
  504. #endif
  505. Browsable(false),
  506. ]
  507. override public Color BackSecondaryColor
  508. {
  509. get
  510. {
  511. return base.BackSecondaryColor;
  512. }
  513. set
  514. {
  515. base.BackSecondaryColor = value;
  516. foreach(Annotation annotation in this.annotations)
  517. {
  518. annotation.BackSecondaryColor = value;
  519. }
  520. }
  521. }
  522. /// <summary>
  523. /// Gets or sets the color of an annotation's shadow.
  524. /// <seealso cref="ShadowOffset"/>
  525. /// </summary>
  526. /// <value>
  527. /// A <see cref="Color"/> value used to draw an annotation's shadow.
  528. /// </value>
  529. [
  530. SRCategory("CategoryAttributeAppearance"),
  531. DefaultValue(typeof(Color), "128,0,0,0"),
  532. SRDescription("DescriptionAttributeShadowColor"),
  533. TypeConverter(typeof(ColorConverter)),
  534. #if DESIGNER
  535. Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
  536. #endif
  537. Browsable(false),
  538. ]
  539. override public Color ShadowColor
  540. {
  541. get
  542. {
  543. return base.ShadowColor;
  544. }
  545. set
  546. {
  547. base.ShadowColor = value;
  548. foreach(Annotation annotation in this.annotations)
  549. {
  550. annotation.ShadowColor = value;
  551. }
  552. }
  553. }
  554. /// <summary>
  555. /// Gets or sets the offset between an annotation and its shadow.
  556. /// <seealso cref="ShadowColor"/>
  557. /// </summary>
  558. /// <value>
  559. /// An integer value that represents the offset between an annotation and its shadow.
  560. /// </value>
  561. [
  562. SRCategory("CategoryAttributeAppearance"),
  563. DefaultValue(0),
  564. SRDescription("DescriptionAttributeShadowOffset"),
  565. Browsable(false),
  566. ]
  567. override public int ShadowOffset
  568. {
  569. get
  570. {
  571. return base.ShadowOffset;
  572. }
  573. set
  574. {
  575. base.ShadowOffset = value;
  576. foreach(Annotation annotation in this.annotations)
  577. {
  578. annotation.ShadowOffset = value;
  579. }
  580. }
  581. }
  582. #endregion
  583. #region Editing Permissions Properties
  584. /// <summary>
  585. /// Gets or sets a flag that specifies whether an annotation may be selected
  586. /// with a mouse by the end user.
  587. /// </summary>
  588. /// <value>
  589. /// <b>True</b> if the annotation may be selected, <b>false</b> otherwise.
  590. /// </value>
  591. [
  592. SRCategory("CategoryAttributeEditing"),
  593. DefaultValue(false),
  594. SRDescription("DescriptionAttributeAllowSelecting"),
  595. ]
  596. override public bool AllowSelecting
  597. {
  598. get
  599. {
  600. return base.AllowSelecting;
  601. }
  602. set
  603. {
  604. base.AllowSelecting = value;
  605. }
  606. }
  607. /// <summary>
  608. /// Gets or sets a flag that specifies whether an annotation may be moved
  609. /// with a mouse by the end user.
  610. /// </summary>
  611. /// <value>
  612. /// <b>True</b> if the annotation may be moved, <b>false</b> otherwise.
  613. /// </value>
  614. [
  615. SRCategory("CategoryAttributeEditing"),
  616. DefaultValue(false),
  617. SRDescription("DescriptionAttributeAllowMoving"),
  618. ]
  619. override public bool AllowMoving
  620. {
  621. get
  622. {
  623. return base.AllowMoving;
  624. }
  625. set
  626. {
  627. base.AllowMoving = value;
  628. }
  629. }
  630. /// <summary>
  631. /// Gets or sets a flag that specifies whether an annotation anchor may be moved
  632. /// with a mouse by the end user.
  633. /// </summary>
  634. /// <value>
  635. /// <b>True</b> if the annotation anchor may be moved, <b>false</b> otherwise.
  636. /// </value>
  637. [
  638. SRCategory("CategoryAttributeEditing"),
  639. DefaultValue(false),
  640. SRDescription("DescriptionAttributeAnnotationGroup_AllowAnchorMoving"),
  641. ]
  642. override public bool AllowAnchorMoving
  643. {
  644. get
  645. {
  646. return base.AllowAnchorMoving;
  647. }
  648. set
  649. {
  650. base.AllowAnchorMoving = value;
  651. }
  652. }
  653. /// <summary>
  654. /// Gets or sets a flag that specifies whether an annotation may be resized
  655. /// with a mouse by the end user.
  656. /// </summary>
  657. /// <value>
  658. /// <b>True</b> if the annotation may be resized, <b>false</b> otherwise.
  659. /// </value>
  660. [
  661. SRCategory("CategoryAttributeEditing"),
  662. DefaultValue(false),
  663. SRDescription("DescriptionAttributeAllowResizing"),
  664. ]
  665. override public bool AllowResizing
  666. {
  667. get
  668. {
  669. return base.AllowResizing;
  670. }
  671. set
  672. {
  673. base.AllowResizing = value;
  674. }
  675. }
  676. /// <summary>
  677. /// Gets or sets a flag that specifies whether an annotation's text may be edited
  678. /// when the end user double clicks on the text.
  679. /// </summary>
  680. /// <value>
  681. /// <b>True</b> if the annotation text may be edited, <b>false</b> otherwise.
  682. /// </value>
  683. [
  684. SRCategory("CategoryAttributeEditing"),
  685. DefaultValue(false),
  686. SRDescription("DescriptionAttributeAllowTextEditing"),
  687. ]
  688. override public bool AllowTextEditing
  689. {
  690. get
  691. {
  692. return base.AllowTextEditing;
  693. }
  694. set
  695. {
  696. base.AllowTextEditing = value;
  697. }
  698. }
  699. /// <summary>
  700. /// Gets or sets a flag that specifies whether a polygon annotation's points
  701. /// may be moved with a mouse by the end user.
  702. /// </summary>
  703. /// <value>
  704. /// <b>True</b> if the polygon annotation's points may be moved, <b>false</b> otherwise.
  705. /// </value>
  706. [
  707. SRCategory("CategoryAttributeEditing"),
  708. DefaultValue(false),
  709. SRDescription("DescriptionAttributeAnnotationGroup_AllowPathEditing"),
  710. ]
  711. override public bool AllowPathEditing
  712. {
  713. get
  714. {
  715. return base.AllowPathEditing;
  716. }
  717. set
  718. {
  719. base.AllowPathEditing = value;
  720. }
  721. }
  722. #endregion
  723. #region Other Properties
  724. /// <summary>
  725. /// Gets the collection of annotations in the group.
  726. /// </summary>
  727. /// <value>
  728. /// An <see cref="AnnotationCollection"/> object.
  729. /// </value>
  730. /// <remarks>
  731. /// Note that the coordinates of all annotations in the group are relative to the
  732. /// group annotation.
  733. /// </remarks>
  734. [
  735. SRCategory("CategoryAttributeAnnotations"),
  736. SRDescription("DescriptionAttributeAnnotationGroup_Annotations"),
  737. #if DESIGNER
  738. Editor(typeof(AnnotationCollectionEditor), typeof(UITypeEditor)),
  739. #endif
  740. DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
  741. ]
  742. public AnnotationCollection Annotations
  743. {
  744. get
  745. {
  746. return annotations;
  747. }
  748. }
  749. /// <summary>
  750. /// Gets or sets an annotation's type name.
  751. /// </summary>
  752. /// <remarks>
  753. /// This property is used to get the name of each annotation type
  754. /// (e.g. Line, Rectangle, Ellipse).
  755. /// <para>
  756. /// This property is for internal use and is hidden at design and run time.
  757. /// </para>
  758. /// </remarks>
  759. [
  760. SRCategory("CategoryAttributeMisc"),
  761. Bindable(true),
  762. Browsable(false),
  763. EditorBrowsableAttribute(EditorBrowsableState.Never),
  764. DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
  765. SerializationVisibilityAttribute(SerializationVisibility.Hidden),
  766. SRDescription("DescriptionAttributeAnnotationType"),
  767. ]
  768. public override string AnnotationType
  769. {
  770. get
  771. {
  772. return "Group";
  773. }
  774. }
  775. /// <summary>
  776. /// Gets or sets annotation selection points style.
  777. /// </summary>
  778. /// <value>
  779. /// A <see cref="SelectionPointsStyle"/> value that represents annotation
  780. /// selection style.
  781. /// </value>
  782. /// <remarks>
  783. /// This property is for internal use and is hidden at design and run time.
  784. /// </remarks>
  785. [
  786. SRCategory("CategoryAttributeAppearance"),
  787. DefaultValue(SelectionPointsStyle.Rectangle),
  788. ParenthesizePropertyNameAttribute(true),
  789. Browsable(false),
  790. EditorBrowsableAttribute(EditorBrowsableState.Never),
  791. DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
  792. SerializationVisibilityAttribute(SerializationVisibility.Hidden),
  793. SRDescription("DescriptionAttributeSelectionPointsStyle"),
  794. ]
  795. override internal SelectionPointsStyle SelectionPointsStyle
  796. {
  797. get
  798. {
  799. return SelectionPointsStyle.Rectangle;
  800. }
  801. }
  802. #endregion
  803. #region Methods
  804. /// <summary>
  805. /// Paints an annotation object using the specified graphics.
  806. /// </summary>
  807. /// <param name="graphics">
  808. /// A <see cref="ChartGraphics"/> object, used to paint the annotation object.
  809. /// </param>
  810. /// <param name="chart">
  811. /// Reference to the <see cref="Chart"/> control.
  812. /// </param>
  813. override internal void Paint(Chart chart, ChartGraphics graphics)
  814. {
  815. // Paint all annotations in the group
  816. foreach(Annotation annotation in this.annotations)
  817. {
  818. annotation.Paint(chart, graphics);
  819. }
  820. if( (this.Common.ProcessModePaint && this.IsSelected) ||
  821. this.Common.ProcessModeRegions )
  822. {
  823. // Get annotation position in relative coordinates
  824. PointF firstPoint = PointF.Empty;
  825. PointF anchorPoint = PointF.Empty;
  826. SizeF size = SizeF.Empty;
  827. GetRelativePosition(out firstPoint, out size, out anchorPoint);
  828. PointF secondPoint = new PointF(firstPoint.X + size.Width, firstPoint.Y + size.Height);
  829. // Create selection rectangle
  830. RectangleF selectionRect = new RectangleF(firstPoint, new SizeF(secondPoint.X - firstPoint.X, secondPoint.Y - firstPoint.Y));
  831. // Check rectangle orientation
  832. if(selectionRect.Width < 0)
  833. {
  834. selectionRect.X = selectionRect.Right;
  835. selectionRect.Width = -selectionRect.Width;
  836. }
  837. if(selectionRect.Height < 0)
  838. {
  839. selectionRect.Y = selectionRect.Bottom;
  840. selectionRect.Height = -selectionRect.Height;
  841. }
  842. // Check if text position is valid
  843. if( selectionRect.IsEmpty ||
  844. float.IsNaN(selectionRect.X) ||
  845. float.IsNaN(selectionRect.Y) ||
  846. float.IsNaN(selectionRect.Right) ||
  847. float.IsNaN(selectionRect.Bottom) )
  848. {
  849. return;
  850. }
  851. if(this.Common.ProcessModeRegions)
  852. {
  853. // Add hot region
  854. this.Common.HotRegionsList.AddHotRegion(
  855. selectionRect,
  856. ReplaceKeywords(this.ToolTip),
  857. String.Empty,
  858. String.Empty,
  859. String.Empty,
  860. this,
  861. ChartElementType.Annotation,
  862. String.Empty);
  863. }
  864. // Paint selection handles
  865. PaintSelectionHandles(graphics, selectionRect, null);
  866. }
  867. }
  868. #endregion // Methods
  869. #region IDisposable override
  870. /// <summary>
  871. /// Releases unmanaged and - optionally - managed resources
  872. /// </summary>
  873. /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
  874. protected override void Dispose(bool disposing)
  875. {
  876. if (disposing)
  877. {
  878. //Clean up managed resources
  879. if (this.annotations != null)
  880. {
  881. this.annotations.Dispose();
  882. this.annotations = null;
  883. }
  884. }
  885. base.Dispose(disposing);
  886. }
  887. #endregion
  888. }
  889. }