当前位置:网站首页>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
边栏推荐
- Obsidian设置图床
- 使用 Excel 读取 SAP ABAP CDS View 通过 ODBC 暴露出来的数据
- LeetCode - 025. 链表中的两数相加
- 7 days to learn Go, Go structure + Go range to learn
- 【虚拟化生态平台】平台架构图&思路和实现细节
- Read through the interface to call the artifact RestTemplate
- DCM 中间件家族迎来新成员
- AWS Amazon cloud account registration, free application for 12 months Amazon cloud server detailed tutorial
- 最全phpmyadmin漏洞汇总
- Different lower_case_table_names settings for server (‘1‘) and data dictionary (‘0‘) 解决方案
猜你喜欢

下课看着文档走回实验室,我重新拾起了遗忘的SQL运算符

LeetCode - 025. 链表中的两数相加

5 open source Rust web development frameworks, which one do you choose?

AWS亚马逊云账号注册,免费申请12个月亚马逊云服务器详细教程

“带薪划水”偷刷阿里老哥的面经宝典,三次挑战字节,终成正果

拥抱趋势!阿里这套微服务开源框架权威手册,实战到底层细致清晰

Redis学习笔记-3.慢查询和其他高级数据结构

Data Persistence Technology - MP

MySQL 的几种碎片整理方案总结(解决delete大量数据后空间不释放的问题)

The item 'node.exe' was not recognized as the name of a cmdlet, function, script file, or runnable program.
随机推荐
5 个开源的 Rust Web 开发框架,你选择哪个?
学习笔记 Golang 写入文件(io.WriteString、ioutil.WriteFile、file.Write、write.WriteString)
Summary of several defragmentation schemes for MySQL (to solve the problem of not releasing space after deleting a large amount of data)
Experience innovation and iteration through the development of lucky draw mini-programs
ApiPost is really fragrant and powerful, it's time to throw away Postman and Swagger
分布式事务——分布式事务简介、分布式事务框架 Seata(AT模式、Tcc模式、Tcc Vs AT)、分布式事务—MQ
St. Regis Takeaway Project: New dishes and dishes paged query
mpu9150(driverack pa简明教程)
最全phpmyadmin漏洞汇总
502 bad gateway causes and solutions
《MySQL高级篇》五、InnoDB数据存储结构
musl Reference Manual
基于Multisim的函数信号发生器–方波、三角波、正弦波[通俗易懂]
Service discovery of kubernetes
unity computeshader的可读写buffer
Redis - Basics
Use ODBC in Excel to read data from CDS view on SAP BTP platform
mysql根据多字段分组——group by带两个或多个参数
Docker实践经验:Docker 上部署 mysql8 主从复制
Distributed Transactions - Introduction to Distributed Transactions, Distributed Transaction Framework Seata (AT Mode, Tcc Mode, Tcc Vs AT), Distributed Transactions - MQ