Autor Beitrag
Bummibaer
Hält's aus hier
Beiträge: 7

Win XP,Solaris,Linux
perl,C#
BeitragVerfasst: Do 19.03.09 13:57 
Hallo,

was mache ich hier falsch. Ich möchte eine Zeitreihe, die von einem Timer
geliefert wird in ein Panel zeichnen.
Das Bild flackert ziemlich stark.
Die paar Punkte (Größenordnung 255) sollten doch ohne Flackern gezeichnet werden.


xBegin bezeichnet meinen Ausschnitt in der Datenreihe points.

Sollte ich grundsätzlich am Ende das Dispose einfügen?

Vielen Dank für Hinweise,

Steffen


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
       public Form1()
        {
            InitializeComponent();
           // Doublebuffering einschalten
            this.SetStyle(
              ControlStyles.AllPaintingInWmPaint |
             ControlStyles.UserPaint |
             ControlStyles.DoubleBuffer, true);
             this.timer1.Interval = 20;

        }

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Panel p = (Panel)sender;
            Graphics g = e.Graphics;
 
            int pCount = points.Count;

            
            int PanelHeight = p.Height;
            int PanelWidth = p.Width;
            int ClientHeight = p.ClientRectangle.Height;
            int ClientWidth = p.ClientRectangle.Width;
            float ClipHeight = g.ClipBounds.Height;
            float ClipWidth = g.ClipBounds.Width;
            int eClipLeft = e.ClipRectangle.Left;
            int eClipRight = e.ClipRectangle.Right;
            Point asPosition = p.AutoScrollPosition;

            int xBegin; // Beginn des Daten-Ausschnitt
            int xEnd;   // Ende des Zeichen-Bereiches
            xBegin   = - asPosition.X + 1;
            xEnd     =  eClipRight > pCount ? pCount :  eClipRight;

            GraphicsPath gp = new GraphicsPath();
            for (int x = 1; x < xEnd; x++)
            {
                gp.AddLine(x - 1, points[xBegin - 1] * yScale * mAmpScale, x, points[xBegin] * yScale * mAmpScale);
                if ((xBegin % 100) == 0)
                {
                    g.DrawString(xBegin.ToString(), pFont, bECG, (float)x, 10.0f);
                }
                xBegin++;
            }
            g.DrawPath(pECG, gp);
            p.AutoScrollMinSize = new Size(pCount , PanelHeight);

/*  Macht das ganze noch schlimmer
            g.DrawLine(pTest, 0, 0, PanelWidth, PanelHeight);
            g.DrawLine(pTest, 0, PanelHeight, PanelWidth, 0);
*/


            if (bScroll)
            {
                p.AutoScrollPosition = new Point(pCount - p.Width, p.AutoScrollPosition.Y);
            }
            // gp.Dispose();
            // g.Dispose();
        }
Console.Beep()
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 43

Win XP, Ubuntu 8.10
C# (VS 2008 Exp) C++ (VS 2008 Exp)
BeitragVerfasst: Do 19.03.09 15:18 
Schau hier mal rein:

www.mycsharp.de/wbb2...d.php?threadid=59978

Dispose solltest du nicht unbedingt nutzen das macht das Prog nur langsamer

_________________
Ihr zweifelt an der Existenz der If-Schleife??? Ihr müsst nur fest daran glauben!!!