home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Pins
- BorderStyle = 3 'Fixed Dialog
- Caption = "Pins sample"
- ClientHeight = 5430
- ClientLeft = 1245
- ClientTop = 1065
- ClientWidth = 7455
- Height = 6120
- Left = 1185
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 5430
- ScaleWidth = 7455
- ShowInTaskbar = 0 'False
- Top = 435
- Width = 7575
- Begin EasynetLib.Easynet Easynet1
- Height = 3525
- Left = 120
- TabIndex = 0
- Top = 1800
- Width = 5970
- _Version = 65537
- _ExtentX = 10530
- _ExtentY = 6218
- _StockProps = 101
- BorderStyle = 1
- xGrid = 5
- yGrid = 5
- Shape = 1
- FillColor = 65280
- DrawColor = 0
- ForeColor = 0
- DrawWidth = 1
- Oriented = -1 'True
- ReadOnly = 0 'False
- MultiSel = -1 'True
- ScrollBars = 3
- CanDrawNode = -1 'True
- CanDrawLink = -1 'True
- CanMoveNode = -1 'True
- CanSizeNode = -1 'True
- CanStretchLink = -1 'True
- CanMultiLink = -1 'True
- Transparent = 0 'False
- DrawStyle = 0
- Alignment = 7
- ShowGrid = 0 'False
- LinkHead = 0
- DoSelChange = -1 'True
- DoAddNode = -1 'True
- DoAddLink = -1 'True
- Hiding = 0 'False
- ImageFile = ""
- DisplayHandles = -1 'True
- Zoom = 100
- AutoSize = 0
- AutoScroll = -1 'True
- End
- Begin VB.CommandButton Command2
- Caption = "Unsleep"
- Height = 495
- Index = 1
- Left = 6360
- TabIndex = 4
- Top = 3000
- Width = 975
- End
- Begin VB.CommandButton Command2
- Caption = "Sleep"
- Height = 495
- Index = 0
- Left = 6360
- TabIndex = 3
- Top = 2400
- Width = 975
- End
- Begin VB.TextBox Text1
- Height = 1575
- Left = 120
- Locked = -1 'True
- MultiLine = -1 'True
- TabIndex = 2
- Text = "PINS.frx":0000
- Top = 120
- Width = 7215
- End
- Begin VB.CommandButton Command1
- Caption = "&Delete"
- Height = 495
- Left = 6360
- TabIndex = 1
- Top = 1800
- Width = 975
- End
- Begin VB.Menu FileMenu
- Caption = "&File"
- Begin VB.Menu ExitMenu
- Caption = "&Exit"
- End
- End
- Begin VB.Menu HelpMenu
- Caption = "&?"
- Begin VB.Menu AboutMenu
- Caption = "&About..."
- End
- End
- Attribute VB_Name = "Pins"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub AboutMenu_Click()
- Dim msg$
- msg = "EasyNet: sample that shows how to use Owner property" + Chr(13) + "Copyright
- 1994-1996 by Patrick Lassalle"
- MsgBox msg
- End Sub
- Private Sub Command1_Click()
- Dim j&, ownedCount&
- Dim ownedNode&(), org&, dst&, item&
- With Easynet1
- item = .item
- If item <> 0 Then
- ' If current item exists
- If .IsItemLink(item) Then
- ' If current item is a link, delete its origin and destination
- ' owned nodes.
- org = .GetLinkOrg(item)
- dst = .GetLinkDst(item)
- .DeleteItem item ' Delete current item
- .DeleteItem org
- .DeleteItem dst
- Else
- ' If current item is a node, delete all its owned nodes.
- ownedCount = .GetOwnedNodesCount(item) ' Count of owned nodes
- If ownedCount > 0 Then
- ReDim ownedNode(1 To ownedCount) ' Array of owned nodes
- .GetOwnedNodesArray item, ownedCount, ownedNode(1)
- For j = 1 To ownedCount
- .DeleteItem ownedNode(j) ' Delete each owned node
- Next j
- End If
- .DeleteItem item ' Delete current item
- End If
- End If
- End With
- End Sub
- Private Sub Command2_Click(Index As Integer)
- Dim ownedCount&, j&
- Dim item&, ownedNode&()
- Dim sleeping As Boolean
- With Easynet1
- ' Get current irem
- item = .item
- ' If current item exists and is a node...
- If item <> 0 And .IsItemLink(item) = False Then
- ownedCount = .GetOwnedNodesCount(item) ' Count of owned nodes
- If ownedCount > 0 Then
- ReDim ownedNode(1 To ownedCount) ' Array of owned nodes
- .GetOwnedNodesArray item, ownedCount, ownedNode(1)
-
- If Index = 0 Then
- sleeping = True
- Else
- sleeping = False
- End If
-
- ' Make each owned node sleeping
- For j = 1 To ownedCount
- .SetItemSleeping ownedNode(j), sleeping
- Next j
- End If
- End If
- End With
- End Sub
- Private Sub Easynet1_AddLink()
- Dim link&, nodedst&, nodeorg&, dst&, org&
- Dim Xorg&, Yorg&, Xdst&, Ydst&
- With Easynet1
- ' identifier of the link
- link = .item
- ' Get first and last point of the link
- Xorg = .GetLinkPointX(link, 0)
- Yorg = .GetLinkPointY(link, 0)
- Xdst = .GetLinkPointX(link, 1)
- Ydst = .GetLinkPointY(link, 1)
- ' Get origin and destination nodes of our just created link
- dst = .GetLinkDst(link)
- org = .GetLinkOrg(link)
- ' Create 2 little black nodes:
- ' - the first is owned by the origin node
- ' - the second is owned by the destination node
- nodeorg = .AddNodeItem()
- .SetNodeRect nodeorg, Xorg - 45, Yorg - 45, Xorg + 45, Yorg + 45
- .SetNodeOwner nodeorg, org
- .SetNodeFillColor nodeorg, RGB(0, 0, 0)
- nodedst = .AddNodeItem()
- .SetNodeRect nodedst, Xdst - 45, Ydst - 45, Xdst + 45, Ydst + 45
- .SetNodeOwner nodedst, dst
- .SetNodeFillColor nodedst, RGB(0, 0, 0)
- ' Now destroy the link ...
- .DeleteItem link
- ' ... and recreate a new one with the two little black nodes
- ' as origin and destination.
- ' Note: it is important to avoid sending a new AddLink event here.
- ' That is why DoAddLink property is made false.
- ' If you don't do that , you'll have a stack overflow.
- .DoAddLink = False
- link = .AddLinkItem(nodeorg, nodedst)
- .DoAddLink = True
- End With
- End Sub
- Private Sub ExitMenu_Click()
- End
- End Sub
-