|
|
楼主 |
发表于 2005-11-12 20:48:49
|
显示全部楼层
form1.frm
VERSION 5.00
Object = "{E760686B-BC9E-4802-9ECF-175FDF4062CE}#5.0#0"; "MAPX50.DLL"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 8310
ClientLeft = 165
ClientTop = 735
ClientWidth = 10920
LinkTopic = "Form1"
ScaleHeight = 8310
ScaleWidth = 10920
StartUpPosition = 3 '窗口缺省
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 3
Top = 7935
Width = 10920
_ExtentX = 19262
_ExtentY = 661
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 690
Left = 0
TabIndex = 2
Top = 0
Width = 10920
_ExtentX = 19262
_ExtentY = 1217
ButtonWidth = 1085
ButtonHeight = 1058
AllowCustomize = 0 'False
Appearance = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 2
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "new"
ImageKey = "new"
BeginProperty ButtonMenus {66833FEC-8583-11D1-B16A-00C0F0283628}
NumButtonMenus = 2
BeginProperty ButtonMenu1 {66833FEE-8583-11D1-B16A-00C0F0283628}
EndProperty
BeginProperty ButtonMenu2 {66833FEE-8583-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "car"
ImageKey = "car"
EndProperty
EndProperty
OLEDropMode = 1
End
Begin MSComctlLib.ImageList ImageList1
Left = 0
Top = 960
_ExtentX = 1005
_ExtentY = 1005
BackColor = 65535
ImageWidth = 34
ImageHeight = 34
MaskColor = 255
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 3
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0000
Key = "new"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":033A
Key = "save"
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":3AD4E
Key = "car"
EndProperty
EndProperty
End
Begin MSComDlg.CommonDialog cm1
Left = 120
Top = 7080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MapXLib.Map Map1
Height = 6375
Left = 360
TabIndex = 1
Top = 960
Width = 9855
_Version = 500012
_ExtentX = 17383
_ExtentY = 11245
_StockProps = 1
MapCatalog.GeoDictionary= "GeoDictionary"
GeoSet = "Empty GeosetName {9A9AC2F4-8375-44d1-BCEB-476AE986F190}"
GeoSetUserName = "United States"
DefaultStyle.TextFontBackColor= 16777215
DefaultStyle.SupportsBitmapSymbols= -1 'True
DefaultStyle.SymbolChar= 55
DefaultStyle.SymbolFontBackColor= 16777215
BeginProperty DefaultStyle.TextFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty DefaultStyle.SymbolFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Map Symbols"
Size = 14.25
Charset = 2
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
DefaultStyle.LineStyle= 1
DefaultStyle.LineWidth= 1
DefaultStyle.RegionColor= 16777215
DefaultStyle.LinePattern= 2
DefaultStyle.RegionBackColor= 16777215
DefaultStyle.RegionBorderStyle= 1
DefaultStyle.RegionBorderWidth= 1
Title.Visible = 0 'False
Title.Text = "Empty Title {01A9504B-CE13-4415-A5A0-51D8C2F15204}"
Title.Style.TextFontBackColor= 16777215
Title.Style.TextFontOpaque= -1 'True
Title.Style.SymbolChar= 0
BeginProperty Title.Style.TextFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 23.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Title.Style.SymbolFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 23.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Title.X = 3285
Title.Y = 425
Map.NumericCoordSys.ProjectionInfo= "Form1.frx":3AFE0
Map.DisplayCoordSys.ProjectionInfo= "Form1.frx":3B110
End
Begin VB.CommandButton Command1
Caption = "打开表"
Height = 375
Left = 9120
TabIndex = 0
Top = 7440
Width = 1095
End
Begin VB.Menu MNUFile
Caption = "文件"
Begin VB.Menu MNUOpenTable
Caption = "打开表"
End
Begin VB.Menu MNUOpenProject
Caption = "打开工程"
End
End
Begin VB.Menu MNUEtid
Caption = "编辑"
Begin VB.Menu MNUCreatPoint
Caption = "创建点对象"
End
End
Begin VB.Menu MNUTool1
Caption = "工具1"
Begin VB.Menu MNUZoomin
Caption = "放大"
End
Begin VB.Menu MNUZoomout
Caption = "缩小"
End
Begin VB.Menu MNUPan
Caption = "移动"
End
End
Begin VB.Menu MNUTool2
Caption = "工具2"
Begin VB.Menu MNUDistance
Caption = "量算距离"
End
Begin VB.Menu MNUToolsRuler
Caption = "俩点间距"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mousedownX1 As Double, mousedownY1 As Double
Dim x1 As Single, y1 As Single
Private Sub Command1_Click()
Dim layerinfo As New MapXLib.layerinfo
Dim lyr As MapXLib.Layer
Dim FileName As String, FilePath As String, LayerName As String
cm1.DialogTitle = "打开表"
cm1.DefaultExt = "Tab|*.tab"
cm1.Filter = "表(*.tab)|*.tab"
cm1.ShowOpen
FileName = cm1.FileTitle '文件名
FilePath = cm1.FileName '路径名+文件名
FilePath = Left(FilePath, InStr(FilePath, FileName) - 1) '得到路径名
LayerName = Left(FileName, InStr(FileName, ".") - 1) '得到表名
'将新建图层加入到数据集
layerinfo.Type = miLayerInfoTypeTab
layerinfo.AddParameter "FileSpec", FilePath + "" + FileName
layerinfo.AddParameter "NAME", LayerName
Set lyr = Map1.Layers.Add(layerinfo, 1)
End Sub
Private Sub Command2_Click(Index As Integer)
Case Index = 0
Map1.CurrentTool = miZoomInTool
End Sub
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Map1.CurrentTool = RulerToolID Then
Map1.ConvertCoord X, Y, mousedownX1, mousedownY1, miScreenToMap
End If
End Sub
Private Sub Map1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Map1.CurrentTool = RulerToolID Then
Dim x2 As Double
Dim y2 As Double
Map1.MapUnit = RulerUnit
Map1.ConvertCoord X, Y, x2, y2, miScreenToMap
StatusBar1.SimpleText = Map1.Distance(mousedownX1, mousedownY1, x2, y2) & "" & RulerUnitString
End If
End Sub
Private Sub MNUCreatPoint_Click()
Dim pnt As MapXLib.Point
Dim FeaFac As MapXLib.FeatureFactory
Dim lyr As MapXLib.Layer
Dim ftr As MapXLib.Feature
Dim newstyle As MapXLib.Style
'绑定
Set lyr = Map1.Layers.Item(1)
Set FeaFac = Map1.FeatureFactory
'设置点对象样式
With newstyle
.SymbolType = miSymbolTypeBitmap
.SymbolBitmapSize = 24
.SymbolBitmapTransparent = False
.SymbolBitmapName = "YIEL2-32.BMP"
End With
Map1.AutoRedraw = False '禁止自动刷新
lyr.Editable = True '设置当前图层为可写烶态
'创建点对象
pnt.Set x1, y1
'添加进当前图层
Set ftr = FeaFac.CreateSymbol(pnt, newstyle)
'创建符号
Set ftr = FeaFac.CreateSymbol(pnt, Map1.DefaultStyle)
'添加
lyr.AddFeature ftr
lyr.Refresh
Map1.AutoRedraw = True
lyr.Editable = False
'釃放
Set pnt = Nothing
Set FeaFac = Nothing
Set lyr = Nothing
Set ftr = Nothing
End Sub
Private Sub MNUDistance_Click()
Dim pnt As MapXLib.Point
Dim ftr As MapXLib.Feature
DistanceValue = 0
'第一个点
pnt.Set ftr.Parts.Item(1).Item(1).X, ftr.Parts.Item(1).Item(1).Y
For j = 2 To ftr.Parts.Item(1).Count
'累加
x1 = ftr.Parts.Item(1).Item(j - 1).X
y1 = ftr.Parts.Item(1).Item(j - 1).Y
x2 = ftr.Parts.Item(1).Item(j).X
y2 = ftr.Parts.Item(1).Item(j).Y
DistanceValue = diatancevalue + Me.Map1.Distance(x1, y1, x2, y2)
Next
'的边形周长
MsgBox DistanceValue + " " + Me.Map1.MapUnit
End Sub
Private Sub Form_Load()
Map1.GeoSet = ""
'Map1.Cureatcustomtool RulerToolID, miToolTypeLine, miSizeAllCursor
Map1.CreateCustomTool PolyRulerToolID, miToolTypePoly, miSizeAllCursor
End Sub
Private Sub MNUOpenTable_Click()
Dim layerinfo As New MapXLib.layerinfo
Dim lyr As MapXLib.Layer
Dim FileName As String, FilePath As String, LayerName As String
cm1.DialogTitle = "打开表"
cm1.DefaultExt = "Tab|*.tab"
cm1.Filter = "表(*.tab)|*.tab"
cm1.ShowOpen
FileName = cm1.FileTitle '文件名
FilePath = cm1.FileName '路径名+文件名
FilePath = Left(FilePath, InStr(FilePath, FileName) - 1) '得到路径名
LayerName = Left(FileName, InStr(FileName, ".") - 1) '得到表名
'将新建图层加入到数据集
layerinfo.Type = miLayerInfoTypeTab
layerinfo.AddParameter "FileSpec", FilePath + "" + FileName
layerinfo.AddParameter "NAME", LayerName
Set lyr = Map1.Layers.Add(layerinfo, 1)
End Sub
Private Sub MNUToolsRuler_Click()
'checkedmenu.Checked = False
'pressedbutton.Value = tbrUnpressed
Set checkedmenu = MNUToolsRuler
'Set pressedbutton = Toolbar1.Buttons(5)
checkedmenu.Checked = True
'pressedbutton.Value = tbrPressed
Toolbar1.Refresh
Map1.CurrentTool = RulerToolID
End Sub
Private Sub MNUOpenProject_Click()
cm1.DialogTitle = "打开工程"
cm1.DefaultExt = "Gst|*.gst"
cm1.Filter = "工程(*.gst)|*.gst"
cm1.ShowOpen
FileName = cm1.FileTitle
FilePath = cm1.FileName
Map1.GeoSet = FilePath
End Sub
Private Sub MNUPan_Click()
Map1.CurrentTool = miPanTool
End Sub
Private Sub MNUZoomin_Click()
Map1.CurrentTool = miZoomInTool
End Sub
Private Sub MNUZoomout_Click()
Map1.CurrentTool = miZoomOutTool
End Sub |
|