프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Settings.vb @ 47a4970e

이력 | 보기 | 이력해설 | 다운로드 (3.01 KB)

1
Imports System.IO
2

    
3
Public Class Settings
4

    
5
    Private Sub Settings_Load(sender As Object, e As EventArgs) Handles MyBase.Load
6
        Txt_DBPath.Text = My.Settings.DBPath
7
        Txt_Plant_Hierarchy.Text = My.Settings.Plant_Hierarchy
8
        Txt_SymbolLibrary.Text = My.Settings.SymbolLibrary
9
    End Sub
10

    
11
    Private Sub Btn_Save_Click(sender As Object, e As EventArgs) Handles Btn_Save.Click
12
        If Txt_DBPath.Text <> "" And Txt_Plant_Hierarchy.Text <> "" Then
13
            My.Settings.DBPath = Txt_DBPath.Text
14
            My.Settings.Plant_Hierarchy = Txt_Plant_Hierarchy.Text
15
            My.Settings.SymbolLibrary = Txt_SymbolLibrary.Text
16
            My.Settings.Save()
17
            MessageBox.Show("저장완료")
18
        Else
19
            MessageBox.Show("설정값이 잘못되었습니다.")
20

    
21
        End If
22
    End Sub
23

    
24
    Private Sub Btn_Cancel_Click(sender As Object, e As EventArgs) Handles Btn_Cancel.Click
25
        Me.Close()
26
    End Sub
27

    
28
    Private Sub Btn_SelectPath_Click(sender As Object, e As EventArgs) Handles Btn_SelectPath.Click
29
        Txt_DBPath.Text = OpenFileDlg("DB files (*.DB)|*.DB")
30
    End Sub
31

    
32
    Private Function OpenFileDlg(ByVal sFilter As String) As String
33
        Dim myStream As FileStream = Nothing
34

    
35
        Dim openFileDialog1 As New OpenFileDialog()
36
        Dim sSelectPath As String = ""
37
        openFileDialog1.InitialDirectory = My.Settings.DBPath
38
        openFileDialog1.Filter = sFilter
39
        openFileDialog1.FilterIndex = 2
40
        openFileDialog1.RestoreDirectory = True
41

    
42
        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
43
            Try
44
                myStream = openFileDialog1.OpenFile()
45
                If (myStream IsNot Nothing) Then
46
                    ' Insert code to read the stream here.
47
                    sSelectPath = myStream.Name
48

    
49
                End If
50
            Catch Ex As Exception
51
                MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
52
            Finally
53
                ' Check this again, since we need to make sure we didn't throw an exception on open.
54
                If (myStream IsNot Nothing) Then
55
                    myStream.Close()
56
                End If
57
            End Try
58
        End If
59
        Return sSelectPath
60
    End Function
61

    
62

    
63
    Private Sub Btn_Plant_Hierarchy_Click(sender As Object, e As EventArgs) Handles Btn_Plant_Hierarchy.Click
64
        Dim oOpenFolderDlg = New FolderBrowserDialog()
65
        oOpenFolderDlg.SelectedPath = My.Settings.Plant_Hierarchy
66
        Dim result As DialogResult = oOpenFolderDlg.ShowDialog()
67
        Dim sFolderName As String = ""
68

    
69
        If (result = DialogResult.OK) Then
70
            sFolderName = oOpenFolderDlg.SelectedPath
71
            Txt_Plant_Hierarchy.Text = sFolderName
72
            '    Txt_FolderPath.Text = sFolderName
73
        End If
74
    End Sub
75

    
76
    Private Sub Btn_SymbolLibrary_Click(sender As Object, e As EventArgs) Handles Btn_SymbolLibrary.Click
77
        Txt_SymbolLibrary.Text = OpenFileDlg("Excel File(*.xls, *.xlsx)|*.xls;*.xlsx")
78
    End Sub
79
End Class
클립보드 이미지 추가 (최대 크기: 500 MB)