📄 filebrowser.cs
字号:
strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder();
}
pListener = new FileOperationListener();
pListener.StartListening(this.Handle, hFS, "Moving", strPCFolder + "\\" + strPCFile, "-->" + strPhoneFolder);
iResult = CONAFileSystem.CONAMoveFile(hFS, CONADefinitions.CONA_DIRECT_PC_TO_PHONE, strPCFile, strPCFolder, strPhoneFolder);
pListener.StopListening();
if (iResult == PCCSErrors.CONA_OK)
{
MessageBox.Show("Move completed succesfully!");
}
else if (iResult == PCCSErrors.ECONA_CANCELLED)
{
MessageBox.Show("Move was cancelled.");
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_MovePCToPhone_Click(): CONAMoveFile failed!", iResult);
}
// show updated folder listing
LBX_PCFiles.PopulateList("");
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder);
iResult = CONAFileSystem.CONACloseFS(hFS);
if (iResult != PCCSErrors.CONA_OK)
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_MovePCToPhone_Click(): CONACloseFS failed!", iResult);
}
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_MovePCToPhone_Click(): CONAOpenFS failed!", iResult);
}
}
}
//===================================================================
// BTN_MovePhoneToPC_Click
//
// Moves selected phone file to selected pc folder
//===================================================================
private void BTN_MovePhoneToPC_Click(object sender, System.EventArgs e)
{
FileOperationListener pListener;
string file = LBX_PhoneFiles.GetCurrentFile();
if (file.Length <= 0)
{
MessageBox.Show("Please select phone file to be moved.");
}
else
{
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 strPhoneFile = LBX_PhoneFiles.GetCurrentFile();
string strPhoneFolder = LBX_PhoneFiles.GetSelectedFolder();
string strPCFolder = LBX_PCFiles.GetCurrentFolder();
pListener = new FileOperationListener();
pListener.StartListening(this.Handle, hFS, "Moving", strPhoneFolder + "\\" + strPhoneFile, "-->" + strPCFolder);
iResult = CONAFileSystem.CONAMoveFile(hFS, CONADefinitions.CONA_DIRECT_PHONE_TO_PC, strPhoneFile, strPhoneFolder, strPCFolder);
pListener.StopListening();
if (iResult == PCCSErrors.CONA_OK)
{
MessageBox.Show("Move completed succesfully!");
}
else if (iResult == PCCSErrors.ECONA_CANCELLED)
{
MessageBox.Show("Move was cancelled.");
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_MovePhoneToPC_Click(): CONAMoveFile failed!", iResult);
}
// show updated folder listing
LBX_PCFiles.PopulateList("");
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder);
iResult = CONAFileSystem.CONACloseFS(hFS);
if (iResult != PCCSErrors.CONA_OK)
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_MovePhoneToPC_Click(): CONACloseFS failed!", iResult);
}
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_MovePhoneToPC_Click(): CONAOpenFS failed!", iResult);
}
}
}
//===================================================================
// BTN_Create_Click
//
// Creates new folder to selected phone folder
//===================================================================
private void BTN_Create_Click(object sender, System.EventArgs e)
{
FileOperationListener pListener;
FRM_Create CreateDlg = new FRM_Create();
CreateDlg.TXB_Name.Text = "";
if (CreateDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
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 strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder();
pListener = new FileOperationListener();
pListener.StartListening(this.Handle, hFS, "Creating", strPhoneFolder + "\\" + CreateDlg.TXB_Name.Text, "");
iResult = CONAFileSystem.CONACreateFolder(hFS, CreateDlg.TXB_Name.Text, strPhoneFolder);
pListener.StopListening();
if (iResult == PCCSErrors.CONA_OK)
{
MessageBox.Show("Create folder completed succesfully!");
}
else if (iResult == PCCSErrors.ECONA_CANCELLED)
{
MessageBox.Show("Create folder was cancelled.");
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Create_Click(): CONACreateFolder failed!", iResult);
}
// show updated folder listing
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder);
iResult = CONAFileSystem.CONACloseFS(hFS);
if (iResult != PCCSErrors.CONA_OK)
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Create_Click(): CONACloseFS failed!", iResult);
}
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Create_Click(): CONAOpenFS failed!", iResult);
}
}
}
//===================================================================
// BTN_Rename_Click
//
// Renames a folder or file from phone. If the selected item is
// a phone, renames friendly name of phone
//===================================================================
private void BTN_Rename_Click(object sender, System.EventArgs e)
{
bool bIsFile = true;
// selected item is file - not folder
if (LBX_PhoneFiles.SelectedIndex != -1)
{
FRM_Rename RenameDlg = new FRM_Rename();
RenameDlg.LBL_OldName.Text = LBX_PhoneFiles.GetCurrentFile();
if (RenameDlg.LBL_OldName.Text.Length <= 0)
{
bIsFile = false;
// selected item is folder - not file
RenameDlg.LBL_OldName.Text = LBX_PhoneFiles.GetSelectedFolder();
}
if (RenameDlg.LBL_OldName.Text.Length > 0)
{
if (RenameDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
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)
{
if (iResult == PCCSErrors.CONA_OK)
{
string strPhoneFolder = LBX_PhoneFiles.GetCurrentFolder();
string strNewName = RenameDlg.TXB_NewName.Text;
string strOldName = RenameDlg.LBL_OldName.Text;
strOldName = strOldName.Substring(strOldName.LastIndexOf("\\") + 1);
if (bIsFile)
{
iResult = CONAFileSystem.CONARenameFile(hFS, strOldName, strNewName, strPhoneFolder);
}
else
{
iResult = CONAFileSystem.CONARenameFolder(hFS, strOldName, strNewName, strPhoneFolder);
}
if (iResult == PCCSErrors.CONA_OK)
{
// show updated folder listing
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder);
MessageBox.Show("Rename completed succesfully!");
}
else
{
if (bIsFile)
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Rename_Click(): CONARenameFile failed!", iResult);
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Rename_Click(): CONARenameFolder failed!", iResult);
}
}
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Rename_Click(): CONAGetCurrentFolder failed!", iResult);
}
}
iResult = CONAFileSystem.CONACloseFS(hFS);
if (iResult != PCCSErrors.CONA_OK)
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Rename_Click(): CONACloseFS failed!", iResult);
}
}
}
else
{
MessageBox.Show("No phone renaming");
}
}
else
{
MessageBox.Show("Please select file/folder to be renamed.");
}
}
//===================================================================
// BTN_Delete_Click
//
// Deletes selected phone file/folder
//===================================================================
private void BTN_Delete_Click(object sender, System.EventArgs e)
{
FileOperationListener pListener;
if (LBX_PhoneFiles.GetState() == Common.PHONELIST_STATE_PHONECONTENT)
{
string strMessage;
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 strSelectedtxt = "";
int cursel = LBX_PhoneFiles.SelectedIndex;
if (cursel != -1)
{
strSelectedtxt = LBX_PhoneFiles.Items[cursel].ToString();
}
string strSelectedFile = LBX_PhoneFiles.GetCurrentFile();
if (strSelectedFile.Length > 0)
{
string strPhoneFile = LBX_PhoneFiles.GetCurrentFile();
string strPhoneFolder = LBX_PhoneFiles.GetSelectedFolder();
strMessage = "Are you sure you want to permanently delete file \"";
strMessage += strPhoneFile + "\" from folder \"" + strPhoneFolder + "\"?";
if (MessageBox.Show(strMessage, "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
pListener = new FileOperationListener();
pListener.StartListening(this.Handle, hFS, "Deleting", strPhoneFolder + "\\" + strPhoneFile, "");
iResult = CONAFileSystem.CONADeleteFile(hFS, strPhoneFile, strPhoneFolder);
pListener.StopListening();
if (iResult == PCCSErrors.CONA_OK)
{
MessageBox.Show("Delete file completed succesfully!");
}
else if (iResult == PCCSErrors.ECONA_CANCELLED)
{
MessageBox.Show("Delete file was cancelled.");
}
else
{
PCCAPIUtils.ShowErrorMessage("FileBrowser::BTN_Delete_Click(): CONADeleteFile failed!", iResult);
}
// show updated folder listing
LBX_PhoneFiles.ShowPhoneFolder(strPhoneFolder);
}
}
else if (strSelectedtxt.Length > 0 & strSelectedtxt != "[..]")
{
string strPhoneFolder;
strPhoneFolder = LBX_PhoneFiles.GetSelectedFolder();
int iLastSeparator = strPhoneFolder.LastIndexOf("\\");
strPhoneFolder = strPhoneFolder.Remove(iLastSeparator, strPhoneFolder.Length - iLastSeparator);
string strFolder = LBX_PhoneFiles.GetItemData(LBX_PhoneFiles.SelectedIndex);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -