Hello,
I have problem with ploting the wave shape in picturebox. It plot wave like it looks and that part is ok, but the main problem is that when is ploted wave, routine delete grid and markers which are made before :( . So how to force routine to keep markers and grid intact ?
Here is code, just make picturebox1 (size 315:102) and put timer1 in (100ms interval).
PublicClass Form1' Size of picturebox1 is 315;102 !!!!!!!!!!!!!!PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Randomize() m_OldValue = 0 Dim bm AsNew Bitmap(PictureBox1.Width, PictureBox1.Height)Dim gr As Graphics = Graphics.FromImage(bm) gr.DrawLine(Pens.Black, 0, 101, PictureBox1.Width, 101) gr.DrawLine(Pens.Black, 0, PictureBox1.Height, 0, 0) For j AsInteger = 0 To 300 Step 10 gr.DrawLine(Pens.Black, j, PictureBox1.Height, j, 98)Next jFor j AsInteger = 0 To 300 Step 20 gr.DrawLine(Pens.Black, j, PictureBox1.Height, j, 95)Next jFor i AsInteger = 10 To 80 Step 10 gr.DrawLine(Pens.Black, 0, i, 4, i)Next iFor i AsInteger = 20 To 80 Step 20 gr.DrawLine(Pens.Black, 0, i, 7, i)Next iFor j AsInteger = 20 To 300 Step 20 gr.DrawLine(Pens.Cyan, j, 94, j, 0)Next jFor i AsInteger = 20 To 80 Step 20 gr.DrawLine(Pens.Cyan, 4, i, PictureBox1.Width, i)Next i PictureBox1.Image = bm EndSubPrivateConst m_Dx AsSingle = 3Private m_OldValue AsSinglePrivateFunction NewValue() AsSingleDim new_value AsSingle new_value = m_OldValue + Rnd() * 8 - 4 If new_value > 99 Then new_value = 99If new_value < 1 Then new_value = 1 NewValue = new_valueEndFunctionPrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.TickDim bm AsNew Bitmap(picturebox1.Width, picturebox1.Height)Dim gr As Graphics = Graphics.FromImage(bm) gr.DrawImage(picturebox1.Image, +m_Dx, 0) gr.DrawLine(Pens.Black, 0, 101, PictureBox1.Width, 101) 'plot horizontal black line gr.DrawLine(Pens.Black, 0, PictureBox1.Height, 0, 0) 'plot vertical line but wrong !!! gr.ScaleTransform(1, -101 / picturebox1.Height) gr.TranslateTransform(0, -101) For i AsInteger = 20 To 80 Step 20 gr.DrawLine(Pens.Cyan, 0, i, PictureBox1.Width - m_Dx, i)Next iDim new_value AsInteger = NewValue() gr.DrawLine(Pens.Red, 0 + 1 + m_Dx, m_OldValue, 0 + 1, new_value) m_OldValue = new_value picturebox1.Image = bm EndSub
Thanks in advance,