- Код: Выделить всё
Public Class TargetManager
Private Columns() As Integer
Private ColumnIndex As Integer = -1
Public Sub AddColumn(ByVal ColumnSize As Integer)
Dim sz As Integer
If Columns Is Nothing Then
sz = 1
Else
sz = Columns.Length + 1
End If
Array.Resize(Columns, sz)
Columns(sz - 1) = ColumnSize
End Sub
Public Sub DeleteColumn(ByVal Index As Integer)
If Columns.Length = 1 And Index = 0 Then
Columns = Nothing
Else
Array.Copy(Columns, Index + 1, Columns, Index, Columns.Length - Index - 1)
Array.Resize(Columns, Columns.Length - 1)
End If
End Sub
Private Sub TargetManager_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim x As Integer
Dim s As Integer
If Columns IsNot Nothing Then
s = 0
For x = 0 To Columns.Length - 1
s = s + Columns(x)
e.Graphics.DrawLine(Pens.Black, s, 0, s, Me.Height)
Next x
End If
End Sub
Private Sub TargetManager_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Dim i As Integer
Dim s As Integer
If ColumnIndex = -1 Then
Me.Cursor = Cursors.Arrow
If Columns IsNot Nothing Then
s = 0
For i = 0 To Columns.Length - 1
s = s + Columns(i)
If e.X > s - 2 And e.X < s + 2 Then
Me.Cursor = Cursors.SizeWE
End If
Next i
End If
Else
s = 0
For i = 0 To ColumnIndex - 1
s = s + Columns(i)
Next
Columns(ColumnIndex) = e.X - s
Me.Refresh()
End If
End Sub
Private Sub TargetManager_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Dim i As Integer
Dim s As Integer
If Columns IsNot Nothing Then
s = 0
For i = 0 To Columns.Length - 1
s = s + Columns(i)
If e.X > s - 2 And e.X < s + 2 Then
ColumnIndex = i
End If
Next i
End If
End Sub
Private Sub TargetManager_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
ColumnIndex = -1
End Sub
End Class
Как сделать что-бы граффика компанента не мелькала?