📄 filebrowser.vb
字号:
' User has clicked Cancel button to cancel current file operation
'===================================================================
Private Sub BTN_Cancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_Cancel.Click
m_bCancelled = True
Cursor = Cursors.Default
BTN_Create.Visible = True
BTN_Delete.Visible = True
BTN_Rename.Visible = True
BTN_Close.Visible = True
BTN_Cancel.Visible = False
ProgressBar1.Visible = False
End Sub
'===================================================================
' BTN_Close_Click
'
' User has clicked Close button
'===================================================================
Private Sub BTN_Close_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_Close.Click
Me.Close()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If bRefreshPhoneListBox Then
LBX_PhoneFiles.ListAllPhones()
LBL_PhoneFiles.Text = ""
bRefreshPhoneListBox = False
End If
End Sub
Private Function GetLocalFormattedDate(ByVal dwTime As System.Runtime.InteropServices.ComTypes.FILETIME) As String
If dwTime.dwHighDateTime <> 0 And dwTime.dwLowDateTime <> 0 Then
Dim st As SYSTEMTIME = New SYSTEMTIME()
FileTimeToSystemTime(dwTime, st)
Dim dt As DateTime = New DateTime(st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, DateTimeKind.Local)
GetLocalFormattedDate = dt.ToString()
Else
GetLocalFormattedDate = ""
End If
End Function
Private Function StrFormatByteSize(ByVal lSize As Long) As String
Dim dlSize As Decimal
If lSize < 1000 Then
StrFormatByteSize = lSize.ToString() + " bytes"
ElseIf lSize < 1000000 Then
dlSize = lSize / 1000
StrFormatByteSize = String.Format("{0:0.0}", dlSize) + "KB"
ElseIf lSize < 1000000000 Then
dlSize = lSize / 1000000
StrFormatByteSize = String.Format("{0:0.0}", dlSize) + "MB"
ElseIf lSize < 1000000000000 Then
dlSize = lSize / 1000000000
StrFormatByteSize = String.Format("{0:0.0}", dlSize) + "GB"
Else
dlSize = lSize / 1000000000000
StrFormatByteSize = String.Format("{0:0.0}", dlSize) + "TB"
End If
End Function
Private Sub BTN_ItemInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTN_ItemInfo.Click
If LBX_PhoneFiles.GetState() = PHONELIST_STATE_PHONECONTENT Then
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 strSelectedFile As String
strSelectedFile = LBX_PhoneFiles.GetCurrentFile
If strSelectedFile.Length > 0 Then
Dim strPhoneFolder As String = LBX_PhoneFiles.GetCurrentFolder
Dim strPhoneFile As String = LBX_PhoneFiles.GetCurrentFile
Dim stFileInfo As CONAPI_FILE_INFO = New CONAPI_FILE_INFO()
Dim ptrFileInfo As IntPtr = IntPtr.Zero
ptrFileInfo = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(CONAPI_FILE_INFO)))
'Marshal.StructureToPtr(stFileInfo, ptrFileInfo, True)
iResult = CONAGetFileInfo(hFS, strPhoneFile, ptrFileInfo, strPhoneFolder)
If iResult = CONA_OK Then
stFileInfo = Marshal.PtrToStructure(ptrFileInfo, GetType(CONAPI_FILE_INFO))
Dim dlgFileInfo As FRM_FolderInfo = New FRM_FolderInfo
dlgFileInfo.Text = "File Info"
Dim iItemCount As Integer = 0
Dim listItem As ListViewItem = New ListViewItem()
listItem.Text = "Name"
listItem.SubItems.Add(stFileInfo.pstrName)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "File permission"
listItem.SubItems.Add(Permissions2String(stFileInfo.iAttributes))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "File modified time"
listItem.SubItems.Add(GetLocalFormattedDate(stFileInfo.tFileTime))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "File size"
listItem.SubItems.Add(stFileInfo.iFileSize.ToString())
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "MIME type"
listItem.SubItems.Add(stFileInfo.pstrMIMEType)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
dlgFileInfo.ShowDialog(Me)
Else
ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONAGetFileInfo failed!", iResult)
End If
CONAFreeFileInfoStructure(ptrFileInfo)
Marshal.FreeHGlobal(ptrFileInfo)
Else
Dim strPhoneFolder As String = LBX_PhoneFiles.GetCurrentFolder()
Dim strFolder As String = LBX_PhoneFiles.SelectedItem
Dim stFolderContent As CONAPI_FOLDER_CONTENT = New CONAPI_FOLDER_CONTENT()
Dim ptrFolderContent As IntPtr = IntPtr.Zero
'strPhoneFolder &= "\\"
strFolder = strFolder.TrimStart("[")
strFolder = strFolder.TrimEnd("]")
ptrFolderContent = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(CONAPI_FOLDER_CONTENT)))
stFolderContent.iSize = Marshal.SizeOf(GetType(CONAPI_FOLDER_CONTENT))
Marshal.StructureToPtr(stFolderContent, ptrFolderContent, True)
iResult = CONAGetFolderInfo(hFS, CONA_GET_FOLDER_INFO, strFolder, strPhoneFolder, ptrFolderContent, Nothing)
If iResult = CONA_OK Then
stFolderContent = Marshal.PtrToStructure(ptrFolderContent, GetType(CONAPI_FOLDER_CONTENT))
Dim stFolderInfo As CONAPI_FOLDER_INFO2 = Marshal.PtrToStructure(stFolderContent.pFolderInfo, GetType(CONAPI_FOLDER_INFO2))
Dim dlgFileInfo As FRM_FolderInfo = New FRM_FolderInfo
dlgFileInfo.Text = "Folder Info"
Dim iItemCount As Integer = 0
Dim listItem As ListViewItem = New ListViewItem()
listItem.Text = "Name"
listItem.SubItems.Add(stFolderInfo.pstrName)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Absolute path"
listItem.SubItems.Add(stFolderInfo.pstrLocation)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Type and permission"
listItem.SubItems.Add(Permissions2String(stFolderInfo.iAttributes))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Folder time"
listItem.SubItems.Add(GetLocalFormattedDate(stFolderInfo.tFolderTime))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Label"
listItem.SubItems.Add(stFolderInfo.pstrLabel)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Memory type"
listItem.SubItems.Add(stFolderInfo.pstrMemoryType)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Identification ID"
listItem.SubItems.Add(stFolderInfo.pstrID)
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Free memory"
listItem.SubItems.Add(StrFormatByteSize(stFolderInfo.dlFreeMemory))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Total memory"
listItem.SubItems.Add(StrFormatByteSize(stFolderInfo.dlTotalMemory))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Used memory"
listItem.SubItems.Add(StrFormatByteSize(stFolderInfo.dlUsedMemory))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Number of files"
listItem.SubItems.Add(stFolderInfo.iContainFiles.ToString())
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Number of folders"
listItem.SubItems.Add(stFolderInfo.iContainFolders.ToString())
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
listItem = New ListViewItem()
listItem.Text = "Size of folder content"
listItem.SubItems.Add(StrFormatByteSize(stFolderInfo.dlTotalSize))
dlgFileInfo.ListView1.Items.Insert(iItemCount, listItem)
iItemCount += 1
dlgFileInfo.ShowDialog(Me)
Else
ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONAGetFolderInfo failed!", iResult)
End If
CONAFreeFolderContentStructure(ptrFolderContent)
Marshal.FreeHGlobal(ptrFolderContent)
End If
iResult = CONACloseFS(hFS)
If iResult <> CONA_OK Then
ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONACloseFS failed!", iResult)
End If
Else
ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONAOpenFS failed!", iResult)
End If
Else
' state is phonelist
MsgBox("No phone file or folder selected.")
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -