📄 filebrowser.cs
字号:
strMessage = "Are you sure you want to permanently delete folder \"";
strMessage += strFolder + "\" from folder \"" + strPhoneFolder + "\"?";
if (MessageBox.Show(strMessage, "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
pListener = new FileOperationListener();
pListener.StartListening(this.Handle, hFS, "Deleting", strPhoneFolder + "\\" + strFolder, "");
iResult = CONAFileSystem.CONADeleteFolder(hFS, strFolder, CONADefinitions.CONA_DELETE_FOLDER_WITH_FILES, strPhoneFolder);
pListener.StopListening();
if (iResult == PCCSErrors.CONA_OK)
{
MessageBox.Show("Delete folder completed succesfully!");
}
else if (iResult == PCCSErrors.ECONA_CANCELLED)
{
MessageBox.Show("Delete folder was cancelled.");
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Delete_Click(): CONADeleteFolder failed!", iResult);
}
// show updated folder listing
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder);
}
}
else
{
MessageBox.Show("Select file/folder to be deleted.");
}
iResult = CONAFileSystem.CONACloseFS(hFS);
if (iResult != PCCSErrors.CONA_OK)
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Delete_Click(): CONACloseFS failed!", iResult);
}
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Delete_Click(): CONAOpenFS failed!", iResult);
}
}
else
{
// state is phonelist
MessageBox.Show("Please select phone file/folder to be deleted.");
}
}
//===================================================================
// BTN_Cancel_Click
//
// User has clicked Cancel button to cancel current file operation
//===================================================================
private void BTN_Cancel_Click(object sender, System.EventArgs e)
{
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;
}
//===================================================================
// BTN_Close_Click
//
// User has clicked Close button
//===================================================================
private void BTN_Close_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Timer1_Tick(object sender, System.EventArgs e)
{
if (bRefreshPhoneListBox)
{
LBX_PhoneFiles.ListAllPhones();
LBL_PhoneFiles.Text = "";
bRefreshPhoneListBox = false;
}
}
private void BTN_FolderInfo_Click(object sender, System.EventArgs e)
{
if (LBX_PhoneFiles.GetState() == Common.PHONELIST_STATE_PHONECONTENT) {
int hFS = 0;
int iMedia = CONADefinitions.API_MEDIA_ALL;
int iDeviceID = 0;
int iResult = CONAFileSystem.CONAOpenFS(LBX_PhoneFiles.GetCurrentSN(), ref iMedia, ref hFS, ref iDeviceID);
if ( iResult == PCCSErrors.CONA_OK) {
string strSelectedFile = "";
strSelectedFile = LBX_PhoneFiles.GetCurrentFile();
if ( strSelectedFile.Length > 0 ) {
string strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder();
string strPhoneFile = LBX_PhoneFiles.GetCurrentFile();
CONADefinitions.CONAPI_FILE_INFO stFileInfo = new CONADefinitions.CONAPI_FILE_INFO();
System.IntPtr ptrFileInfo = System.IntPtr.Zero;
ptrFileInfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FILE_INFO)));
Marshal.StructureToPtr(stFileInfo, ptrFileInfo, true);
iResult = CONAFileSystem.CONAGetFileInfo(hFS, strPhoneFile, ptrFileInfo, strPhoneFolder);
if ( iResult == PCCSErrors.CONA_OK ) {
stFileInfo = (CONADefinitions.CONAPI_FILE_INFO)Marshal.PtrToStructure(ptrFileInfo, typeof(CONADefinitions.CONAPI_FILE_INFO));
FRM_ItemInfo dlgFileInfo = new FRM_ItemInfo();
dlgFileInfo.Text = "File Info";
int iItemCount = 0;
ListViewItem listItem = new ListViewItem();
listItem.Text = "Name";
listItem.SubItems.Add(stFileInfo.pstrName);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "File permission";
listItem.SubItems.Add(PCCAPIUtils.Permissions2String(stFileInfo.iAttributes));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "File modified time";
listItem.SubItems.Add(Common.GetLocalFormattedDate(stFileInfo.tFileTime));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount ++;
listItem = new ListViewItem();
listItem.Text = "File size";
listItem.SubItems.Add(stFileInfo.iFileSize.ToString());
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount ++;
listItem = new ListViewItem();
listItem.Text = "MIME type";
listItem.SubItems.Add(stFileInfo.pstrMIMEType);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
dlgFileInfo.ShowDialog(this);
}
else {
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONAGetFileInfo failed!", iResult);
}
CONAFileSystem.CONAFreeFileInfoStructure(ptrFileInfo);
Marshal.FreeHGlobal(ptrFileInfo);
}
else {
string strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder();
string strFolder = LBX_PhoneFiles.SelectedItem.ToString();
CONADefinitions.CONAPI_FOLDER_CONTENT stFolderContent = new CONADefinitions.CONAPI_FOLDER_CONTENT();
System.IntPtr ptrFolderContent = System.IntPtr.Zero;
// strPhoneFolder &= "\\"
strFolder = strFolder.TrimStart(('['));
strFolder = strFolder.TrimEnd((']'));
ptrFolderContent = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FOLDER_CONTENT)));
stFolderContent.iSize = Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FOLDER_CONTENT));
Marshal.StructureToPtr(stFolderContent, ptrFolderContent, true);
iResult = CONAFileSystem.CONAGetFolderInfo(hFS, CONADefinitions.CONA_GET_FOLDER_INFO, strFolder, strPhoneFolder, ptrFolderContent, null);
if ( iResult == PCCSErrors.CONA_OK ) {
stFolderContent = (CONADefinitions.CONAPI_FOLDER_CONTENT)Marshal.PtrToStructure(ptrFolderContent, typeof(CONADefinitions.CONAPI_FOLDER_CONTENT));
CONADefinitions.CONAPI_FOLDER_INFO2 stFolderInfo = (CONADefinitions.CONAPI_FOLDER_INFO2)Marshal.PtrToStructure(stFolderContent.pFolderInfo, typeof(CONADefinitions.CONAPI_FOLDER_INFO2));
FRM_ItemInfo dlgFileInfo = new FRM_ItemInfo();
dlgFileInfo.Text = "Folder Info";
int iItemCount = 0;
ListViewItem listItem = new ListViewItem();
listItem.Text = "Name";
listItem.SubItems.Add(stFolderInfo.pstrName);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Absolute path";
listItem.SubItems.Add(stFolderInfo.pstrLocation);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Type and permission";
listItem.SubItems.Add(PCCAPIUtils.Permissions2String(stFolderInfo.iAttributes));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Folder time";
listItem.SubItems.Add(Common.GetLocalFormattedDate(stFolderInfo.tFolderTime));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Label";
listItem.SubItems.Add(stFolderInfo.pstrLabel);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Memory type";
listItem.SubItems.Add(stFolderInfo.pstrMemoryType);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount ++;
listItem = new ListViewItem();
listItem.Text = "Identification ID";
listItem.SubItems.Add(stFolderInfo.pstrID);
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Free memory";
listItem.SubItems.Add(Common.StrFormatByteSize(stFolderInfo.dlFreeMemory));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Total memory";
listItem.SubItems.Add(Common.StrFormatByteSize(stFolderInfo.dlTotalMemory));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Used memory";
listItem.SubItems.Add(Common.StrFormatByteSize(stFolderInfo.dlUsedMemory));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Number of files";
listItem.SubItems.Add(stFolderInfo.iContainFiles.ToString());
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Number of folders";
listItem.SubItems.Add(stFolderInfo.iContainFolders.ToString());
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
listItem = new ListViewItem();
listItem.Text = "Size of folder content";
listItem.SubItems.Add(Common.StrFormatByteSize(stFolderInfo.dlTotalSize));
dlgFileInfo.ListView.Items.Insert(iItemCount, listItem);
iItemCount++;
dlgFileInfo.ShowDialog(this);
}
else {
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONAGetFolderInfo failed!", iResult);
}
CONAFileSystem.CONAFreeFolderContentStructure(ptrFolderContent);
Marshal.FreeHGlobal(ptrFolderContent);
}
iResult = CONAFileSystem.CONACloseFS(hFS);
if (iResult != PCCSErrors.CONA_OK ) {
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONACloseFS failed!", iResult);
}
}
else {
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_FileInfo_Click(): CONAOpenFS failed!", iResult);
}
}
else {
// state is phonelist
MessageBox.Show("No phone file or folder selected.");
}
}
public bool UseCache()
{
return this.checkBoxUseCache.Checked;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -