当前位置:网站首页>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
边栏推荐
- 拥抱趋势!阿里这套微服务开源框架权威手册,实战到底层细致清晰
- lotus-local-net 2k v1.17.0-rc4
- "JUC Concurrent Programming - Advanced" 06 - Immutability of Shared Models (Design of Immutable Classes | Use of Immutable Classes | Flyweight Pattern)
- 学习爬虫之Scrapy框架学习(1)---Scrapy框架初学习及豆瓣top250电影信息获取的实战!
- Distributed id solution
- Mysql环境变量的配置(详细图解)
- Different lower_case_table_names settings for server (‘1‘) and data dictionary (‘0‘) 解决方案
- How MySQL's allowMultiQueries flag relates to JDBC and jOOQ
- MySQL limit paging query and performance issues
- Use ODBC in Excel to read data from CDS view on SAP BTP platform
猜你喜欢
随机推荐
AWS亚马逊云账号注册,免费申请12个月亚马逊云服务器详细教程
2022/7/30
deeplab implements its own remote sensing geological segmentation dataset
CWE4.8 -- 2022年危害最大的25种软件安全问题
Cloudera Manager —— 端到端的企业数据中心管理工具
「MySQL」- 基础增删改查
Redis - Basics
SQL - Left join, Right join, Inner join
[Go Affair] See through Go's collections and slices at a glance
台达PLC出现通信错误或通信超时或下载时提示机种不符的解决办法总结
R 语言data.frame 中的另一行中减去一行
Data Persistence Technology - MP
第十二章 使用中的 OpenAPI 属性
SAP Commerce Cloud Product Review 的添加逻辑
Implement the popup component
3D激光SLAM:LeGO-LOAM论文解读---点云分割部分
If the value of the enum map does not exist, deserialization is not performed
In PLC communication error or timeout or download the prompt solution of the model
Docker安装canal、mysql进行简单测试与实现redis和mysql缓存一致性
How MySQL's allowMultiQueries flag relates to JDBC and jOOQ