VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "VisRectangle"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa VisRectangle
Dim x As Integer, y As Integer, w As Integer, h As Integer
Private rect As Rectangle
Private selected As Boolean
'-----
Public Sub init(xp As Integer, yp As Integer)
  x = xp                          'Przechowaj współrzędne
  y = yp
  w = 40                          'Domyślne wymiary
  h = 30
  saveAsRect
End Sub
'-----
'Metody właściwości używane dla przechowania i odtworzenia stanu
Friend Property Get rects() As Rectangle
  Set rects = rect
End Property
'-----
Friend Property Set rects(rc As Rectangle)
  x = rc.x
  y = rc.y
  w = rc.w
  h = rc.h
  saveAsRect
End Property
'-----
Public Sub setSelected(b As Boolean)
  selected = b
End Sub
'-----
'Przechowaj wartości w instancji klasy Rectangle
Private Sub saveAsRect()
  Set rect = New Rectangle
  rect.init x, y, w, h
End Sub
'-----
'Rysuje prostokąt i ochwyty
Public Sub draw(Pic As PictureBox)
  'Rysuj prostokąt
  Pic.Line (x, y)-(x + w, y + h), , B
  If selected Then   'Rysuj uchwyty
    Pic.Line (x + w / 2, y - 2)- _
              (x + w / 2 + 4, y + 2), , BF
    Pic.Line (x - 2, y + h / 2)- _
              (x + 2, y + h / 2 + 4), , BF
    Pic.Line (x + (w / 2), y + h - 2)- _
              (x + (w / 2) + 4, y + h + 2), , BF
    Pic.Line (x + (w - 2), y + (h / 2))- _
              (x + (w + 2), y + (h / 2) + 4), , BF
  End If
End Sub
'-----
Public Function contains(xp As Integer, yp As Integer) As Boolean
  contains = rect.contains(xp, yp)
End Function
'-----
Public Sub move(xpt As Integer, ypt As Integer)
  x = xpt
  y = ypt
  saveAsRect
End Sub
