private void cmsFolderList_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Name) { //粘贴项 case "tsmiPaste": //判断操作类型 switch (FileOperation_Type) { case FileItemOperationType.FILE_COPY: string strURL_FileCopy = URL.GetUrl_CopyFile(FileOperation_FolderID, CuttentFolderID, FileOperation_ItemID); fileCopy(strURL_FileCopy); break; case FileItemOperationType.FILE_SHEAR: string strURL_FileShear = URL.GetUrl_MoveFile(FileOperation_FolderID, CuttentFolderID, FileOperation_ItemID); fileCopy(strURL_FileShear); //文件移动和拷贝的操作非常类似 //剪切执行完成后操作类型置空 FileOperation_Type = FileItemOperationType.NONE; break; default: break; } break; case "tsmiUpload": //打开一个文件选择器 OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "选择要上传的文件"; ofd.ShowDialog(); if (ofd.FileName == null || ofd.FileName == "") { return; } //执行文件上传 uploadFile(ofd.FileName); break; case "tsmiRefresh": readFolderMenu(CuttentFolderID); break; case "tsmiCreateFolder": createFolder(); break; default: break; } }
public void IFileItemCallBack_OnFileItemMenuStripClick(FileItem.Type type, ToolStripItem menuItem, FileItem item) { //如果是文件的快捷菜单项被单击 if (type == FileItem.Type.FILE) { //判断被单击的快捷菜单项 switch (menuItem.Name) { //下载 case "tsmiDownload": downloadFile(item.fileInfo.filename, item.fileInfo.fileid); break; //删除 case "tsmiDelete": deleteFile(item); break; //重命名 case "tsmiRename": string newfilename = Microsoft.VisualBasic.Interaction.InputBox("请输入文件的新名称:", "重命名", item.fileInfo.filename); if (newfilename == null || newfilename == "") { return; } renameFile(CuttentFolderID, item.fileInfo.fileid, newfilename); break; //复制 case "tsmiCopy": FileOperation_Type = FileItemOperationType.FILE_COPY; FileOperation_ItemID = item.fileInfo.fileid; FileOperation_FolderID = CuttentFolderID; labFileInfo.Text = "复制文件 - " + item.fileInfo.filename; break; //剪切 case "tsmiShear": FileOperation_Type = FileItemOperationType.FILE_SHEAR; FileOperation_ItemID = item.fileInfo.fileid; FileOperation_FolderID = CuttentFolderID; labFileInfo.Text = "剪切文件 - " + item.fileInfo.filename; break; default: MessageBox.Show("文件名:" + item.fileInfo.filename + "\n" + menuItem.Text + " 功能未完成."); break; } } //如果是文件夹的快捷菜单项被单击 else if (type == FileItem.Type.FOLDER) { switch (menuItem.Name) { //打开文件夹 case "tsmiOpenFolder": //打开所选的文件夹 openFolder(item.folderInfo.foldername, item.folderInfo.folderid); break; //删除文件夹 //case "tsmiDeleteFolder": // deleteFolder(item); // break; default: MessageBox.Show("文件夹名:" + item.folderInfo.foldername + "\n" + menuItem.Text + " 功能未完成."); break; } } }