当前位置:网站首页>vb.net 画曲线
vb.net 画曲线
2022-07-31 11:38:00 【laocooon】
Public Class Form1
Public Enum Type
None = 0
Line = 1
Cirle = 2
PolyLine = 3
Curve = 4
End Enum
Dim m_Type As Type = Type.None
Dim First As Point
Dim Last As Point
Dim g As Graphics
Dim listPoint As New List(Of Point)
Private Sub Initial(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, MyBase.Load
m_Type = Type.None
First = Point.Empty
Last = Point.Empty
Dim c As Control = TryCast(sender, Control)
If IsNothing(c) Then Exit Sub
Select Case c.Name
Case "Button1"
m_Type = Type.Line
Case "Button2"
m_Type = Type.Cirle
Case "Button3"
m_Type = Type.PolyLine
Case "Button4"
m_Type = Type.Curve
End Select
End Sub
Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles MyBase.MouseClick
Dim pen As Pen = New Pen(Color.Red)
g = Me.CreateGraphics()
If e.Button = MouseButtons.Left Then
'分情况
Select Case m_Type
Case Type.None
Return
Case Type.Line
If First = Point.Empty Then
First = New Point(e.X, e.Y)
Else
Last = New Point(e.X, e.Y)
g.DrawLine(pen, First, Last)
Me.Initial(Nothing, e) '取消
End If
Case Type.Cirle
If First = Point.Empty Then
First = New Point(e.X, e.Y)
Else
Dim R As Integer = Math.Sqrt((First.X - e.X) * (First.X - e.X) + (First.Y - e.Y) * (First.Y - e.Y))
Dim left As New Point(First.X - R, First.Y - R)
g.DrawEllipse(pen, left.X, left.Y, 2 * R, 2 * R)
Me.Initial(Nothing, e) '取消
End If
Case Type.PolyLine
If First = Point.Empty Then
First = New Point(e.X, e.Y)
Else
Last = New Point(e.X, e.Y)
g.DrawLine(pen, First, Last)
First = Last
End If
Case Type.Curve
If First = Point.Empty Then
First = New Point(e.X, e.Y)
listPoint.Add(First)
Else
Last = New Point(e.X, e.Y)
listPoint.Add(Last)
If Type.Curve = m_Type Then
If listPoint.Count = 3 Then
g.DrawCurve(pen, listPoint.ToArray(), 0.5)
End If
End If
End If
End Select
ElseIf e.Button = MouseButtons.Right Then
Me.Initial(Nothing, e) '取消
End If
End Sub
End Class
边栏推荐
猜你喜欢
Cloudera Manager —— 端到端的企业数据中心管理工具
SQL - Left join, Right join, Inner join
Redis - Basics
Redis学习笔记-3.慢查询和其他高级数据结构
Initial JDBC programming
MySql模糊查询大全
deeplab实现自己遥感地质分割数据集
unity computeshader的可读写buffer
After class, watching the documentation and walking back to the lab, I picked up the forgotten SQL operators again
mysql根据多字段分组——group by带两个或多个参数
随机推荐
多线程学习笔记-2.final关键字和不变性
"JUC Concurrent Programming - Advanced" 06 - Immutability of Shared Models (Design of Immutable Classes | Use of Immutable Classes | Flyweight Pattern)
音视频基础
便利贴--46{基于移动端长页中分页加载逻辑封装}
The principle of v-model
oracle优化:instr做join条件很慢「建议收藏」
基于C51实现按键控制
Can I find a Go job in 7 days?Learn Go with arrays and pointers
B/S架构模式的一个整体执行流程
结构化查询语言SQL-关系数据库标准语言
Docker build Mysql master-slave replication
3D激光SLAM:LeGO-LOAM论文解读---点云分割部分
The latest MySql installation teaching, very detailed
Initial JDBC programming
三层架构service、dao、controller层
MySQL 的 limit 分页查询及性能问题
Mysql环境变量的配置(详细图解)
St. Regis Takeaway Project: New dishes and dishes paged query
2022/7/30
使用内存映射加快PyTorch数据集的读取