知识大全 vb.net graphic 简单的画图程序

Posted 状态

篇首语:得意犹堪夸世俗,诏黄新湿字如鸦。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 vb.net graphic 简单的画图程序相关的知识,希望对你有一定的参考价值。

  [vb]

  Public Class Form

  Dim DrawState As Boolean

  Dim PreX As Single

  Dim PreY As Single

  Dim eP As New Pen(Color Black )          构造黑色画笔 并将它赋给对象变量eP

   Dim g As Graphics = Me CreateGraphics     在窗体上构造一块画布 并将它赋给对象变量g

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load

   将DrawState初始化为False 表示提笔

  DrawState = False

  End Sub

  Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseDown

   当鼠标左键被按下时 把DrawState设为True 表示落笔开始画线

  Dim g As Graphics = Me CreateGraphics

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = True     设置画图状态

  PreX = e X          PreX和PreY保存了线条的起点

  PreY = e Y

  End If

   当按住鼠标右键时 画一个直径为 的圆

  If e Button = Windows Forms MouseButtons Right Then

  g DrawEllipse(eP e X e Y )

  End If

  End Sub

  Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseMove

   当鼠标移动时 如果处于画线状态 则在(PreX PreY)与(X Y)之间画一条直线

  Dim g As Graphics = Me CreateGraphics

  If DrawState = True Then

  g DrawLine(eP PreX PreY e X e Y)

  PreX = e X

  PreY = e Y

  End If

  End Sub

  Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseUp

   当释放鼠标左键时 解除画线状态

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = False

  End If

  End Sub

  End Class

  Public Class Form

  Dim DrawState As Boolean

  Dim PreX As Single

  Dim PreY As Single

  Dim eP As New Pen(Color Black )          构造黑色画笔 并将它赋给对象变量eP

   Dim g As Graphics = Me CreateGraphics     在窗体上构造一块画布 并将它赋给对象变量g

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load

   将DrawState初始化为False 表示提笔

  DrawState = False

  End Sub

  Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseDown

   当鼠标左键被按下时 把DrawState设为True 表示落笔开始画线

  Dim g As Graphics = Me CreateGraphics

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = True     设置画图状态

  PreX = e X          PreX和PreY保存了线条的起点

  PreY = e Y

  End If

   当按住鼠标右键时 画一个直径为 的圆

  If e Button = Windows Forms MouseButtons Right Then

  g DrawEllipse(eP e X e Y )

  End If

  End Sub

  Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseMove

   当鼠标移动时 如果处于画线状态 则在(PreX PreY)与(X Y)之间画一条直线

  Dim g As Graphics = Me CreateGraphics

  If DrawState = True Then

  g DrawLine(eP PreX PreY e X e Y)

  PreX = e X

  PreY = e Y

  End If

  End Sub

  Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseUp

   当释放鼠标左键时 解除画线状态

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = False

  End If

  End Sub

  End Class

  改法

  [vb]

  Public Class Form

  Dim DrawState As Boolean

  Dim PreX As Single

  Dim PreY As Single

  Dim eP As New Pen(Color Black )          构造黑色画笔 并将它赋给对象变量eP

  Dim g As Graphics     在窗体上构造一块画布 并将它赋给对象变量g

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load

   将DrawState初始化为False 表示提笔

  DrawState = False

  End Sub

  Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseDown

   当鼠标左键被按下时 把DrawState设为True 表示落笔开始画线

   Dim g As Graphics = Me CreateGraphics

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = True     设置画图状态

  PreX = e X          PreX和PreY保存了线条的起点

  PreY = e Y

  End If

   当按住鼠标右键时 画一个直径为 的圆

  If e Button = Windows Forms MouseButtons Right Then

  g DrawEllipse(eP e X e Y )

  End If

  End Sub

  Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseMove

   当鼠标移动时 如果处于画线状态 则在(PreX PreY)与(X Y)之间画一条直线

   Dim g As Graphics = Me CreateGraphics

  If DrawState = True Then

  g DrawLine(eP PreX PreY e X e Y)

  PreX = e X

  PreY = e Y

  End If

  End Sub

  Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseUp

   当释放鼠标左键时 解除画线状态

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = False

  End If

  End Sub

  Private Sub Form _Resize(ByVal sender As Object ByVal e As System EventArgs) Handles Me Resize

  g = Me CreateGraphics

  End Sub

  End Class

  Public Class Form

  Dim DrawState As Boolean

  Dim PreX As Single

  Dim PreY As Single

  Dim eP As New Pen(Color Black )          构造黑色画笔 并将它赋给对象变量eP

  Dim g As Graphics     在窗体上构造一块画布 并将它赋给对象变量g

  Private Sub Form _Load(ByVal sender As System Object ByVal e As System EventArgs) Handles MyBase Load

   将DrawState初始化为False 表示提笔

  DrawState = False

  End Sub

  Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseDown

   当鼠标左键被按下时 把DrawState设为True 表示落笔开始画线

   Dim g As Graphics = Me CreateGraphics

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = True     设置画图状态

  PreX = e X          PreX和PreY保存了线条的起点

  PreY = e Y

  End If

   当按住鼠标右键时 画一个直径为 的圆

  If e Button = Windows Forms MouseButtons Right Then

  g DrawEllipse(eP e X e Y )

  End If

  End Sub

  Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseMove

   当鼠标移动时 如果处于画线状态 则在(PreX PreY)与(X Y)之间画一条直线

   Dim g As Graphics = Me CreateGraphics

  If DrawState = True Then

  g DrawLine(eP PreX PreY e X e Y)

  PreX = e X

  PreY = e Y

  End If

  End Sub

  Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles Me MouseUp

   当释放鼠标左键时 解除画线状态

  If e Button = Windows Forms MouseButtons Left Then

  DrawState = False

  End If

  End Sub

  Private Sub Form _Resize(ByVal sender As Object ByVal e As System EventArgs) Handles Me Resize

  g = Me CreateGraphics

  End Sub

cha138/Article/program/net/201311/13744

相关参考

知识大全 VB.NET 2005编写定时关机程序

VB.NET2005编写定时关机程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  最近在网上搜

知识大全 VB.NET编写测试硬盘速度的程序

VB.NET编写测试硬盘速度的程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  前日在用SiS

知识大全 完整的VB.NET的语法解析程序

完整的VB.NET的语法解析程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 比较长不过支持全部

知识大全 用VB.net2008编写屏幕抓捕程序

用VB.net2008编写屏幕抓捕程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!VisualS

知识大全 VB.net2008打造精美电子日历程序

VB.net2008打造精美电子日历程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  Visu

知识大全 用vb.net实现闹钟提醒程序

  一个提醒程序最典型的就是闹钟程序网上有不少个性化的提醒程序下载但是大部分都是以时间为主的闹钟提醒我们也可以用来打造一个适合自己的提醒程序比如监控一个某个应用程序的变化然后发出声音提醒自己等等  一

知识大全 用VB.NET 2005编写定时关机程序[3]

用VB.NET2005编写定时关机程序[3]  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  双击

知识大全 用VB.NET 2005编写定时关机程序[2]

用VB.NET2005编写定时关机程序[2]  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  双击

知识大全 用VB.NET 2005编写定时关机程序[1]

用VB.NET2005编写定时关机程序[1]  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!&nbs

知识大全 用VB.NET 2005编写定时关机程序[4]

用VB.NET2005编写定时关机程序[4]  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!&nbs