473,378 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

draw a wave in VB.net panel

91
Hi,

I need to draw a'wave form' in a panel inVB.net, the wave form will be updated once every one second. the problem is the screen blinking whenever it is updated. how can I solve this problem? the paint event code as below.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
  2.         Dim i As Integer
  3.         Dim x, y, offset As Integer
  4.  
  5.         offset = lastCnt - 2
  6.  
  7.        e.Graphics.DrawCurve(PenRed, trigP, 1, drawSegments, 0)
  8.  
  9.         MyBase.OnPaint(e)
  10.     End Sub
  11.  
Apr 5 '10 #1
4 4729
qfchen
91
Hi need help on this. the waveform is updated dot by dot, the previous dots will be draw again when new dot moves in. that cause the whole panel screen blinking whenever update happen. any way to avoid re-draw previous dots again in new update?
Apr 6 '10 #2
CroCrew
564 Expert 512MB
Hello qfchen,

Can you post all your code so that I/we can simulate what you’re trying to do? Then maybe we can come up with an answer for you.

CroCrew~
Apr 6 '10 #3
qfchen
91
Hi CroCrew
I have a database, which capture real signals from a device, my application, every one second, read the signal from the database, then display as waveform on a panel screen, what I pass to the paint() is point array "Dim trigP(2000) As PointF", each time only the last point is new point, but have to redraw all the point in the Array.to show the waveform, Any way to display only one point without touching the previous points? below is the code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2.         Dim cnt, CntLast, svCurrent, x, y As Integer
  3.         Dim t1 As DateTime = Now
  4.         Dim t2 As DateTime = Now
  5.         Dim ft1, ft2, timeStamp, tStamp As Double
  6.         Dim strSvCurrent As String
  7.         Dim during As New TimeSpan(0, 2, 30)
  8.  
  9.         Timer1.Enabled = False
  10.  
  11.         t1 -= during
  12.         t2 += during
  13.         ft1 = t1.ToOADate()
  14.         ft2 = t2.ToOADate()
  15.  
  16.         cnt = EM_AWARE_20kVTableAdapter.FillByDT(DataSet_ESD.EM_AWARE_20kV, ft1, ft2)
  17.         If cnt <> 0 Then
  18.             tStamp = DataSet_ESD.EM_AWARE_20kV.Rows(0).Item(3).ToString
  19.             strSvCurrent = DataSet_ESD.EM_AWARE_20kV.Rows(0).Item(10).ToString
  20.  
  21.             svCurrent = Round((Convert.ToInt16(strSvCurrent) / 20) + TrigBoxMidPoint / 2)
  22.             If firstRun = True Then
  23.                 firstRun = False
  24.                 timeStamp = tStamp
  25.  
  26.                 x = Round(lastCnt * trigIntervel)
  27.                 y = Panel1.Height - svCurrent
  28.                 xData(lastCnt) = x
  29.                 yData(lastCnt) = y
  30.                 trigP(lastCnt) = New Point(x, y)
  31.                 lastCnt += 1
  32.             ElseIf lastCnt * trigIntervel <= Panel1.Width - 1 Then
  33.                timeStamp = tStamp
  34.                 x = Round(lastCnt * trigIntervel)
  35.                 y = Panel1.Height - svCurrent
  36.                 xData(lastCnt) = x
  37.                 yData(lastCnt) = y
  38.                 trigP(lastCnt) = New Point(x, y)
  39.                 lastCnt += 1
  40.                 If lastCnt > 3 Then
  41.                     drawSegments = lastCnt - 2
  42.                     Panel1.Refresh()
  43.                 End If
  44.              Else
  45.                 timeStamp = tStamp
  46.                 For Counter = 1 To lastCnt - 1
  47.                     yData(Counter - 1) = yData(Counter)
  48.                     trigP(Counter - 1) = New Point(xData(Counter), yData(Counter))
  49.                     Next
  50.                 x = Round(lastCnt * trigIntervel)
  51.                 y = Panel1.Height - svCurrent
  52.                 xData(lastCnt - 1) = x
  53.                 yData(lastCnt - 1) = y
  54.                 trigP(lastCnt - 1) = New Point(x, y)
  55.                 drawSegments = lastCnt - 2
  56.                 Panel1.Refresh()
  57.                 End If
  58.         End If
  59.  
  60.         Timer1.Enabled = True
  61.     End Sub
  62.  
Apr 6 '10 #4
qfchen
91
any idea how to resolve the blinking issue when draw waveform in paint event?
Apr 8 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John | last post by:
I'm trying to use the DrawText() method to draw some very long string text on the Panel with AutoScroll enabled. However, for some unknown reasons, I could not trigger the ScrollBar to show up. ...
1
by: Bad_Kid | last post by:
(c++) I have to present a wave which is stored in a file (int numbers, I know sample's freq) on some kind of graph. I've never been using drawing in c++. Any suggestions, the easiest way to do...
2
by: intrepid_dw | last post by:
All I am writing a C# WinForms application which is giving me some problems. The application consists of a form containing an empty Tab control to which TabPages are added dynamically (at...
11
by: dongarbage | last post by:
Hi there, I'm very much a C# novice. How do you do freehand drawing on a panel with a mouse in c#? Thanks, Don
0
by: vijaykumarairbee | last post by:
hi, i have panel control with network images pan,routers etc. when i scroll my panel control the images refresh rate is very slow.it means while i scroll the panel images go inside the panel...
0
by: Soren | last post by:
Hi, I'm trying to create a small GUI program where I can do plots using Matplotlib. I've been trying to borrow code from the examples at the matplotlib website, but I can't get it to work. I...
4
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've windows form, in this form i've a panel. I want to draw lines inside the panel using the panel coordinates( meaing that the left upper corner of the panel is 0,0), how can i do it? ...
3
by: Brandon Arnold | last post by:
I have a panel that contains a label and a picturebox. When clicked, I want to draw a rectangle over everything. I can draw the rect and set the color, no big deal. The problem is because I have to...
3
by: alanteo | last post by:
I am developing an application using Visual C++ express edition. The application requires the drawing of a panel of specific size and resolution. I would like to ask if there is any way for me to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.