Stefans,
stefans wrote:
maybe i have to tell you, that the current tee-chart implementation has the delay issue too (in case your program manager would probably not be very happy). You can do the following to check it out by yourself:
Ok, I've now implemented this code in TeeChart for testing purposes. I started out with some timing, e.g.
Code: Select all
long start, stop;
void tChart1_BeforeDraw(object sender, Graphics3D g)
{
start = DateTime.Now.Ticks;
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
stop = DateTime.Now.Ticks;
TimeSpan ts = TimeSpan.FromTicks(stop - start);
this.Text = ts.TotalMilliseconds.ToString();
System.Threading.Thread.Sleep(1000);
stop = DateTime.Now.Ticks;
ts = TimeSpan.FromTicks(stop - start);
this.Text += " " + ts.TotalMilliseconds.ToString();
}
Here I could detect little differences in the times between the new 'manual' buffering and how the code was. This is good news, in the sense that the code seems to have little to no performance impact. However, from what you told me I was expecting the Thread.Sleep to produce a noticeable visible difference between the two buffering methods, but I could detect none. On the first run of the form, neither chart showed anything before the first time appeared and and both only showed when the second time appeared. The same happened when zooming on the chart (to imitate repainting).
There is another issue with this technique. In TeeChart, we have a Panel.Transparent property. This can be emulated in the code we've been using thus:
Code: Select all
private void Draw(Rectangle rect, Graphics g)
{
++count;
if (!transparent)
{
g.FillRectangle(Brushes.Green, rect);
}
Font font = new Font(FontFamily.GenericSansSerif, 16);
g.DrawString("ManualBufferedControl2: Times Drawed: " + count.ToString(), font, Brushes.Black, new PointF(10, 10));
//DrawRectangles(rect, g);
}
private bool transparent = false;
public bool Transparent
{
get { return transparent; }
set { transparent = value; }
}
The trouble is here that as the OnPaintBackround override is stopping this method from being called in the base class when using
double-buffering then the control appears black rather than transparent. Getting the colour of teechart's containing control is not an option, I think.
I agree with you that this 'manual' buffering implementation is the way to go. Now, if I could just get over this transparency problem and have a more convincing demonstration of the advantage of the 'manual'
buffer in the threading scenario, then I think we could actually convince the boss to include it into the production code <g>.