📄 form1.vb
字号:
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Public ReadOnly GENERIC_WRITE As Long = &H40000000
Public ReadOnly FILE_SHARE_READ As Long = &H1
Public ReadOnly CREATE_ALWAYS As Long = 1
Public ReadOnly FILE_ATTRIBUTE_NORMAL As Long = &H80000000
Dim KX As Single
Dim KY As Single
Dim PreviousPoint As POINTAPI
Dim Offset As POINTAPI
Dim drag As Boolean
Dim FScale As Long = 100
Public CADImage As IntPtr
Dim lForm As Form2 = New Form2
<DllImport("CADImage.dll", _
SetLastError:=True, _
CharSet:=CharSet.Ansi, ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CreateCAD(ByVal hWindow As IntPtr, ByVal lpFileName As String) As IntPtr
End Function
<DllImport("Cadimage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function SetDefaultColor(ByVal hObject As IntPtr, ByVal ADefaultColor As Integer) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CloseCAD(ByVal hObject As IntPtr) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function DrawCAD(ByVal hObject As IntPtr, ByVal hDC As IntPtr, ByRef lprc As Rect) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function GetExtentsCAD(ByVal handle As IntPtr, ByRef fRect As Rect) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CADLayerCount(ByVal hObject As IntPtr) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CADLayer(ByVal hObject As IntPtr, ByVal nIndex As Integer, ByRef lpData As Data) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function GetLastErrorCAD(ByVal lbBuf As String) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function GetBoxCAD(ByVal Handle As IntPtr, ByRef AbsWidth As Single, ByRef AbsHeight As Single) As Long
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function DrawCADtoBitmap(ByVal hObject As IntPtr, ByRef lpcd As CADDRAW) As Long
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function DrawCADtoJpeg(ByVal Handle As IntPtr, ByVal CdDraw As CADDRAW) As IntPtr
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CADLayoutsCount(ByVal Handle As IntPtr) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function SaveCADtoBitmap(ByVal Handle As IntPtr, ByRef cADDraw As CADDRAW, ByVal FileName As String) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function SaveCADtoJpeg(ByVal Handle As IntPtr, ByRef cADDraw As CADDRAW, ByVal FileName As String) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CADLayerVisible(ByVal Handle As Integer, ByVal Visible As Integer) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function CADLayoutName(ByVal Handle As IntPtr, ByVal Index As Integer, <MarshalAs(UnmanagedType.LPStr)> ByRef Name As String, ByVal nSize As Integer) As Integer
End Function
<DllImport("CADImage.dll", _
SetLastError:=True, CharSet:=CharSet.Ansi, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function DefaultLayoutIndex(ByVal Handle As IntPtr) As Integer
End Function
Public Sub GetClientRect(ByVal acl As Control, ByRef R As Rect)
R.Left = acl.Left
R.Top = acl.Top
R.Right = acl.Size.Width
R.Bottom = acl.Size.Height
End Sub
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents panel1 As System.Windows.Forms.Panel
Friend WithEvents dlgOpenDXFFile As System.Windows.Forms.OpenFileDialog
Friend WithEvents CD As System.Windows.Forms.SaveFileDialog
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem10 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem11 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem12 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem13 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem14 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem15 As System.Windows.Forms.MenuItem
Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.panel1 = New System.Windows.Forms.Panel
Me.dlgOpenDXFFile = New System.Windows.Forms.OpenFileDialog
Me.CD = New System.Windows.Forms.SaveFileDialog
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem3 = New System.Windows.Forms.MenuItem
Me.MenuItem11 = New System.Windows.Forms.MenuItem
Me.MenuItem4 = New System.Windows.Forms.MenuItem
Me.MenuItem10 = New System.Windows.Forms.MenuItem
Me.MenuItem14 = New System.Windows.Forms.MenuItem
Me.MenuItem15 = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
Me.MenuItem13 = New System.Windows.Forms.MenuItem
Me.MenuItem5 = New System.Windows.Forms.MenuItem
Me.MenuItem6 = New System.Windows.Forms.MenuItem
Me.MenuItem7 = New System.Windows.Forms.MenuItem
Me.MenuItem8 = New System.Windows.Forms.MenuItem
Me.MenuItem9 = New System.Windows.Forms.MenuItem
Me.MenuItem12 = New System.Windows.Forms.MenuItem
Me.ColorDialog1 = New System.Windows.Forms.ColorDialog
Me.SuspendLayout()
'
'panel1
'
Me.panel1.AutoScroll = True
Me.panel1.BackColor = System.Drawing.SystemColors.Control
Me.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.panel1.Dock = System.Windows.Forms.DockStyle.Fill
Me.panel1.Location = New System.Drawing.Point(0, 0)
Me.panel1.Name = "panel1"
Me.panel1.Size = New System.Drawing.Size(736, 299)
Me.panel1.TabIndex = 7
'
'dlgOpenDXFFile
'
Me.dlgOpenDXFFile.DefaultExt = "*.dxf"
Me.dlgOpenDXFFile.Filter = "*.dxf;*.dwg |*.dxf;*.dwg"
Me.dlgOpenDXFFile.RestoreDirectory = True
Me.dlgOpenDXFFile.Title = "OpenDXFFile"
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem14, Me.MenuItem2, Me.MenuItem12})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem3, Me.MenuItem11, Me.MenuItem4, Me.MenuItem10})
Me.MenuItem1.Text = "File"
'
'MenuItem3
'
Me.MenuItem3.Index = 0
Me.MenuItem3.Text = "Load"
'
'MenuItem11
'
Me.MenuItem11.Enabled = False
Me.MenuItem11.Index = 1
Me.MenuItem11.Text = "Save as BMP"
'
'MenuItem4
'
Me.MenuItem4.Enabled = False
Me.MenuItem4.Index = 2
Me.MenuItem4.Text = "Save as JPG"
'
'MenuItem10
'
Me.MenuItem10.Index = 3
Me.MenuItem10.Text = "Exit"
'
'MenuItem14
'
Me.MenuItem14.Index = 1
Me.MenuItem14.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem15})
Me.MenuItem14.Text = "View"
'
'MenuItem15
'
Me.MenuItem15.Enabled = False
Me.MenuItem15.Index = 0
Me.MenuItem15.Text = "SetDefaultColor"
'
'MenuItem2
'
Me.MenuItem2.Index = 2
Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem13, Me.MenuItem5, Me.MenuItem6, Me.MenuItem7, Me.MenuItem8, Me.MenuItem9})
Me.MenuItem2.Text = "Scale"
'
'MenuItem13
'
Me.MenuItem13.Enabled = False
Me.MenuItem13.Index = 0
Me.MenuItem13.Text = "10"
'
'MenuItem5
'
Me.MenuItem5.Enabled = False
Me.MenuItem5.Index = 1
Me.MenuItem5.Text = "50"
'
'MenuItem6
'
Me.MenuItem6.Checked = True
Me.MenuItem6.Enabled = False
Me.MenuItem6.Index = 2
Me.MenuItem6.Text = "100"
'
'MenuItem7
'
Me.MenuItem7.Enabled = False
Me.MenuItem7.Index = 3
Me.MenuItem7.Text = "200"
'
'MenuItem8
'
Me.MenuItem8.Enabled = False
Me.MenuItem8.Index = 4
Me.MenuItem8.Text = "500"
'
'MenuItem9
'
Me.MenuItem9.Enabled = False
Me.MenuItem9.Index = 5
Me.MenuItem9.Text = "1000"
'
'MenuItem12
'
Me.MenuItem12.Index = 3
Me.MenuItem12.Text = "Layers"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -