home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / WINDOWS / EZNET.ZIP / PINS.ZIP / PINS.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-07-22  |  6.9 KB  |  218 lines

  1. VERSION 4.00
  2. Begin VB.Form Pins 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Pins sample"
  5.    ClientHeight    =   5430
  6.    ClientLeft      =   1245
  7.    ClientTop       =   1065
  8.    ClientWidth     =   7455
  9.    Height          =   6120
  10.    Left            =   1185
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   5430
  15.    ScaleWidth      =   7455
  16.    ShowInTaskbar   =   0   'False
  17.    Top             =   435
  18.    Width           =   7575
  19.    Begin EasynetLib.Easynet Easynet1 
  20.       Height          =   3525
  21.       Left            =   120
  22.       TabIndex        =   0
  23.       Top             =   1800
  24.       Width           =   5970
  25.       _Version        =   65537
  26.       _ExtentX        =   10530
  27.       _ExtentY        =   6218
  28.       _StockProps     =   101
  29.       BorderStyle     =   1
  30.       xGrid           =   5
  31.       yGrid           =   5
  32.       Shape           =   1
  33.       FillColor       =   65280
  34.       DrawColor       =   0
  35.       ForeColor       =   0
  36.       DrawWidth       =   1
  37.       Oriented        =   -1  'True
  38.       ReadOnly        =   0   'False
  39.       MultiSel        =   -1  'True
  40.       ScrollBars      =   3
  41.       CanDrawNode     =   -1  'True
  42.       CanDrawLink     =   -1  'True
  43.       CanMoveNode     =   -1  'True
  44.       CanSizeNode     =   -1  'True
  45.       CanStretchLink  =   -1  'True
  46.       CanMultiLink    =   -1  'True
  47.       Transparent     =   0   'False
  48.       DrawStyle       =   0
  49.       Alignment       =   7
  50.       ShowGrid        =   0   'False
  51.       LinkHead        =   0
  52.       DoSelChange     =   -1  'True
  53.       DoAddNode       =   -1  'True
  54.       DoAddLink       =   -1  'True
  55.       Hiding          =   0   'False
  56.       ImageFile       =   ""
  57.       DisplayHandles  =   -1  'True
  58.       Zoom            =   100
  59.       AutoSize        =   0
  60.       AutoScroll      =   -1  'True
  61.    End
  62.    Begin VB.CommandButton Command2 
  63.       Caption         =   "Unsleep"
  64.       Height          =   495
  65.       Index           =   1
  66.       Left            =   6360
  67.       TabIndex        =   4
  68.       Top             =   3000
  69.       Width           =   975
  70.    End
  71.    Begin VB.CommandButton Command2 
  72.       Caption         =   "Sleep"
  73.       Height          =   495
  74.       Index           =   0
  75.       Left            =   6360
  76.       TabIndex        =   3
  77.       Top             =   2400
  78.       Width           =   975
  79.    End
  80.    Begin VB.TextBox Text1 
  81.       Height          =   1575
  82.       Left            =   120
  83.       Locked          =   -1  'True
  84.       MultiLine       =   -1  'True
  85.       TabIndex        =   2
  86.       Text            =   "PINS.frx":0000
  87.       Top             =   120
  88.       Width           =   7215
  89.    End
  90.    Begin VB.CommandButton Command1 
  91.       Caption         =   "&Delete"
  92.       Height          =   495
  93.       Left            =   6360
  94.       TabIndex        =   1
  95.       Top             =   1800
  96.       Width           =   975
  97.    End
  98.    Begin VB.Menu FileMenu 
  99.       Caption         =   "&File"
  100.       Begin VB.Menu ExitMenu 
  101.          Caption         =   "&Exit"
  102.       End
  103.    End
  104.    Begin VB.Menu HelpMenu 
  105.       Caption         =   "&?"
  106.       Begin VB.Menu AboutMenu 
  107.          Caption         =   "&About..."
  108.       End
  109.    End
  110. Attribute VB_Name = "Pins"
  111. Attribute VB_Creatable = False
  112. Attribute VB_Exposed = False
  113. Option Explicit
  114. Private Sub AboutMenu_Click()
  115.   Dim msg$
  116.   msg = "EasyNet: sample that shows how to use Owner property" + Chr(13) + "Copyright 
  117.  1994-1996 by Patrick Lassalle"
  118.   MsgBox msg
  119. End Sub
  120. Private Sub Command1_Click()
  121.   Dim j&, ownedCount&
  122.   Dim ownedNode&(), org&, dst&, item&
  123.   With Easynet1
  124.     item = .item
  125.     If item <> 0 Then
  126.       ' If current item exists
  127.       If .IsItemLink(item) Then
  128.         ' If current item is a link, delete its origin and destination
  129.         ' owned nodes.
  130.         org = .GetLinkOrg(item)
  131.         dst = .GetLinkDst(item)
  132.         .DeleteItem item ' Delete current item
  133.         .DeleteItem org
  134.         .DeleteItem dst
  135.       Else
  136.         ' If current item is a node, delete all its owned nodes.
  137.         ownedCount = .GetOwnedNodesCount(item)  ' Count of owned nodes
  138.         If ownedCount > 0 Then
  139.           ReDim ownedNode(1 To ownedCount)      ' Array of owned nodes
  140.           .GetOwnedNodesArray item, ownedCount, ownedNode(1)
  141.           For j = 1 To ownedCount
  142.             .DeleteItem ownedNode(j)  ' Delete each owned node
  143.           Next j
  144.         End If
  145.         .DeleteItem item ' Delete current item
  146.       End If
  147.     End If
  148.   End With
  149. End Sub
  150. Private Sub Command2_Click(Index As Integer)
  151.   Dim ownedCount&, j&
  152.   Dim item&, ownedNode&()
  153.   Dim sleeping As Boolean
  154.   With Easynet1
  155.     ' Get current irem
  156.     item = .item
  157.     ' If current item exists and is a node...
  158.     If item <> 0 And .IsItemLink(item) = False Then
  159.       ownedCount = .GetOwnedNodesCount(item)  ' Count of owned nodes
  160.       If ownedCount > 0 Then
  161.         ReDim ownedNode(1 To ownedCount)      ' Array of owned nodes
  162.         .GetOwnedNodesArray item, ownedCount, ownedNode(1)
  163.         
  164.         If Index = 0 Then
  165.           sleeping = True
  166.         Else
  167.           sleeping = False
  168.         End If
  169.         
  170.         ' Make each owned node sleeping
  171.         For j = 1 To ownedCount
  172.           .SetItemSleeping ownedNode(j), sleeping
  173.         Next j
  174.       End If
  175.     End If
  176.   End With
  177. End Sub
  178. Private Sub Easynet1_AddLink()
  179.   Dim link&, nodedst&, nodeorg&, dst&, org&
  180.   Dim Xorg&, Yorg&, Xdst&, Ydst&
  181.   With Easynet1
  182.     ' identifier of the link
  183.     link = .item
  184.     ' Get first and last point of the link
  185.     Xorg = .GetLinkPointX(link, 0)
  186.     Yorg = .GetLinkPointY(link, 0)
  187.     Xdst = .GetLinkPointX(link, 1)
  188.     Ydst = .GetLinkPointY(link, 1)
  189.     ' Get origin and destination nodes of our just created link
  190.     dst = .GetLinkDst(link)
  191.     org = .GetLinkOrg(link)
  192.     ' Create 2 little black nodes:
  193.     ' - the first is owned by the origin node
  194.     ' - the second is owned by the destination node
  195.     nodeorg = .AddNodeItem()
  196.     .SetNodeRect nodeorg, Xorg - 45, Yorg - 45, Xorg + 45, Yorg + 45
  197.     .SetNodeOwner nodeorg, org
  198.     .SetNodeFillColor nodeorg, RGB(0, 0, 0)
  199.     nodedst = .AddNodeItem()
  200.     .SetNodeRect nodedst, Xdst - 45, Ydst - 45, Xdst + 45, Ydst + 45
  201.     .SetNodeOwner nodedst, dst
  202.     .SetNodeFillColor nodedst, RGB(0, 0, 0)
  203.     ' Now destroy the link ...
  204.     .DeleteItem link
  205.     ' ... and recreate a new one with the two little black nodes
  206.     ' as origin and destination.
  207.     ' Note: it is important to avoid sending a new AddLink event here.
  208.     ' That is why DoAddLink property is made false.
  209.     ' If you don't do that , you'll have a stack overflow.
  210.     .DoAddLink = False
  211.     link = .AddLinkItem(nodeorg, nodedst)
  212.     .DoAddLink = True
  213.   End With
  214. End Sub
  215. Private Sub ExitMenu_Click()
  216.   End
  217. End Sub
  218.