Page 1 of 1

Resizing freezes up WinForm

Posted: Tue Oct 07, 2008 9:09 pm
by 8739068
If I have many points on a chart (~1 million) and I try to resize the parent form of the chart by dragging a corner of the window, the form freezes up.

I have the chart's Anchor property set to Left, Right, Top, & Bottom.

I would like to have the chart not resize until the MouseUp event fires.

Any suggestions?

I have uploaded a sample project

Posted: Wed Oct 08, 2008 9:30 am
by narcis
Hi Mike,

You could try using AutoRepaint property as shown below. Does this help?

Code: Select all

        void tChart1_Resize(object sender, EventArgs e)
        {
            Debug.WriteLine(DateTime.Now.ToString() + "Chart Resizing");
						tChart1.AutoRepaint = true;
						tChart1.Refresh();
						tChart1.AutoRepaint = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Cursor oldCursor = this.Cursor;

            Debug.WriteLine(DateTime.Now.ToString() + " Adding million points");
            this.Cursor = Cursors.WaitCursor;
            this.points1.FillSampleValues(1000000);
            this.Cursor = oldCursor;

						tChart1.AutoRepaint = false;
        }

Suggestion does not work

Posted: Wed Oct 08, 2008 4:15 pm
by 8739068
The code suggestion does not work in the tChart1_Resize event. It appears that this event fires at the beginning of the dragging. I tried moving the code to the Form_MouseUp event. That did not help either.

It appears when the Chart Resizes it still wants to Repaint as I drag the corner of the form. Surprising because I verified that AutoRepaint = False.

There is 2 approaches to take

1. Try to prevent a repaint while dragging/resizing
2. Find ways to optimize the repainting within the TChart Control

Thoughts and ideas on either option?

Posted: Thu Oct 09, 2008 11:01 am
by narcis
Hi Mike,

Using your original code application doesn't freeze here when resizing. After resizing it takes some time to redraw the chart as with the first time the chart is drawn as you can see in the video here (needs to be viewed with Internet Explorer):

http://www.teechart.net/files/public/su ... s.swf.html

Is this the same behavior you are experiencing?

Also notice code below, this is your form Load event, I had to comment in one line as it was incomplete and therefore couldn't build the application. Does it make any difference for you?

Code: Select all

        private void Form1_Load(object sender, EventArgs e)
        {
            this.tChart1.Resize += new EventHandler(tChart1_Resize);
            this.tChart1.BeforeDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_BeforeDraw);
            this.tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
						//this.tChart1.re					
        }
Thanks in advance.

I see a different behavior

Posted: Thu Oct 09, 2008 3:00 pm
by 8739068
Oops on the code. Sorry I left that incomplete line in the code when I sent it.

The video you reference was the behavior I would like to see. I am not seeing that behavior. Instead as I drag, the dialog will freeze because it is repainting the chart as I am resizing. I can move the mouse about a millimeter and then it freezes while it redraws.

Any thoughts on why I see that behavior? Was there anything else you had to do with my project? I assume you might have had to change a reference to the Tchart.dll.

A side question, what did you use to create the video? That was very useful. I might want to do something like that for support issues. A video can be much better than trying to explain in emails.

Posted: Thu Oct 09, 2008 3:10 pm
by narcis
Hi Mike,
Oops on the code. Sorry I left that incomplete line in the code when I sent it.

The video you reference was the behavior I would like to see. I am not seeing that behavior. Instead as I drag, the dialog will freeze because it is repainting the chart as I am resizing. I can move the mouse about a millimeter and then it freezes while it redraws.
Don't you get the same behaviour as in the video commenting in that line? Otherwise, what should that line be?
Any thoughts on why I see that behavior? Was there anything else you had to do with my project? I assume you might have had to change a reference to the Tchart.dll.
I just commented in the line I mentioned and replaced the TeeChart reference to use our current sources. Very little changes have been made since latest maintenance release. Which TeeChart build are you using?
A side question, what did you use to create the video? That was very useful. I might want to do something like that for support issues. A video can be much better than trying to explain in emails.
Yes, I used CamStudio, an open source tool. However, there are other tools that might be more powerful, for example Camtasia.

What I am using

Posted: Thu Oct 09, 2008 3:45 pm
by 8739068
I am using Steema's binary version 3.5.3146.24805

I know that is about 1 version behind the latest.

I did what you had to do to run. My form_load looks like yours.

I am curious, What does your output tab look like when running under visual studio? You should see entries for the debug statements

here is a sample of what mine looks like when I attempt to resize (notice th time stamps)

10/9/2008 10:35:44 AMChart BeforeDraw
10/9/2008 10:35:44 AMChart AfterDraw
10/9/2008 10:35:51 AM Adding million points
10/9/2008 10:35:51 AMChart BeforeDraw
10/9/2008 10:36:31 AMChart AfterDraw
10/9/2008 10:36:44 AMChart Resizing <- Dialog FREEZE when attempting to resize
10/9/2008 10:36:44 AMChart BeforeDraw
10/9/2008 10:37:24 AMChart AfterDraw
10/9/2008 10:37:24 AMChart Resizing
10/9/2008 10:37:24 AMChart BeforeDraw
10/9/2008 10:38:03 AMChart AfterDraw


This results when I tried to do exactly what your video clip showed. It took about 1.5 minutes to show the resize. I don't see the outline of the form as I drag a corner like your video. I see the edge of the form move slightly, my mouse cursor changes to Cursors.SizeNESW and remains this cursor even when I move the mouse away from this form. The form turns white and as you can see in the output window debug statements it takes about 1.5 minutes before the form unfreezes and redraws to the screen.

I have uploaded my own video of what I am seeing on my end. The file name is ChartSizingProblem.swf

Posted: Fri Oct 10, 2008 9:16 am
by narcis
Hi Mike,
I am using Steema's binary version 3.5.3146.24805

I know that is about 1 version behind the latest.
Is it possible for you to try using latest build available at the client area?
I am curious, What does your output tab look like when running under visual studio? You should see entries for the debug statements
Sure, here's the output I get:

10/10/2008 10:55:41Chart BeforeDraw
10/10/2008 10:55:41Chart AfterDraw
10/10/2008 10:55:47 Adding million points
10/10/2008 10:55:48Chart BeforeDraw
10/10/2008 10:56:11Chart AfterDraw
10/10/2008 10:56:23Chart Resizing
10/10/2008 10:56:23Chart BeforeDraw
10/10/2008 10:56:46Chart AfterDraw
I have uploaded my own video of what I am seeing on my end. The file name is ChartSizingProblem.swf
Thanks but I'm afraid you only uploaded ChartSizingProblem.swf.html, you should also include ChartSizingProblem.swf for us to be able to see the video.

Thanks in advance.

Flash file uploaded

Posted: Fri Oct 10, 2008 1:35 pm
by 8739068
The other file has been uploaded.

Here is some observations on speed.

Code: Select all

Action                     Your Time        My Time
Adding a Million Points    24 seconds       40 seconds
Resizing to afterdraw      19 seconds       79 seconds
You also don't seem to get as many BeforeDraw/AfterDraw events to fire. This seems to indicate that something I am doing is causing these events to fire twice.

What speed of a processor are you running on with how much RAM?

I am using a 1.8 GHz with 2 Gb of RAM

Posted: Fri Oct 10, 2008 3:24 pm
by narcis
Hi Mike,

I tried using exactly the same build as you in VS2005, built the application in Debug mode and got identical results to what I posted before.
What speed of a processor are you running on with how much RAM?
I'm using an Intel Core 2 Quad 6600 CPU, 4 Gb RAM and a NVIDIA GeForce 8500 GT graphic card.

Could you please try running your project in another machine and check if results are the same? Could you also build it in release mode and send us your application's bin/Release folder so that we can run it here?

Thanks in advance.

Results

Posted: Fri Oct 10, 2008 5:12 pm
by 8739068
I just uploaded the bin\release build of the ChartMillionPoints test application.

Your test hardware is definitely much faster than mine. I tested the release build on another machine. This machine was a 3 GHz, P4 processor, with 1 Gb of memory, NVidia GeForce 5200. It did perform better and I did see the resizing work much more like your video.

I will try to implement the techniques you have shown here in my main application. It is not ideal, but will help us prevent complaints from our users.

Are future versions of TeeChart going to have any optimization in this area?

Posted: Mon Oct 13, 2008 1:38 pm
by narcis
Hi Mike,

Thanks for your files. They performed here in the same way my build did.

TeeChart is continually being optimized. Future versions may therefore contain optimizations further improve painting performance.