c# - PictureBox Refresh causes layers above to flicker -
I am trying to read data from ports and show that the background on the dial is a picturebox in which a circular scale There is an image in which the reading is done, and the lineship is used to represent the dial. Pictureboxes are 'sent back' to allow the visibility of the lineship. I am attaching the representative code: If I do this:
Private zero timer 1 volt (object sender, eventAggas E) {ang + 2.0 * meth. PI / 180.0; LineShap 1.x1 = convert.OINT32 (lineup 1.x2-r * monastery seam (angle)); Line Shape1.Y1 = Convert. ToInt32 (Lineship 1. Y2 - r * Math. Cos (Angle)); }
Then it leaves a trace on the picture box.
But if I use the refresh function of the picturebox, the dial appears for flicker. I have tried with the timer interval of 10, 15, 20, 50 and 100, but the problem persists.
Private zero timer 1 volt (object sender, event ergugged E) {ang + 2.0 * meth. PI / 180.0; LineShap 1.x1 = convert.OINT32 (lineup 1.x2-r * monastery seam (angle)); Line Shape1.Y1 = Convert. ToInt32 (Lineship 1. Y2 - r * Math. Cos (Angle)); PictureBox1.Refresh (); }
For the real problem, an increase in the gap is not possible. What can I do to show a smooth variety of dials?
As suggested by @Hans Pace, you should not use a lineshap object An example that implements their suggestions (quick, unused):
Private zero timer 1 volt (object sender, eventAgps E) {pictureBox1.Invalidate (); } Zero imagebox 1_Paint (object sender, paint event ARG E) {ang + = 2.0 * meth. PI / 180.0; Var X1 = Convert ToInt32 (X2 - R * Math. Sign (Angle)); Var Y1 = Convert toInt32 (Y2 - r * Math.Cos (angle)); E.Graphics.SmoothingMode = SmoothingMode.AntiAlias; E.Graphics.DrawLine (new pen (color. Yellow, 1f), new point (x1, y1), new point (x2, y2)); }
Also, to avoid spry problem, this.Doublebuffered = true; Try setting
.
Comments
Post a Comment