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轴计数 循环部分怎么修改?
拜谢!
...全文
446 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
内容概要:本文系统研究了直流微网中直流母线电压恢复的二次控制策略,重点提出并实现了基于虚拟压降补偿的方法在并联双向Buck-boost变换器中的应用。通过Simulink搭建详细的仿真模型,深入分析了虚拟压降原理及其在多变换器并联系统中的协调控制机制,有效解决了因线路阻抗差异导致的电压偏差与电流分配不均问题,实现了母线电压的精确调节与快速恢复,显著提升了系统的稳定性、均流性能与电能质量。研究涵盖了控制策略设计、关键参数整定及动态响应特性验证,提供了完整的仿真流程与结果分析。; 适合人群:具备电力电子、自动控制及微电网相关专业知识背景,熟悉Simulink仿真环境,从事新能源发电、直流配电系统、分布式能源控制等领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①深入理解直流微网中母线电压稳定与均流控制的关键技术;②掌握虚拟压降补偿在二次控制中的理论基础与实现方法;③构建并调试并联Buck-boost变换器的协同控制系统仿真模型,服务于学术研究、课程设计或实际工程项目开发; 阅读建议:学习过程中应结合Simulink模型细致剖析控制回路结构,重点关注虚拟阻抗参数对系统动态性能与鲁棒性的影响,建议通过改变负载工况、线路参数或增加变换器数量等方式进行对比仿真,以全面评估控制策略的有效性与适应性。

16,718

社区成员

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

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