frmBrowser.frm
上传用户:shushan03
上传日期:2019-11-23
资源大小:44k
文件大小:9k
源码类别:

CAD

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form frmBrowser 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "DXF Browser"
  5.    ClientHeight    =   7380
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   9930
  9.    Icon            =   "frmBrowser.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   7380
  14.    ScaleWidth      =   9930
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.PictureBox picControls 
  17.       Align           =   4  'Align Right
  18.       Height          =   7380
  19.       Left            =   7410
  20.       ScaleHeight     =   7320
  21.       ScaleWidth      =   2460
  22.       TabIndex        =   1
  23.       Top             =   0
  24.       Width           =   2520
  25.       Begin VB.Frame frmView 
  26.          Caption         =   "View"
  27.          Height          =   615
  28.          Left            =   120
  29.          TabIndex        =   12
  30.          Top             =   6600
  31.          Width           =   2295
  32.          Begin VB.TextBox txtView 
  33.             Height          =   285
  34.             Left            =   1560
  35.             TabIndex        =   16
  36.             Top             =   215
  37.             Width           =   495
  38.          End
  39.          Begin VB.VScrollBar vscrView 
  40.             Height          =   450
  41.             Left            =   2040
  42.             TabIndex        =   15
  43.             Top             =   120
  44.             Width           =   190
  45.          End
  46.          Begin VB.OptionButton optView 
  47.             Caption         =   "Blocks"
  48.             Height          =   195
  49.             Index           =   1
  50.             Left            =   720
  51.             TabIndex        =   14
  52.             Top             =   240
  53.             Width           =   855
  54.          End
  55.          Begin VB.OptionButton optView 
  56.             Caption         =   "PV"
  57.             Height          =   195
  58.             Index           =   0
  59.             Left            =   120
  60.             TabIndex        =   13
  61.             Top             =   240
  62.             Value           =   -1  'True
  63.             Width           =   615
  64.          End
  65.       End
  66.       Begin VB.Frame frameMouse 
  67.          Caption         =   "Mouse"
  68.          Height          =   615
  69.          Left            =   120
  70.          TabIndex        =   6
  71.          Top             =   5880
  72.          Width           =   2295
  73.          Begin VB.CommandButton cmdZoomIn 
  74.             Caption         =   "+"
  75.             Height          =   255
  76.             Left            =   1680
  77.             TabIndex        =   11
  78.             Top             =   240
  79.             Width           =   255
  80.          End
  81.          Begin VB.CommandButton cmdZoomOut 
  82.             Caption         =   "-"
  83.             Height          =   255
  84.             Left            =   1920
  85.             TabIndex        =   10
  86.             Top             =   240
  87.             Width           =   255
  88.          End
  89.          Begin VB.OptionButton optMouse 
  90.             Caption         =   " Zoom"
  91.             Height          =   255
  92.             Index           =   1
  93.             Left            =   840
  94.             TabIndex        =   9
  95.             Top             =   240
  96.             Width           =   855
  97.          End
  98.          Begin VB.OptionButton optMouse 
  99.             Caption         =   "Center"
  100.             Height          =   255
  101.             Index           =   4
  102.             Left            =   3600
  103.             TabIndex        =   8
  104.             Top             =   240
  105.             Width           =   855
  106.          End
  107.          Begin VB.OptionButton optMouse 
  108.             Caption         =   "Pan"
  109.             Height          =   255
  110.             Index           =   0
  111.             Left            =   120
  112.             TabIndex        =   7
  113.             Top             =   240
  114.             Value           =   -1  'True
  115.             Width           =   615
  116.          End
  117.       End
  118.       Begin VB.ListBox List1 
  119.          Height          =   1980
  120.          IntegralHeight  =   0   'False
  121.          Left            =   120
  122.          TabIndex        =   5
  123.          Top             =   3840
  124.          Width           =   2295
  125.       End
  126.       Begin VB.DriveListBox Drive1 
  127.          Height          =   315
  128.          Left            =   120
  129.          TabIndex        =   4
  130.          Top             =   120
  131.          Width           =   2295
  132.       End
  133.       Begin VB.DirListBox Dir1 
  134.          Height          =   1665
  135.          Left            =   120
  136.          TabIndex        =   3
  137.          Top             =   480
  138.          Width           =   2295
  139.       End
  140.       Begin VB.FileListBox File1 
  141.          Height          =   1650
  142.          Left            =   120
  143.          Pattern         =   "*.dxf"
  144.          TabIndex        =   2
  145.          Top             =   2160
  146.          Width           =   2295
  147.       End
  148.    End
  149.    Begin VB.PictureBox picDXF 
  150.       AutoRedraw      =   -1  'True
  151.       Height          =   7380
  152.       Left            =   0
  153.       ScaleHeight     =   100
  154.       ScaleLeft       =   -5
  155.       ScaleMode       =   0  'User
  156.       ScaleTop        =   -95
  157.       ScaleWidth      =   100
  158.       TabIndex        =   0
  159.       Top             =   0
  160.       Width           =   7380
  161.    End
  162. End
  163. Attribute VB_Name = "frmBrowser"
  164. Attribute VB_GlobalNameSpace = False
  165. Attribute VB_Creatable = False
  166. Attribute VB_PredeclaredId = True
  167. Attribute VB_Exposed = False
  168. Option Explicit
  169. Dim MyDXF As DXFData
  170. Dim dragX As Single
  171. Dim dragY As Single
  172. Dim SelGroup As RECT
  173. Dim Pan As Boolean
  174. Dim Zoom As Boolean
  175. Sub RedrawPic()
  176. If optView(0) Then
  177.     DrawDXF picDXF, MyDXF
  178. Else
  179.     DrawBlock picDXF, MyDXF, vscrView.Value
  180. End If
  181. End Sub
  182. Private Sub cmdZoomIn_Click()
  183. picDXF.ScaleHeight = 0.75 * picDXF.ScaleHeight
  184. picDXF.ScaleWidth = 0.75 * picDXF.ScaleWidth
  185. RedrawPic
  186. End Sub
  187. Private Sub cmdZoomOut_Click()
  188. picDXF.ScaleHeight = 1.25 * picDXF.ScaleHeight
  189. picDXF.ScaleWidth = 1.25 * picDXF.ScaleWidth
  190. RedrawPic
  191. End Sub
  192. Private Sub Dir1_Change()
  193. File1.Path = Dir1.Path
  194. End Sub
  195. Private Sub Drive1_Change()
  196. Dir1.Path = Drive1.Drive
  197. End Sub
  198. Private Sub File1_Click()
  199. ImportDXF File1.Path & "" & File1.filename, MyDXF
  200. vscrView.Value = 0
  201. vscrView.Max = UBound(MyDXF.Blocks)
  202. RedrawPic
  203. 'Exit Sub
  204. 'This next part is merely a view of the dxf data
  205. On Error Resume Next
  206. List1.Clear
  207. Dim i As Integer
  208. Dim j As Integer
  209. Dim k As Integer
  210. For i = 0 To UBound(MyDXF.Blocks)
  211.     List1.AddItem "-" & MyDXF.Blocks(i).Name
  212.     For j = 0 To UBound(MyDXF.Blocks(i).Entities)
  213.         List1.AddItem "--" & MyDXF.Blocks(i).Entities(j).Type
  214.         For k = 0 To UBound(MyDXF.Blocks(i).Entities(j).Data)
  215.             List1.AddItem "---" & MyDXF.Blocks(i).Entities(j).Data(k).Key & " = " & MyDXF.Blocks(i).Entities(j).Data(k).Value
  216.         Next k
  217.     Next j
  218. Next i
  219. List1.AddItem "--------------"
  220. For i = 0 To UBound(MyDXF.Entities)
  221.     List1.AddItem "PV -" & MyDXF.Entities(i).Type
  222.     For k = 0 To UBound(MyDXF.Entities(i).Data)
  223.         List1.AddItem "---" & MyDXF.Entities(i).Data(k).Key & " = " & MyDXF.Entities(i).Data(k).Value
  224.     Next k
  225. Next i
  226. End Sub
  227. Private Sub optView_Click(Index As Integer)
  228. txtView = MyDXF.Blocks(vscrView.Value).Name
  229. RedrawPic
  230. End Sub
  231. Private Sub picDXF_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  232. dragX = X
  233. dragY = Y
  234. SelGroup.X1 = X
  235. SelGroup.Y1 = Y
  236. SelGroup.X2 = X
  237. SelGroup.Y2 = Y
  238. If optMouse(0) Then Pan = True
  239. If optMouse(1) Then Zoom = True
  240. End Sub
  241. Private Sub picDXF_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  242. Me.Caption = "DXF Browser -- (" & Format(X, "0.000") & "," & Format(-Y, "0.000") & ")"
  243. If Pan Then
  244.     picDXF.ScaleTop = picDXF.ScaleTop + (dragY - Y)
  245.     picDXF.ScaleLeft = picDXF.ScaleLeft + (dragX - X)
  246.     picDXF.Cls
  247.     picDXF.Picture = LoadPicture()
  248.     RedrawPic
  249.     Exit Sub
  250. End If
  251. If Zoom Then
  252.     picDXF.DrawMode = 6
  253.     picDXF.DrawStyle = 1
  254.     picDXF.DrawWidth = 1
  255.     picDXF.Line (SelGroup.X1, SelGroup.Y1)-(SelGroup.X2, SelGroup.Y2), vbBlack, B
  256.     picDXF.Line (SelGroup.X1, SelGroup.Y1)-(X, Y), vbBlack, B
  257.     SelGroup.X2 = X
  258.     SelGroup.Y2 = Y
  259. End If
  260. End Sub
  261. Private Sub picDXF_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  262. DoEvents
  263. picDXF.DrawMode = 13
  264. picDXF.DrawStyle = 0
  265. picDXF.DrawWidth = 1
  266. If Zoom Then
  267.     If SelGroup.X2 < SelGroup.X1 Then Swap SelGroup.X1, SelGroup.X2
  268.     If SelGroup.Y2 < SelGroup.Y1 Then Swap SelGroup.Y1, SelGroup.Y2
  269.     SelGroup.Y2 = SelGroup.Y1 + Abs(SelGroup.X2 - SelGroup.X1)
  270.     If SelGroup.X2 = SelGroup.X1 Then Exit Sub
  271.     If SelGroup.Y2 = SelGroup.Y1 Then Exit Sub
  272.     picDXF.ScaleWidth = Abs(SelGroup.X2 - SelGroup.X1)
  273.     picDXF.ScaleLeft = SelGroup.X1
  274.     picDXF.ScaleHeight = Abs(SelGroup.Y1 - SelGroup.Y2)
  275.     picDXF.ScaleTop = SelGroup.Y1
  276.     RedrawPic
  277. End If
  278. Pan = False
  279. Zoom = False
  280. End Sub
  281. Private Sub txtView_Change()
  282. RedrawPic
  283. End Sub
  284. Private Sub vscrView_Change()
  285. txtView = MyDXF.Blocks(vscrView.Value).Name
  286. End Sub
  287. Private Sub vscrView_Scroll()
  288. txtView = MyDXF.Blocks(vscrView.Value).Name
  289. End Sub