home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / PolarDraw / data1.cab / Samples / Visual_Basic / Simple / Simple.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-08-31  |  6.2 KB  |  161 lines

  1. VERSION 5.00
  2. Object = "{52DE3A21-0A3F-11D4-B9D2-008048FD54E6}#2.0#0"; "POLARDRAW20.OCX"
  3. Begin VB.Form frmSimpleDrawing 
  4.    Caption         =   "Simple Drawing"
  5.    ClientHeight    =   5025
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   8835
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   5025
  11.    ScaleWidth      =   8835
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin POLARDRAW20Lib.POLARDraw POLARDraw1 
  14.       Height          =   4815
  15.       Left            =   120
  16.       TabIndex        =   6
  17.       Top             =   120
  18.       Width           =   6375
  19.       _Version        =   131072
  20.       _ExtentX        =   11245
  21.       _ExtentY        =   8493
  22.       _StockProps     =   224
  23.       PaperShadowColor=   0
  24.       DrawPaperOutline=   -1  'True
  25.       DrawPaperShadow =   -1  'True
  26.       PaperShadowOffset=   24444616
  27.       ViewportOriginX =   8384568
  28.       ViewportOriginY =   48183456
  29.       PageOriginX     =   24379392
  30.       PageOriginY     =   5813682
  31.       HorizontalGrid  =   567
  32.       VerticalGrid    =   567
  33.       ShowVerticalScrollBar=   0   'False
  34.       ShowHorizontalScrollBar=   0   'False
  35.       ShowVerticalRuler=   0   'False
  36.       ShowHorizontalRuler=   0   'False
  37.       SelectionCount  =   -1
  38.       ShapeCount      =   1598273252
  39.       CanvasWidth     =   0
  40.       CanvasHeight    =   1598275446
  41.    End
  42.    Begin VB.ComboBox cmbEditMode 
  43.       Height          =   315
  44.       Left            =   6660
  45.       Style           =   2  'Dropdown List
  46.       TabIndex        =   2
  47.       Top             =   3390
  48.       Width           =   1575
  49.    End
  50.    Begin VB.ComboBox cmbShape 
  51.       Height          =   315
  52.       Left            =   6660
  53.       Style           =   2  'Dropdown List
  54.       TabIndex        =   0
  55.       Top             =   2580
  56.       Width           =   1575
  57.    End
  58.    Begin VB.Label Label5 
  59.       Caption         =   "Ctrl+R for resizing and   Ctrl + C for drawing (Create new)"
  60.       Height          =   570
  61.       Left            =   6675
  62.       TabIndex        =   5
  63.       Top             =   1650
  64.       Width           =   1875
  65.    End
  66.    Begin VB.Label Label4 
  67.       Caption         =   "Use combo boxes to switch between edit modes or use shortcuts:"
  68.       Height          =   645
  69.       Left            =   6690
  70.       TabIndex        =   4
  71.       Top             =   990
  72.       Width           =   2085
  73.    End
  74.    Begin VB.Label Label2 
  75.       Caption         =   "Current Edit Mode:"
  76.       Height          =   225
  77.       Left            =   6675
  78.       TabIndex        =   3
  79.       Top             =   3150
  80.       Width           =   1575
  81.    End
  82.    Begin VB.Label Label1 
  83.       Caption         =   "Current Shape Type:"
  84.       Height          =   315
  85.       Left            =   6660
  86.       TabIndex        =   1
  87.       Top             =   2385
  88.       Width           =   1575
  89.    End
  90. Attribute VB_Name = "frmSimpleDrawing"
  91. Attribute VB_GlobalNameSpace = False
  92. Attribute VB_Creatable = False
  93. Attribute VB_PredeclaredId = True
  94. Attribute VB_Exposed = False
  95. Dim pd_environment As POLARDRAW20Lib.Environment
  96. Public arr_ShapeTypeConstants As Variant
  97. Public arr_ShapeTypeNames As Variant
  98. Public arr_EditModeConstants As Variant
  99. Public arr_EditModeNames As Variant
  100. Private Sub cmbEditMode_Click()
  101.    pd_environment.EditMode = cmbEditMode.ItemData(cmbEditMode.ListIndex)
  102.    If pd_environment.EditMode = polEditPoints Then
  103.        POLARDraw1.ShowConnectors = True
  104.    Else
  105.        POLARDraw1.ShowConnectors = False
  106.    End If
  107. End Sub
  108. Private Sub cmbShape_Click()
  109.       pd_environment.CurrentShapeType = cmbShape.ItemData(cmbShape.ListIndex)
  110.       
  111.       If pd_environment.CurrentShapeType = polLink Then
  112.          POLARDraw1.ShowConnectors = True
  113.       Else
  114.          POLARDraw1.ShowConnectors = False
  115.       End If
  116. End Sub
  117. Private Sub Form_Load()
  118.   arr_ShapeTypeConstants = Array(polArc, polDiamond, polDimensionBar, polEllipse, polFreeform, polHexagon, polIsoscelesTriangle, polLeftArrow, polLine, polLink, polOctagon, polParallelogram, polPentagon, polPlainText, polPlusSign, polRectangle, polRightTriangle, polRoundRectangle, polStar, polTextBox, polTrapezoid)
  119.   arr_ShapeTypeNames = Array("Arc", "Diamond", "Dimension Bar", "Ellipse", "Freeform", "Hexagon", "Isosceles Triangle", "Left Arrow", "Line", "Link", "Octagon", "Parallelogram", "Pentagon", "Plain Text", "Plus Sign", "Rectangle", "Right Triangle", "Round Rectangle", "Star", "Text Box", "Trapezoid")
  120.   arr_EditModeConstants = Array(polCreateNew, polEditPoints, polResize, polRotate, polView)
  121.   arr_EditModeNames = Array("Draw", "Edit Polygon Points", "Resize", "Rotate", "Just View")
  122.    Set pd_environment = POLARDraw1.ActiveWindow.Environment
  123.    pd_environment.CurrentShapeType = polFreeform
  124.    pd_environment.EditMode = polCreateNew
  125.    'setting values for combo-box that enables switching between shape types
  126.    For i = 0 To UBound(arr_ShapeTypeConstants)
  127.       cmbShape.AddItem arr_ShapeTypeNames(i), i
  128.       cmbShape.ItemData(i) = arr_ShapeTypeConstants(i)
  129.    Next i
  130.    'setting values for combo-box that enables switching between edit modes
  131.    For i = 0 To UBound(arr_EditModeConstants)
  132.       cmbEditMode.AddItem arr_EditModeNames(i), i
  133.       cmbEditMode.ItemData(i) = arr_EditModeConstants(i)
  134.    Next i
  135.    cmbEditMode.ListIndex = IndexOf(cmbEditMode, pd_environment.EditMode)
  136.    cmbShape.ListIndex = IndexOf(cmbShape, pd_environment.CurrentShapeType)
  137.        
  138. End Sub
  139. Private Sub Form_Unload(Cancel As Integer)
  140.    Set pd_environment = Nothing
  141. End Sub
  142. Private Sub POLARDraw1_KeyDown(KeyCode As Integer, Shift As Integer)
  143.   If Shift = vbCtrlMask Then
  144.         Select Case KeyCode
  145.             Case vbKeyR
  146.                 pd_environment.EditMode = polResize
  147.                 cmbEditMode.ListIndex = IndexOf(cmbEditMode, pd_environment.EditMode)
  148.             Case vbKeyC
  149.                 pd_environment.EditMode = polCreateNew
  150.                 cmbEditMode.ListIndex = IndexOf(cmbEditMode, pd_environment.EditMode)
  151.         End Select
  152.     End If
  153. End Sub
  154. Private Function IndexOf(Combo As ComboBox, DataValue As Long) As Long
  155.    With Combo
  156.       For i = 0 To .ListCount - 1
  157.          If .ItemData(i) = DataValue Then IndexOf = i
  158.       Next
  159.    End With
  160. End Function
  161.