Custom OnPaint additions with new release

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Loz
Newbie
Newbie
Posts: 18
Joined: Wed May 30, 2007 12:00 am

Custom OnPaint additions with new release

Post by Loz » Wed Oct 10, 2007 1:28 pm

Hi,

Firstly I wanted to mention that the latest update with the double buffering update is excellent. It’s nice and fast after it’s created the chart, no more sluggish windows.

We have one minor problem as a side effect though which I’m hoping you can help with. We override the OnPaint handler to write custom header and footer information and provide some hot-tracking in a Windows Forms application. What we’re finding is that the header and footer information doesn’t always get redrawn properly when windows are dragged over the top. The underlying chart is fine but if we drag a form over the top quickly, sometimes we only see part of the custom text.

We could probably get rid of most of the existing header and footer code and re-write it to use the chart annotation method but if there’s a simple way around it to accommodate the new changes, we’d prefer to do it that way.

It would be good to know in case there are other occasions we need to override the OnPaint handler.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Oct 11, 2007 10:02 am

Hi Loz,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Loz
Newbie
Newbie
Posts: 18
Joined: Wed May 30, 2007 12:00 am

Post by Loz » Thu Oct 11, 2007 12:29 pm

I've posted an example...

The project file is called: ChartOnPaint.rar

The OnPaint handler is in DerivedControls.cs

The function that writes the custom text is DrawHeaderAndFooterText.

We're also doing a few other custom bits and pieces but I've tried to create a basic stripped down example that demonstrates the issue.

To replicate the problem, quickly drag another window over the application when it's running. e.g. Explorer or anything else you have open and you'll see that the thumbnail is painted from what I assume to be the internally cached buffer which doesn't include the added text.

Thanks.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 15, 2007 1:46 pm

Hi Loz,

Thanks for the example project. You can achieve what you request changing your OnPaint override for this:

Code: Select all

		private BufferedGraphics bGraphics;
		private Steema.TeeChart.IChart parent;

		protected override void OnPaint(PaintEventArgs pe)
		{
			base.OnPaint(pe);
			parent = Chart.Parent;
			bGraphics = parent.GetBackBuffer();
			DrawHeaderAndFooterText(bGraphics.Graphics);
			bGraphics.Render();
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Loz
Newbie
Newbie
Posts: 18
Joined: Wed May 30, 2007 12:00 am

Post by Loz » Mon Oct 15, 2007 2:06 pm

That's great, many thanks. We'll get the changes put in place as soon as we can.

Thanks for your excellent support.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 15, 2007 2:25 pm

Hi Loz,

You're very welcome! We are glad to hear that helped.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Oct 22, 2007 11:24 am

Hello Loz,

Please be aware that in future releases, the code below will not compile:

Code: Select all

      private BufferedGraphics bGraphics;
      private Steema.TeeChart.IChart parent;

      protected override void OnPaint(PaintEventArgs pe)
      {
         base.OnPaint(pe);
         parent = Chart.Parent;
         bGraphics = parent.GetBackBuffer();
         DrawHeaderAndFooterText(bGraphics.Graphics);
         bGraphics.Render();
      }
The code has been refactored somewhat meaning that the BufferedGraphics class will be available directly from the TeeChart Graphics3D class. The following code will therefore replace the above:

Code: Select all

      protected override void OnPaint(PaintEventArgs pe)
		{
			base.OnPaint(pe);
			DrawHeaderAndFooterText(Chart.Graphics3D.BackBuffer.Graphics);
			Chart.Graphics3D.BackBuffer.Render();
		}
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply