📄 straightline.vb
字号:
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms.Design
Imports System.Drawing
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing.Drawing2D
Namespace Microsoft.Samples
''' <summary>
''' Summary description for StraightLine.
''' </summary>
Public Class StraightLine
Inherits LineBase
Private m_lineType As StraightLineTypes
Public Sub New()
MyBase.New()
m_lineType = StraightLineTypes.Horizontal
End Sub
<Category("Line Properties"), DefaultValue(GetType(StraightLineTypes), "StraightLineTypes.Horizontal")> _
Public Property LineType() As StraightLineTypes
Get
Return m_lineType
End Get
Set
m_lineType = value
Invalidate()
End Set
End Property
Protected Overloads Overrides Sub LineBase_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
pen = New Pen(ForeColor, Thickness)
If AntiAlias Then
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
End If
Select Case m_lineType
Case StraightLineTypes.Horizontal
DrawCenteredHorizontalLine(e.Graphics)
Exit Select
Case StraightLineTypes.Vertical
DrawCenteredVerticalLine(e.Graphics)
Exit Select
Case StraightLineTypes.DiagonalAscending
DrawCenteredDiagonalAscendingLine(e.Graphics)
Exit Select
Case StraightLineTypes.DiagonalDescending
DrawCenteredDiagonalDescendingLine(e.Graphics)
Exit Select
Case Else
Exit Select
End Select
End Sub
Private Sub DrawCenteredHorizontalLine(ByVal g As Graphics)
g.DrawLine(pen, 0, CInt(Height / 2), Width, CInt(Height / 2))
End Sub
Private Sub DrawCenteredVerticalLine(ByVal g As Graphics)
g.DrawLine(pen, CInt(Width / 2), 0, CInt(Width / 2), Height)
End Sub
Private Sub DrawCenteredDiagonalAscendingLine(ByVal g As Graphics)
g.DrawLine(pen, 0, Height, Width, 0)
End Sub
Private Sub DrawCenteredDiagonalDescendingLine(ByVal g As Graphics)
g.DrawLine(pen, 0, 0, Width, Height)
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -