Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2407

Summary: Subsclassing annotation tool drawText method is not called.
Product: .NET TeeChart Reporter: pep jorge <pep>
Component: Xamarin.FormsAssignee: Steema Issue Manager <issuemanager>
Status: CONFIRMED ---    
Severity: enhancement    
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:
Attachments: sample

Description pep jorge 2021-03-29 05:43:34 EDT
Created attachment 960 [details]
sample

Related post :
http://support.steema.com/viewtopic.php?f=4&t=17492&sid=ab43c8c37b85b8f48aefaa218bc86c14

I got it to render, albeit incorrectly, by subclassing it and invoking the draw call to it. The DrawText method is NOT being called otherwise, for whatever reason.

Edit: AutoSize was being changed for some reason, somewhere. The sizing is ok.

This is a workaround:
[code]


	public class AnnotationTool : Annotation
	{
		public AnnotationTool( Chart chart, string text ) : this(chart) => Text = text;
		public AnnotationTool( Chart chart ) : base(chart)
		{
			Active = true;
			Position = AnnotationPositions.Custom;
			TextAlign = TextAlignment.Start;
			AutoSize = true;
			AllowEdit = false;
		}

		public Rectangle GetBounds()
		{
			 // forces a refresh.
			AutoSize = true;
			return Bounds;
		}


		public void Draw( Graphics3D g ) { DrawText(g); }
	}
	
	
	// In the graphing page, attach to the AfterDraw event
	private void TChart1_Annotations_AfterDraw( object sender, Graphics3D g )
	{
		/// ...
		AnnotationTool.Draw(g);
		/// ...
	}

[/code]