⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchmain.vb

📁 MapX安装软件完整版。MapX的使用必须得基于MapInfo的table数据
💻 VB
📖 第 1 页 / 共 3 页
字号:
				curFeatures = searchLayer.SearchWithinDistance(pt, dist, MapXLib.MapUnitConstants.miUnitMile, searchType)
				' Add results of search to results list box control
				For	Each obj In curFeatures
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.FeatureID. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.Name. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchResultsList.Items.Add(obj.Name & "  id: " & obj.FeatureID)
				Next obj
				' If menu item to add results to selection is true, the replace
				' the selection for that layer with search results
				If add2selectionMenuItem.Checked = True Then
					'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.Selection. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchLayer.Selection.Replace(curFeatures)
				End If
				
				' Clear object Variables
				'UPGRADE_NOTE: Object pt may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				pt = Nothing
				'UPGRADE_NOTE: Object curFeatures may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				curFeatures = Nothing
				'UPGRADE_NOTE: Object obj may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				obj = Nothing
			Case SEARCH_RECTANGLE_TOOL
				' Set rectangle to be used in search
				rc.Set(eventArgs.X1, eventArgs.Y1, eventArgs.X2, eventArgs.Y2)
				' Perform search
				'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.SearchWithinRectangle. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
				curFeatures = searchLayer.SearchWithinRectangle(rc, searchType)
				' Add results of search to results list box control
				For	Each obj In curFeatures
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.FeatureID. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.Name. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchResultsList.Items.Add(obj.Name & "  id: " & obj.FeatureID)
				Next obj
				' If menu item to add results to selection is true, the replace
				' the selection for that layer with search results
				If add2selectionMenuItem.Checked = True Then
					'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.Selection. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchLayer.Selection.Replace(curFeatures)
				End If
				
				' Clear object Variables
				'UPGRADE_NOTE: Object pt may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				pt = Nothing
				'UPGRADE_NOTE: Object curFeatures may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				curFeatures = Nothing
				'UPGRADE_NOTE: Object obj may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				obj = Nothing
				'UPGRADE_NOTE: Object rc may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				rc = Nothing
			Case SEARCH_FEATURE_TOOL
				' Get layer to be used as feature selection layer
				featureLyr = Map1.Layers(searchFeatureLayerCombo.Text)
				pt.Set(eventArgs.X1, eventArgs.Y1)
				' Get feature user wants to use in search, based on where
				' the clicked
				curFeatures = featureLyr.SearchAtPoint(pt)
				' if a feature is found, set a variable to it
				If curFeatures.Count > 0 Then
					obj = curFeatures(1)
				Else
					' display message telling user that they missed a feature for the
					' layer they specified as the feature Search Layer
					MsgBox("No features in collection")
					Exit Sub
				End If
				' Perform search for objects that lie within feature chosen
				'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.SearchWithinFeature. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
				curFeatures = searchLayer.SearchWithinFeature(obj, searchType)
				' Add results of search to results list box control
				For	Each obj In curFeatures
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.FeatureID. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.Name. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchResultsList.Items.Add(obj.Name & "  id: " & obj.FeatureID)
				Next obj
				' If menu item to add results to selection is true, the replace
				' the selection for that layer with search results
				If add2selectionMenuItem.Checked = True Then
					'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.Selection. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchLayer.Selection.Replace(curFeatures)
				End If
				
				' Clear object Variables
				'UPGRADE_NOTE: Object pt may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				pt = Nothing
				'UPGRADE_NOTE: Object curFeatures may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				curFeatures = Nothing
				'UPGRADE_NOTE: Object obj may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				obj = Nothing
				'UPGRADE_NOTE: Object featureLyr may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				featureLyr = Nothing
			Case SEARCH_POINT_TOOL
				searchResultsList.Items.Clear()
				' Assign point values where user clicked
				pt.Set(eventArgs.X1, eventArgs.Y1)
				' Perform search
				'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.SearchAtPoint. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
				curFeatures = searchLayer.SearchAtPoint(pt)
				' Add results of search to results list box control
				For	Each obj In curFeatures
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.FeatureID. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					'UPGRADE_WARNING: Couldn't resolve default property of object obj.Name. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchResultsList.Items.Add(obj.Name & "  id: " & obj.FeatureID)
				Next obj
				' If menu item to add results to selection is true, the replace
				' the selection for that layer with search results
				If add2selectionMenuItem.Checked = True Then
					'UPGRADE_WARNING: Couldn't resolve default property of object searchLayer.Selection. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
					searchLayer.Selection.Replace(curFeatures)
				End If
				
				' Clear object Variables
				'UPGRADE_NOTE: Object pt may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				pt = Nothing
				'UPGRADE_NOTE: Object curFeatures may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				curFeatures = Nothing
				'UPGRADE_NOTE: Object obj may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
				obj = Nothing
			Case Else
		End Select 'End Case
		Exit Sub
ErrHand: 
		MsgBox(Err.Description)
	End Sub
	
	Public Sub panToolMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles panToolMenuItem.Popup
		panToolMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub panToolMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles panToolMenuItem.Click
		'set pan tool to be active tool
		Map1.CurrentTool = MapXLib.ToolConstants.miPanTool
	End Sub
	
	Public Sub searchDistanceMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchDistanceMenuItem.Popup
		searchDistanceMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub searchDistanceMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchDistanceMenuItem.Click
		'set custom search tool to be active tool
		Map1.CurrentTool = SEARCH_DISTANCE_TOOL
	End Sub
	
	Public Sub searchFeatureMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchFeatureMenuItem.Popup
		searchFeatureMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub searchFeatureMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchFeatureMenuItem.Click
		'set custom search tool to be active tool
		Map1.CurrentTool = SEARCH_FEATURE_TOOL
	End Sub
	
	'UPGRADE_WARNING: Event searchLayerListCombo.SelectedIndexChanged may fire when form is intialized. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2075"'
	Private Sub searchLayerListCombo_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchLayerListCombo.SelectedIndexChanged
		searchLayer = Map1.Layers(searchLayerListCombo.Text)
	End Sub
	
	Public Sub searchPointMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchPointMenuItem.Popup
		searchPointMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub searchPointMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchPointMenuItem.Click
		'set custom search tool to be active tool
		Map1.CurrentTool = SEARCH_POINT_TOOL
	End Sub
	
	Public Sub searchRectangleMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchRectangleMenuItem.Popup
		searchRectangleMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub searchRectangleMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles searchRectangleMenuItem.Click
		'set custom search tool to be active tool
		Map1.CurrentTool = SEARCH_RECTANGLE_TOOL
	End Sub
	
	Public Sub zoomInToolMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles zoomInToolMenuItem.Popup
		zoomInToolMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub zoomInToolMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles zoomInToolMenuItem.Click
		'Set zoom in tool to be active tool
		Map1.CurrentTool = MapXLib.ToolConstants.miZoomInTool
	End Sub
	
	Public Sub zoomOutToolMenuItem_Popup(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles zoomOutToolMenuItem.Popup
		zoomOutToolMenuItem_Click(eventSender, eventArgs)
	End Sub
	Public Sub zoomOutToolMenuItem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles zoomOutToolMenuItem.Click
		'Set zoom out tool to be active tool
		Map1.CurrentTool = MapXLib.ToolConstants.miZoomOutTool
	End Sub
	
	Public Sub updateControls()
		Dim lyr As MapXLib.Layer
		If Map1.Layers.Count > 0 Then
			searchLayerListCombo.Items.Clear()
			searchFeatureLayerCombo.Items.Clear()
			For	Each lyr In Map1.Layers
				searchLayerListCombo.Items.Add(lyr.Name)
				searchFeatureLayerCombo.Items.Add(lyr.Name)
			Next lyr
			searchLayerListCombo.SelectedIndex = 0
			searchFeatureLayerCombo.SelectedIndex = 0
			searchLayer = Map1.Layers(searchLayerListCombo.Text)
			
			'UPGRADE_NOTE: Object lyr may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1029"'
			lyr = Nothing
		End If
	End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -