当前位置:网站首页>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
边栏推荐
- 【虚拟化生态平台】树莓派安装虚拟化平台操作流程
- VBA输出日志到工作簿demo
- Summary of several defragmentation schemes for MySQL (to solve the problem of not releasing space after deleting a large amount of data)
- 生命不息,刷题不止,简单题学习知识点
- IDEA configure method annotation automatic parameters
- Read through the interface to call the artifact RestTemplate
- 7 days to learn Go, Go structure + Go range to learn
- 矩形脉冲波形的占空比及脉冲和瞬态特征的测量
- Use jOOQ to write vendor-agnostic SQL with JPA's native query or @Formula.
- apisix-Getting Started
猜你喜欢
《MySQL高级篇》四、索引的存储结构
使用内存映射加快PyTorch数据集的读取
拥抱趋势!阿里这套微服务开源框架权威手册,实战到底层细致清晰
瑞吉外卖项目:新增菜品与菜品分页查询
分布式事务——分布式事务简介、分布式事务框架 Seata(AT模式、Tcc模式、Tcc Vs AT)、分布式事务—MQ
面试、工作中常用sql大全(建议收藏备用)
Different lower_case_table_names settings for server ('1') and data dictionary ('0') solution
Cloudera Manager —— 端到端的企业数据中心管理工具
deeplab实现自己遥感地质分割数据集
一、excel转pdf格式jacob.jar
随机推荐
SQLServer2019 installation (Windows)
Android studio connects to MySQL and completes simple login and registration functions
才22岁!这位'00后'博士拟任职985高校!
LeetCode - 025. 链表中的两数相加
Distributed Transactions - Introduction to Distributed Transactions, Distributed Transaction Framework Seata (AT Mode, Tcc Mode, Tcc Vs AT), Distributed Transactions - MQ
「R」使用ggpolar绘制生存关联网络图
结构化查询语言SQL-关系数据库标准语言
Docker installs canal and mysql for simple testing and achieves cache consistency between redis and mysql
deeplab implements its own remote sensing geological segmentation dataset
Usage of JOIN in MySQL
分布式事务Seata详细使用教程
Many mock tools, this time I chose the right one
基于Multisim的函数信号发生器–方波、三角波、正弦波[通俗易懂]
Unix知识:shell详细解读
分布式id解决方案
线程池 ThreadPoolExecutor 详解
PyQt5快速开发与实战 9.5 PyQtGraph在PyQt中的应用 && 9.6 Plotly在PyQt中的应用
St. Regis Takeaway Project: File Upload and Download
面试、工作中常用sql大全(建议收藏备用)
在 Excel 里使用 ODBC 读取 SAP BTP 平台上 CDS view 的数据