📄 filebrowser.vb
字号:
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(678, 318)
Me.Controls.Add(Me.BTN_ItemInfo)
Me.Controls.Add(Me.CheckBoxUseCache)
Me.Controls.Add(Me.BTN_Cancel)
Me.Controls.Add(Me.LBL_PhoneFiles)
Me.Controls.Add(Me.LBL_PCFiles)
Me.Controls.Add(Me.BTN_Create)
Me.Controls.Add(Me.BTN_Rename)
Me.Controls.Add(Me.BTN_Delete)
Me.Controls.Add(Me.BTN_Close)
Me.Controls.Add(Me.BTN_MovePhoneToPC)
Me.Controls.Add(Me.BTN_MovePCToPhone)
Me.Controls.Add(Me.BTN_CopyPhoneToPC)
Me.Controls.Add(Me.BTN_CopyPCToPhone)
Me.Controls.Add(Me.LBX_PCFiles)
Me.Controls.Add(Me.LBX_PhoneFiles)
Me.Controls.Add(Me.ProgressBar1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "FileBrowser"
Me.Text = "File Browser"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
<STAThread()> _
Shared Sub Main()
' Starts the application.
Application.Run(New FileBrowser)
End Sub
'===================================================================
' RefreshPhoneList
'
' Refresh phone list to list box
'
'===================================================================
Public Sub RefreshPhoneList()
If LBX_PhoneFiles.GetState = PHONELIST_STATE_PHONELIST Then
LBX_PhoneFiles.ListAllPhones()
End If
End Sub
'===================================================================
' StartProgress
'
' Sets progress bar visible and hides/unhides some buttons
'
'===================================================================
Public Sub StartProgress(ByVal title As String, ByVal line1 As String, ByVal line2 As String)
MainForm.LBX_PhoneFiles.ResetContent()
MainForm.LBX_PhoneFiles.Items.Add(title)
MainForm.LBX_PhoneFiles.Items.Add(line1)
MainForm.LBX_PhoneFiles.Items.Add(line2)
MainForm.Cursor = Cursors.WaitCursor
MainForm.BTN_Create.Visible = False
MainForm.BTN_Delete.Visible = False
MainForm.BTN_Rename.Visible = False
MainForm.BTN_Close.Visible = False
MainForm.BTN_ItemInfo.Visible = False
MainForm.CheckBoxUseCache.Visible = False
MainForm.BTN_Cancel.Visible = True
MainForm.ProgressBar1.Minimum = 0
MainForm.ProgressBar1.Maximum = 100
MainForm.ProgressBar1.Value = 0
MainForm.ProgressBar1.Visible = True
End Sub
'===================================================================
' SetProgress
'
' Sets progress bar state
'
'===================================================================
Public Sub SetProgress(ByVal iState As Integer)
ProgressBar1.Value = iState
End Sub
'===================================================================
' StopProgress
'
' Hides progress bar and hides/unhides some buttons
'
'===================================================================
Public Sub StopProgress()
MainForm.ProgressBar1.Visible = False
MainForm.BTN_Create.Visible = True
MainForm.BTN_Delete.Visible = True
MainForm.BTN_Rename.Visible = True
MainForm.BTN_Close.Visible = True
MainForm.BTN_ItemInfo.Visible = True
MainForm.CheckBoxUseCache.Visible = True
MainForm.BTN_Cancel.Visible = False
MainForm.Cursor = Cursors.Default
End Sub
'===================================================================
' SetCancelled
'
' Sets m_bCancelled value
'
'===================================================================
Public Sub SetCancelled(ByVal bCancelled As Boolean)
m_bCancelled = bCancelled
End Sub
'===================================================================
' IsCancelled
'
' Returns true if user has clicked Cancel button
'
'===================================================================
Public Function IsCancelled() As Boolean
Application.DoEvents()
IsCancelled = m_bCancelled
m_bCancelled = False
End Function
'===================================================================
' FileBrowser_Load
'
' Initialization of FileBrowser form
'
'===================================================================
Private Sub FileBrowser_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
MainForm = Me
' Initializing PC file list:
LBX_PCFiles.PopulateList("")
LBL_PCFiles.Text = LBX_PCFiles.GetCurrentFolder()
' Initializing phone file list:
LBX_PhoneFiles.ListAllPhones()
LBL_PhoneFiles.Text = LBX_PhoneFiles.GetCurrentFolder()
Timer1.Enabled = True
Timer1.Start()
End Sub
'===================================================================
' BTN_CopyPCToPhone_Click
'
' Copies selected pc file to selected phone folder
'===================================================================
Private Sub BTN_CopyPCToPhone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_CopyPCToPhone.Click
Dim pListener As FileOperationListener
If LBX_PCFiles.GetCurrentFile().Length() <= 0 Then
MsgBox("Please select PC file to be copied.")
Else
Dim hFS As Integer
Dim iMedia As Integer = API_MEDIA_ALL
Dim iDeviceID As Integer
Dim iResult As Integer = CONAOpenFS(LBX_PhoneFiles.GetCurrentSN(), iMedia, hFS, iDeviceID)
If iResult = CONA_OK Then
Dim strPCFile As String = LBX_PCFiles.GetCurrentFile() ' file name without path
Dim strPCFolder As String = LBX_PCFiles.GetCurrentFolder() ' e.g. 'c:\temp'
Dim strPhoneFolder As String = LBX_PhoneFiles.GetSelectedFolder()
If strPhoneFolder.Length <= 0 Then
strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder()
End If
pListener = New FileOperationListener
pListener.StartListening(Me.Handle, hFS, "Copying", strPCFolder + "\" + strPCFile, "-->" + strPhoneFolder)
iResult = CONACopyFile(hFS, CONA_DIRECT_PC_TO_PHONE Or CONA_RENAME, strPCFile, strPCFolder, strPhoneFolder)
pListener.StopListening()
If iResult = CONA_OK Then
MsgBox("Copy completed succesfully!")
ElseIf iResult = ECONA_CANCELLED Then
MsgBox("Copy was cancelled.")
Else
ShowErrorMessage("FileBrowser::BTN_CopyPCToPhone_Click(): CONACopyFile failed!", iResult)
End If
' show updated folder listing
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder)
iResult = CONACloseFS(hFS)
If iResult <> CONA_OK Then
ShowErrorMessage("FileBrowser::BTN_CopyPCToPhone_Click(): CONACloseFS failed!", iResult)
End If
Else
ShowErrorMessage("FileBrowser::BTN_CopyPCToPhone_Click(): CONAOpenFS failed!", iResult)
End If
End If
End Sub
'===================================================================
' BTN_CopyPhoneToPC_Click
'
' Copies selected phone file to selected pc folder
'===================================================================
Private Sub BTN_CopyPhoneToPC_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_CopyPhoneToPC.Click
Dim pListener As FileOperationListener
Dim file As String = LBX_PhoneFiles.GetCurrentFile()
If file.Length() <= 0 Then
MsgBox("Please select phone file to be copied.")
Else
Dim hFS As Integer
Dim iMedia As Integer = API_MEDIA_ALL
Dim iDeviceID As Integer
Dim iResult As Integer = CONAOpenFS(LBX_PhoneFiles.GetCurrentSN(), iMedia, hFS, iDeviceID)
If iResult = CONA_OK Then
Dim strPhoneFile As String = LBX_PhoneFiles.GetCurrentFile()
Dim strPhoneFolder As String = LBX_PhoneFiles.GetSelectedFolder()
Dim strPCFolder As String = LBX_PCFiles.GetCurrentFolder()
pListener = New FileOperationListener
pListener.StartListening(Me.Handle, hFS, "Copying", strPhoneFolder + "\" + strPhoneFile, "-->" + strPCFolder)
iResult = CONACopyFile(hFS, CONA_DIRECT_PHONE_TO_PC Or CONA_RENAME, strPhoneFile, strPhoneFolder, strPCFolder)
pListener.StopListening()
If iResult = CONA_OK Then
MsgBox("Copy completed succesfully!")
ElseIf iResult = ECONA_CANCELLED Then
MsgBox("Copy was cancelled.")
Else
ShowErrorMessage("FileBrowser::BTN_CopyPhoneToPC_Click(): CONACopyFile failed!", iResult)
End If
' show updated folder listing
LBX_PCFiles.PopulateList("")
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder)
iResult = CONACloseFS(hFS)
If iResult <> CONA_OK Then
ShowErrorMessage("FileBrowser::BTN_CopyPhoneToPC_Click(): CONACloseFS failed!", iResult)
End If
Else
ShowErrorMessage("FileBrowser::BTN_CopyPhoneToPC_Click(): CONAOpenFS failed!", iResult)
End If
End If
End Sub
'===================================================================
' BTN_MovePCToPhone_Click
'
' Moves selected pc file to selected phone folder
'===================================================================
Private Sub BTN_MovePCToPhone_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_MovePCToPhone.Click
Dim pListener As FileOperationListener
If LBX_PCFiles.GetCurrentFile().Length() <= 0 Then
' No PC file selected
MsgBox("Please select PC file to be moved.")
Else
Dim hFS As Integer
Dim iMedia As Integer = API_MEDIA_ALL
Dim iDeviceID As Integer
Dim iResult As Integer = CONAOpenFS(LBX_PhoneFiles.GetCurrentSN(), iMedia, hFS, iDeviceID)
If iResult = CONA_OK Then
Dim strPCFile As String = LBX_PCFiles.GetCurrentFile() ' file name without path
Dim strPCFolder As String = LBX_PCFiles.GetCurrentFolder() ' e.g. 'c:\temp'
Dim strPhoneFolder As String = LBX_PhoneFiles.GetSelectedFolder()
If strPhoneFolder.Length <= 0 Then
strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -