PictureBox 画坐标系 X轴为时间 可移动 有代码

little_potato 2010-04-13 01:42:54
一个Form 一个PictureBox 一个按钮 一个timer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
j += 1
PictureBox1.Image = x_y(PictureBox1)
End Sub

Private Function x_y(ByVal pic As PictureBox) As Bitmap
Dim b As New Bitmap(pic.Width, pic.Height)
Dim g As Graphics = Graphics.FromImage(b)
'背景色
'g.Clear(Color.White)
'線色
Dim p As New Pen(Color.White)
'線様式
p.EndCap = Drawing2D.LineCap.ArrowAnchor
'X
g.DrawLine(p, 20, pic.Height - 20, 20, 10)
'Y
g.DrawLine(p, 20, pic.Height - 20, pic.Width - 20, pic.Height - 20)
'--------------------------------------------------
Dim i As Double
Dim bs As New SolidBrush(Color.Yellow)
Dim po As New Point
'0点
g.DrawString(0, Me.Font, bs, 12, pic.Height - 18)
'開始X位置
po.X = 0
'開始Y位置
po.Y = pic.Height - 40
For i = 0.5 To 5 Step 0.5
'数字
g.DrawString(i, Me.Font, bs, po.X, po.Y)
'点
g.DrawLine(p, po.X + 28, po.Y + 5, po.X + 30, po.Y + 5)
'線
Dim p1 As New Pen(Color.White)
p1.DashStyle = Drawing2D.DashStyle.Dash
g.DrawLine(p1, po.X + 28, po.Y + 5, pic.Width - 20, po.Y + 5)
'間隔
po.Y -= (pic.Height - 50) / 9
Next
'開始X位置
po.X = 55
'開始Y位置
po.Y = pic.Height - 20
For c = 0 To 14400 Step 1200
'数字位置
g.DrawString(c / 1200, Me.Font, bs, po.X - j, po.Y + 5)
g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)
po.X += (pic.Width - 50) / 12
Next
Return b
End Function
请教各位前辈:
想一直让x轴计数 循环部分怎么修改?
拜谢!
...全文
459 2 打赏 收藏 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
plm310 2010-09-02
  • 打赏
  • 举报
回复
运行不出来!
SYSSZ 2010-04-13
  • 打赏
  • 举报
回复
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static j As Long
j += 1
PictureBox1.Image = x_y(PictureBox1, j)
End Sub

Private Function x_y(ByVal pic As PictureBox, ByVal x As Long) As Bitmap
Dim b As New Bitmap(pic.Width, pic.Height)
Dim g As Graphics = Graphics.FromImage(b)
Dim c
Dim j
g.Clear(Color.White)
Dim p As New Pen(Color.Red)
p.EndCap = Drawing2D.LineCap.ArrowAnchor '指定可用线帽样式,Pen 对象以该线帽结束一段直线
g.DrawLine(p, 20, pic.Height - 20, 20, 10) '画Y轴
g.DrawLine(p, 20, pic.Height - 20, pic.Width - 20, pic.Height - 20) '画经X轴
'--------------------------------------------------
Dim i As Double
Dim bs As New SolidBrush(Color.Green)
Dim po As New Point
g.DrawString(0, Me.Font, bs, 12, pic.Height - 18) '0点
po.X = 0 '開始X位置
po.Y = pic.Height - 40 '開始Y位置
For i = 0.5 To 5 Step 0.5
g.DrawString(i, Me.Font, bs, po.X, po.Y) '数字
g.DrawLine(p, po.X + 18, po.Y + 5, po.X + 20, po.Y + 5) '点
Dim p1 As New Pen(Color.Blue) '線
p1.DashStyle = Drawing2D.DashStyle.Dash
g.DrawLine(p1, po.X + 28, po.Y + 5, pic.Width - 20, po.Y + 5)
'間隔
po.Y -= (pic.Height - 50) / 9
Next
'開始X位置
po.X = 20
'開始Y位置
po.Y = pic.Height - 20
For c = 0 To 14400 Step 1200
'数字位置
If (c / 1200) > 0 Then
g.DrawString((c / 1200) + x, Me.Font, bs, po.X - j, po.Y + 5)
end if
g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)
po.X += (pic.Width - 50) / 12
Next
Return b
End Function

End Class
代码下载链接: https://pan.quark.cn/s/a4b39357ea24 用户账户控制(UAC)白名单的配置 Windows7环境中 UAC(User Account Control,用户帐户控制)是由微软在Windows Vista版本中推出的一项旨在增强系统安全性的创新技术,该技术强制要求用户在执行可能干扰计算机正常运作的操作或进行更改会波及其他用户设置的变动前,必须提供相应的权限或管理员密码进行验证。通过对这些操作启动前进行授权确认,UAC能够有效阻止恶意软件及间谍软件在未获授权的状态下于计算机内进行安装或实施修改。 自从Vista版本问世以来,微软便开始推行这一全新的安全机制,可视为对系统安全防护的显著提升。尽管UAC确实能够在一定程度上对某些非法程序起到防御作用,但与此同时,这一功能也给众多用户带来了诸多不便。 因此,许多用户开始探寻是否存在类似于白名单的功能,以便将那些值得信赖的程序直接赋予运行权限。事实上,这类功能确实存在,不过微软并未将其作为标准配置提供。 网络上关于此问题的绝大多数建议都是建议禁用UAC,这种说法显然缺乏针对性,因为若用户希望禁用此功能,本就不会提出相关疑问。 通过运用微软官方发布的Microsoft Application Compatibility Toolkit 5.6版本,可以将信任的程序纳入系统白名单范畴。 获取Application Compatibility Toolkit 安装程序成功后会出现三个可执行文件 以管理员身份启动Compatibility Administrator 在Custom DataBases部分创建新的数据库,并添加一个Application Fix(在下方空白处点击右键,选择...

16,718

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧