-
Notifications
You must be signed in to change notification settings - Fork 1
/
Form1.vb
74 lines (63 loc) · 2.56 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraMap
Imports System.IO
Namespace MapSample
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
End Sub
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Dim dialog As New SaveFileDialog()
dialog.DefaultExt = ".shp" ' Default file extension
dialog.Filter = "Shape file (.shp)|*.shp" ' Filter files by extension
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Dim vl As VectorItemsLayer = TryCast(Me.mapControl1.Layers(0), VectorItemsLayer)
If vl IsNot Nothing Then
vl.ExportToShp(dialog.FileName, New ShpExportOptions() With {.ExportToDbf = True, .ShapeType = ShapeType.PolygonZ})
MessageBox.Show("Shape File Saved")
Return
End If
MessageBox.Show("An error occured")
End If
End Sub
Private Sub simpleButton2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnShp.Click
Dim dialog As New OpenFileDialog()
dialog.DefaultExt = ".shp" ' Default file extension
dialog.Filter = "Shape file (.shp)|*.shp" ' Filter files by extension
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
shapefileDataAdapter1.FileUri = New Uri(dialog.FileName)
Dim projectionPath As String = dialog.FileName.Substring(0, dialog.FileName.Length-3) & "prj"
If File.Exists(projectionPath) Then
btnSave.Enabled = True
btnPrj.Text = "2. Projection Loaded automatically"
btnPrj.Enabled = False
Else
btnPrj.Text = "2. Open Projection File (*.prj)"
btnPrj.Enabled = True
btnSave.Enabled = False
End If
End If
End Sub
Private Sub vectorItemsLayer1_DataLoaded(ByVal sender As Object, ByVal e As DataLoadedEventArgs) Handles vectorItemsLayer1.DataLoaded
mapControl1.ZoomToFitLayerItems()
End Sub
Private Sub simpleButton3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPrj.Click
Dim dialog As New OpenFileDialog()
dialog.DefaultExt = ".prj" ' Default file extension
dialog.Filter = "Shape file (.prj)|*.prj" ' Filter files by extension
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
shapefileDataAdapter1.SourceCoordinateSystem= ShapefileDataAdapter.LoadPrjFile(New Uri(dialog.FileName))
btnSave.Enabled = True
End If
End Sub
End Class
End Namespace